ludovicchabant / vim-gutentags

A Vim plugin that manages your tag files
https://bolt80.com/gutentags/
MIT License
2.3k stars 174 forks source link

Trigger some notification when a tags file is updated #138

Closed aktau closed 5 years ago

aktau commented 7 years ago

Hi, I just switched from vim-easytags to vim-gutentags, and I'm not regretting it. The only feature I'm missing is tags highlighting. It saves me from fruitlessly typing ctrl-] on things that doesn't have any tags (yet). It also serves as a marker of when a file has been processed.

I understand that this is not a core concern of vim-gutentags. I'd like to code it up myself, but I'd need to know when I should kick of my code for (re)processing the tags file to let the Vim syntax/keyword matcher know what to highlight.

Is there anything I can use already? If not, is there some autocommand that vim-gutentags could kick off? Thanks.

davidosomething commented 7 years ago

autocmd User GutentagsUpdated call g:DOTHETHING

or bind c-] such that if a tag is not found (cursor did not move, buffer did not enter) update tags

aktau commented 7 years ago

Thanks a lot. I noticed you added this in 9d3c98cd. Perhaps some docs for this feature could prevent further idle issues about this.

ludovicchabant commented 7 years ago

Thanks for the compliments @aktau!

I don't think GutentagsUpdated is the solution, though? I think it triggers only when the tags start updating, which means I should probably rename it to GutentagsUpdating or something... I think we need another auto-command that gets triggered when the background job ends and the tags file is actually ready for consumption.

The status line indicator actually does something a bit like it (see gutentags#statusline) by checking when the lock file goes away. I think I'll probably only implement some proper notification system when I refactor Gutentags to use the new background job API from Vim 8.

aktau commented 6 years ago

The status line indicator actually does something a bit like it (see gutentags#statusline) by checking when the lock file goes away. I think I'll probably only implement some proper notification system when I refactor Gutentags to use the new background job API from Vim 8.

Circling back to this: that would be excellent :). I notice I'm not the only one that likes the tag highlighting: https://www.reddit.com/r/vim/comments/85cc6d/further_uses_for_ctags/.

weilbith commented 6 years ago

@aktau do u still working on such an highlight plugin? I'd like to have some feature as well and have the same problems with easytags. I thought about writing such plugin myself also, but haven't started yet (always too much to do) Couldn't find anything on a quick search in ur repositories. Any progress?

ludovicchabant commented 6 years ago

The latest Gutentags code is using the Vim8/Neovim job APIs as promised, so the GutentagsUpdated user auto-command now does what it sounds like, which is to fire after the tags file generation has finished. So you can probably trigger whatever tag highlighting thing you have from there... please report how well it works @aktau, along with how you're actually achieving it -- I'm curious about it :)

dizhipeng commented 5 years ago

Hello. I'm using plugin taghighlight, and want to re-highlight all tags after gutentags has finished updating. Here is what I do: autocmd User GutentagsUpdated UpdateTypesFileOnly but it doesn't work. UpdateTypesFileOnly is a command provided by taghighlight to read the tags file, and do the highlight accordingly. It works perfectly when executed manually. I checked the tags file is OK, so are there any hints how to solve this? Thanks

ludovicchabant commented 5 years ago

Mmmh not only it doesn't work, but it also completely locks up my Vim for several seconds (whereas it doesn't do that if I run UpdateTypesFileOnly myself... it's very quick that way).

It looks to me like it's a problem with TagHighlight, where UpdateTypesFileOnly isn't happy when it's run from inside an auto-command. You can see that it's the case if you hook up some custom auto-command (like, say, autocmd User DoSomething UpdateTypesFileOnly) and then execute that manually (with doautocmd User DoSomething). For me, it indeed locks up Vim for several seconds, and doesn't highlight anything.