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

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

Open
alexzanderr opened this issue Jun 10, 2021 · 4 comments

Comments

@alexzanderr
Copy link

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:

  • search for a tag in current opened file
  • if tag is found, when <enter> is pressed, it should jump in the file at that tag's location
  • function close

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
Copy link
Collaborator

raven42 commented Jun 10, 2021

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
Copy link
Author

alexzanderr commented Jun 10, 2021

  • option 1

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.


  • option 2 ( more complex )

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:

  • <C-F>
  • this will open that window
  • search for tags
  • find or not tags (would be great if could navigate with arrows (up/down) between live results
  • if find then when pressing jumps to that tag at the current file tag's line number location

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
Copy link

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
Copy link
Collaborator

raven42 commented Jul 26, 2021

@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.

  • Open a file
  • use :TagbarOpen f to open the tagbar window and switch focus to that window
  • use the vim search functionality /<search-pattern> to search the tags in the tagbar window
  • optionally use the up/down arrow keys to navigate through the tags to find the one you want
  • hit <Enter> to jump to that tag

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants