Git Product home page Git Product logo

browse.nvim's Introduction

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

  • lazy.nvim

    {
        "lalitmee/browse.nvim",
        dependencies = { "nvim-telescope/telescope.nvim" },
    }
  • packer.nvim

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

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

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 = {}
})

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

  • 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()

Customizations

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

  • google
  • duckduckgo
  • brave
  • bing

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

Buy Me A Coffee

browse.nvim's People

Contributors

lalitmee avatar dich0tomy avatar lalitmeeq avatar green726 avatar mmolhoek avatar quminouse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.