Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(picker.sources): add lazy plugin spec #680

Open
1 task done
qw457812 opened this issue Jan 21, 2025 · 4 comments
Open
1 task done

feature(picker.sources): add lazy plugin spec #680

qw457812 opened this issue Jan 21, 2025 · 4 comments
Labels
enhancement New feature or request

Comments

@qw457812
Copy link

qw457812 commented Jan 21, 2025

Did you check the docs?

  • I have read all the snacks.nvim docs

Is your feature request related to a problem? Please describe.

I split the plugin specs in multiple files as suggested by lazy.nvim doc. So I need to remember the spec position or search for "/plugin_name" to look over when needed.

Some cases:

  • When I search for /snacks, URLs like https://github.com/folke/snacks.nvim/pull/136#issuecomment-2492044614 in my config also come up.
  • I have to search /nvim-treesitter instead of /treesitter.
  • Specs could just be a name like "nvim-treesitter", which is hard to search.

Describe the solution you'd like

Before I migrate away from telescope, I enjoy polirritmico/telescope-lazy-plugins.nvim.

Screen Shot:

Image

It shows both LazyVim and User Specs (but does not distinguish between them).

I wish snacks picker adds a source for lazy plugin spec like telescope-lazy-plugins.nvim. Please distinguishes between LazyVim and User Specs if you do this. Something like editor/snacks_picker (lazyvim) and plugins/ui (user).

Describe alternatives you've considered

Search for /plugin_name.

Additional context

Thank you for your continued contribution. Enjoy your works so much. Please feel free to close this issue.

@qw457812 qw457812 added the enhancement New feature or request label Jan 21, 2025
@dpetka2001
Copy link
Contributor

Just do /snacks.*" for your first case and /.*treesitter" for your second? Really no need for a custom picker in my personal opinion. You can achieve what you want by passing appropriate patterns in grep.

@dpetka2001
Copy link
Contributor

You could also use something of a keymap like the following

{
        "<leader>fl",
        function()
          local dirs = {
            vim.fn.stdpath("config") .. "/lua/plugins", -- user specs
            vim.fn.stdpath("data") .. "/lazy/LazyVim/lua/lazyvim/plugins", -- LazyVim specs
          }
          ---@diagnostic disable-next-line: missing-fields
          Snacks.picker.files({
            finder = function()
              local items = {}
              for _, item in ipairs(dirs) do
                items[#items + 1] = {
                  file = item,
                  text = item,
                }
              end
              return items
            end,
            format = "text",
            actions = {
              confirm = function(_, item)
                Snacks.picker.pick("grep", {
                  cwd = item.file,
                  search = "/.*",
                  live = true,
                  on_show = function()
                    vim.schedule(function()
                      vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("i", true, false, true), "n", false)
                      vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes("<right>", true, false, true), "n", false)
                    end)
                  end,
                })
              end,
            },
          })
        end,
        desc = "Find Lazy Plugin Spec",
      },

That way in the initial picker you choose if you want to search User or LazyVim specs and when you choose a directory another grep picker launches where you can search with the appropriate pattern for the plugin you want.

@qw457812
Copy link
Author

qw457812 commented Jan 22, 2025

Just do /snacks.*" for your first case and /.*treesitter" for your second? Really no need for a custom picker in my personal opinion. You can achieve what you want by passing appropriate patterns in grep.

Thanks, it helps. However, spec could also be name only like:

https://github.com/LazyVim/LazyVim/blob/1e83b4f843f88678189df81b1c88a400c53abdbc/lua/lazyvim/plugins/extras/lang/angular.lua#L11-L13

Sorry, I didn't make myself clear. About distinguishes between LazyVim and User Specs, I think it would be better to list them all, but label them in some way, like editor/snacks_picker (lazyvim) and plugins/ui (user).

@dpetka2001
Copy link
Contributor

Thanks, it helps. However, spec could also be name only like

Then you just adjust your pattern to not include the character /.

For the second part of your comment, you could maybe use the format field in the grep picker to check each item's cwd and adjust the format based on that if you want to experiment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants