Skip to content

OliverChao/telescope-picker-list.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

telescope-picker-list.nvim

Screencast.2023-03-28.16.00.24.mp4

A plugin that helps you use any pickers in telescope.

  1. There are too many pickers in telescope, including builtins and extensions, and some third-part plugins that integrates telescope.
  2. It is hard to give any picker one mapping.
  3. You need one way to easily list all pickers and then search you want, and just run this picker.

Installation

Use any plugin manager you like.

lazy

{
  "nvim-telescope/telescope.nvim",
  dependencies = {
        { "OliverChao/telescope-picker-list.nvim" },
    }
}

packer

use { 'OliverChao/telescope-picker-list.nvim' }

Requirements

Config

Initialize picker-list in extensions field.

extensions = {

  -- picker-list extensions
  picker_list = {},
}
  1. If you want to add some options for pickers, use opts.
  2. If you want to exclude some pickers, use excluded_pickers.
  3. If you want to define you own pickers, use use_pickers.

Here is one example:

telescope.setup({
  -- other config
  extensions = {

    -- picker_list extensions
    picker_list = {
      -- some picker options
      opts = {
        project = { display_type = "full" },
        emoji = require("telescope.themes").get_dropdown({}),
        luasnip = require("telescope.themes").get_dropdown({}),
        notify = require("telescope.themes").get_dropdown({}),
      },
      -- excluded pickers which will not list
      excluded_pickers = {
        "fzf",
        "fd",
      },
      -- user defined pickers
      user_pickers = {
        {
          "todo-comments",
          function()
            vim.cmd([[TodoTelescope theme=dropdown]])
          end,
        },
        {
          "urlview local",
          function()
            vim.cmd([[UrlView]])
          end,
        },
        {
          "urlview lazy",
          function()
            vim.cmd([[UrlView lazy]])
          end,
        },
      },
    }, -- end picker-list
  }, -- end extensions
}) -- end telescope setup function

require("telescope").load_extension("fzf")
require("telescope").load_extension("luasnip")
require("telescope").load_extension("file_browser")
require("telescope").load_extension("project")
require("telescope").load_extension("notify")

-- picker_list must be the last one
require("telescope").load_extension("picker_list")

If you want to register some extensions lazily, you can use require("telescope._extensions.picker_list.main").register(extension_name).

The following config adds goimpl extension after it is loaded.

Please note that you need make sure that telescope is loaded while activating other extensions in this way.

{
    "edolphin-ydf/goimpl.nvim",

    dependencies = {
      "nvim-telescope/telescope.nvim",
      other dependencies...
    },

    ft = "go",

    config = function()
      require("telescope").load_extension("goimpl")
      -- add goimpl to picker_list after it is loaded
      require("telescope._extensions.picker_list.main").register("goimpl")
    end,
  }

Another example for harpoon:

dependencies = {
  "nvim-telescope/telescope.nvim",
  other dependencies...
},
 config = function()
   require("harpoon").setup()
   require("telescope").load_extension("harpoon")

   require("telescope._extensions.picker_list.main").register("harpoon")
 end,

picker-list use cache to locate all extensions for efficiency. In this way, after it is loaded, you need do some extra work to add new extensions. This represents an inevitable compromise solution.

Keymap

-- neovim < 0.7
vim.api.nvim_set_keymap(
  "n",
  "<leader>fh",
  "<CMD>lua require 'telescope'.extensions.picker_list.picker_list()<CR>",
  {
    noremap = true,
    silent = true,
  }
)

-- neovim >= 0.7
vim.keymap.set(
  "n",
  "<leader>fh",
  require('telescope').extensions.picker_list.picker_list
)

Inspiration

This plugin is inspired by telescope-find-pickers.

About

A plugin that helps you use any picker in telescope.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages