Home

Awesome

<div align="center">

browse.nvim

browse for anything using your choice of method

Neovim Lua License

browse.nvim

</div>

Features

Requirements

Installation

Setup

-- default values for the setup
require('browse').setup({
  -- search provider you want to use
  provider = "google", -- duckduckgo, bing

  -- either pass it here or just pass the table to the functions
  -- see below for more
  bookmarks = {},
  icons = {
      bookmark_alias = "->", -- if you have nerd fonts, you can set this to ""
      bookmarks_prompt = "", -- if you have nerd fonts, you can set this to "󰂺 "
      grouped_bookmarks = "->", -- if you have nerd fonts, you can set this to 
  }
})

Usage

There are so many ways in which you can use this to improve your search experience. After bookmarks table support for multiple formats and organized structure of the bookmarks, you can just use open_bookmarks() api.

bookmarks

For bookmarks you can declare your bookmarks in lua table format. bookmarks table can contain multiple structures.

  1. grouped urls with a name key in the table (recommended)

    local bookmarks = {
      ["github"] = {
          ["name"] = "search github from neovim",
          ["code_search"] = "https://github.com/search?q=%s&type=code",
          ["repo_search"] = "https://github.com/search?q=%s&type=repositories",
          ["issues_search"] = "https://github.com/search?q=%s&type=issues",
          ["pulls_search"] = "https://github.com/search?q=%s&type=pullrequests",
      },
    }
    
  2. urls with aliases

    local bookmarks = {
      ["github_code_search"] = "https://github.com/search?q=%s&type=code",
      ["github_repo_search"] = "https://github.com/search?q=%s&type=repositories",
    }
    
  3. urls with a query parameter

    local bookmarks = {
      "https://github.com/search?q=%s&type=code",
      "https://github.com/search?q=%s&type=repositories",
    }
    
  4. simple and direct urls

    local bookmarks = {
         "https://github.com/hoob3rt/lualine.nvim",
         "https://github.com/neovim/neovim",
         "https://neovim.discourse.group/",
         "https://github.com/nvim-telescope/telescope.nvim",
         "https://github.com/rockerBOO/awesome-neovim",
     }
    
  5. you can also combine all of the above in a table if you want.

and then pass this table into the browse() function like this

vim.keymap.set("n", "<leader>b", function()
  require("browse").browse({ bookmarks = bookmarks })
end)

If this bookmarks table will be empty or will not be passed and if you select Bookmarks from telescope result, you will not see anything in the telescope results.

search

require('browse').input_search()
require("browse").open_bookmarks({ bookmarks = bookmarks })
require("browse").browse({ bookmarks = bookmarks })

devdocs

require('browse.devdocs').search()
require('browse.devdocs').search_with_filetype()

mdn

require('browse.mdn').search()

Customizations

You can customize the input_search() to use the provider you like. Possible values for the provider are following:

Advanced usage

Create commands for all the functions which browse.nvim exposes and then simply run whatever you want from the command line

local browse = require('browse')

function command(name, rhs, opts)
  opts = opts or {}
  vim.api.nvim_create_user_command(name, rhs, opts)
end

command("InputSearch", function()
  browse.input_search()
end, {})

-- this will open telescope using dropdown theme with all the available options
-- in which `browse.nvim` can be used
command("Browse", function()
  browse.browse({ bookmarks = bookmarks })
end)

command("Bookmarks", function()
  browse.open_bookmarks({ bookmarks = bookmarks })
end)

command("DevdocsSearch", function()
  browse.devdocs.search()
end)

command("DevdocsFiletypeSearch", function()
  browse.devdocs.search_with_filetype()
end)

command("MdnSearch", function()
  browse.mdn.search()
end)

Acknowledgements and Credits

Support

<a href="https://www.buymeacoffee.com/iamlalitmee" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>