camspiers / snap

A fast finder system for neovim.
The Unlicense
490 stars 17 forks source link

How to implement searching help tags? #22

Closed ahmedelgabri closed 3 years ago

ahmedelgabri commented 3 years ago

Something like :Helptags from fzf.vim or telescope.help_tags(), I'm still a bit struggling to get any custom finder implementation to work for me, especially with issues like #13 but for this one, I don't even know if that's possible. For example, there is no CWD in that case to pass to producer.ripgrep.general

camspiers commented 3 years ago

Added in this commit:

https://github.com/camspiers/snap/commit/e52ebce05cb25e1ea8b0b2feaee0367fc301ffd9

There is now a help producer, a help previewer and a help selector.

camspiers commented 3 years ago

I hope it all makes sense, remember you can do anything you want in your own custom producers, previews, selectors etc. You don't need to use ripgrep etc.

local fzf = snap.get'consumer.fzf'
snap.register.map({"n"}, {"<Leader>fh"}, function ()
  snap.run {
    prompt = "Help>",
    producer = fzf(snap.get'producer.vim.help'),
    reverse = true,
    select = snap.get'select.help'.select,
    views = {snap.get'preview.help'}
  }
end)
camspiers commented 3 years ago

Tagging @akinsho too

ahmedelgabri commented 3 years ago

I hope it all makes sense, remember you can do anything you want in your own custom producers, previews, selectors etc. You don't need to use ripgrep etc.

I know, I tried that but was faced with #13 (or maybe I was doing something wrong)

But thanks for this, will give it a try.

ahmedelgabri commented 3 years ago

@camspiers just tried it, works great! thanks 👍🏼

camspiers commented 3 years ago

No problem!

camspiers commented 3 years ago

And thanks for the idea btw :)

akinsho commented 3 years ago

@camspiers thanks for adding this (and tagging me) I've definitely been wanting/missing this functionality.

One quick question which I couldn't tell if it was possible or not was whether it's possible to show the result in a floating window like the other types of pickers? (based on just copying the snippet you posted above), the match is shown in a vertical split instead.

camspiers commented 3 years ago

It shouldn't be displaying in a split if you use views = {snap.get'preview.help'} at least it doesn't for me.

camspiers commented 3 years ago

Do you mean if you select the match?

akinsho commented 3 years ago

Ah, it's because my ftplugin file is being read, and it contains

  autocmd! BufWinEnter <buffer> wincmd L | vertical resize 80

🤔 not sure how to work around this short of removing the line. I think the way the buffers are read triggers autocommands like filetypes etc. which somehow telescope does without

ahmedelgabri commented 3 years ago

Wait, that's not a feature? 😆 I actually liked that split for the help & thought it was built like this. turns out I also had an ftplugin for help with wincmd L

akinsho commented 3 years ago

@camspiers, reluctant to add even more to your plate but just thought it was worth mentioning that although using noautocmd prevents triggering the ftplugin files it also means that syntax highlighting isn't enabled for those buffers. It's not a huge deal and I think it's a bit of a thorny issue to resolve anyway but just putting it out there.

camspiers commented 3 years ago

Syntax highlighting for the help files should be easy to turn on manually in the preview. I welcome a PR but otherwise I can likely get to it tomorrow or the next day.