Skip to content

browse for anything using your choice of method

License

Notifications You must be signed in to change notification settings

rwrued/browse.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

browse.nvim

browse for anything using your choice of method

Neovim Lua License

browse.nvim

Features

  • cross platform
  • reduces your search key strokes for any stackoverflow query
  • devdocs search
  • MDN search

Requirements

Installation

  • packer.nvim

    use({
      "lalitmee/browse.nvim",
      requires = { "nvim-telescope/telescope.nvim" },
    })
  • vim-plug

    Plug 'nvim-telescope/telescope.nvim'
    Plug 'lalitmee/browse.nvim'

Usage

browse.nvim exposes the following for:

Search

  • input_search(), it will prompt you to search for something
require('browse').input_search()
  • open_bookmarks(), search with the table bookmarks
require("browse").open_bookmarks({ bookmarks = bookmarks })
  • browse(), it opens telescope.nvim dropdown theme to select the method
require("browse").browse({ bookmarks = bookmarks })

devdocs

  • devdocs.search(), search for anything in the devdocs
require('browse.devdocs').search()
  • devdocs.search_with_filetype(), search for anything for the current file type
require('browse.devdocs').search_with_filetype()

MDN

  • mdn.search(), search for anything on MDN
require('browse.mdn').search()

bookmarks

For bookmarks you can declare your bookmarks in lua table format. for example:

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",
}

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.

Customizations

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

  • google
  • duckduckgo
  • brave
  • bing
require('browse').setup({
  -- search provider you want to use
  provider = "google", -- default
})

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("BrowseInputSearch", function()
  browse.input_search()
end, {})

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

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

command("BrowseDevdocsSearch", function()
  browse.devdocs.search()
end, {})

command("BrowseDevdocsFiletypeSearch", function()
  browse.devdocs.search_with_filetype()
end, {})

command("BrowseMdnSearch", function()
  browse.mdn.search()
end, {})

Acknowledgements and Credits

Donate

Buy me a coffee through paypal.

About

browse for anything using your choice of method

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%