preservim / tagbar

Vim plugin that displays tags in a window, ordered by scope
https://preservim.github.io/tagbar
Other
6.12k stars 486 forks source link

fuzzy tag finder - search function for a specific keyboard inserted tag ( :TagBarFuzzyFindTag ) #771

Open alexzanderr opened 3 years ago

alexzanderr commented 3 years ago

i dont know if there is a function for that. i read the docs, i didnt find any related content.

im requesting a feature.

please add a function callable from command-line called :TagBarFuzzyFindTag function behaviour:


just like vs code Ctrl+P + @ outline search: image

it would be great if it would have a beautiful animation like this one.

OR

tell me how to make my own fuzzy tag finder

i know that there are already functions related to this such as :tagbarshowtag and :tagbarcurrenttag, but i cant combine them in order to search for a tag and if found then jump to it, or i dont know how to.

thanks in advance.

raven42 commented 3 years ago

That sounds like it could be a good idea. I don't know that we'd be able to do any kind of a popup type window or auto-fill based on a partial search pattern, but basic searching could be possible.

One thing to note on this, If the tagbar status line is not being used, and the tagbar window has never been opened for a file, then that file has not yet been examined. So if this is implemented it will have to take that into account to force an update on the file before searching for any tags.

Would you expect the syntax to be something like this?

:TagbarSearch <search-pattern>

And would you want to leave the tagbar window closed if it was closed? Or would you want to have it open the tagbar window and jump to the tag in the tagbar window? Or are you expecting it to jump to the tag in the file window?

alexzanderr commented 3 years ago

this would be good

:TagbarSearch <search-pattern>

write :TagbarSearch, then write pattern, press enter. if pattern is found in current file only (because the search consists looking in current file only, not globally) then jump in current file to the tag's location.


a function such as TagbarSearchWithLiveSearch that could be binded to a keymap. when i press for example <C-F> this shoul call the function and then:

image

and then look like this: image

but just for tags that appear in the tagbar (or the current file)

the principle is this:

i would like to see something like this and like vs code's outline search. would be great if you could implement both options.

i know that i have big expectations.

daedroza commented 3 years ago

Honestly this is done using fzf.vim, generate the tags file and use :Tags under the project and search for your function. I use it currently. Also, is there a Telegram group for connecting with others to explore more of tagbar's features?

raven42 commented 3 years ago

@alexzanderr The process you are describing doesn't sound quite like a match for tagbar. Tagbar is using the output of ctags to parse known tags in a file, but not the spots where those tags may be used. In you example, doing a search for https://github and showing all entries that match that in a file doesn't really sound like it would be useful for a tag. There would likely only ever be a single entry of a tag.

Now for partial matches, yes I could see how you could have multiple tags partially matching the search pattern. However this sounds a lot like just using the normal vim search in the tagbar window itself. The process you describe could easily be done in the tagbar window itself.

Much of this can be done using shortcuts as well or configuration options to help control it. There is a g:tagbar_autoclose configuration for example which can close the tagbar window when you jump to a tag. There is also the g:tagbar_sort option to change how the tags are sorted between name and file order. You could also map the :TagbarOpen f to a keymap in vim as well, so it really sounds like this functionality is exactly what tagbar is capable of with a little modification of your key mappings and config in your .vimrc.

@daedroza I'm not aware of any Telegram group for tagbar's features. I've only ever been involved with it here on github.