Closed oryband closed 11 years ago
Sure, just add the following line to your vimrc script:
autocmd BufWritePost * call xolox#easytags#autoload('BufWritePost')
From now on the vim-easytags plug-in will run automatically whenever you write a buffer.
Perhaps this should be added to the docs?
Sure, good idea. I created a new section Customizing the easytags plug-in and added the subsection Update & highlight tags immediately after save (the new version of doc/easytags.txt
will be included in the next release). Thanks for the suggestion!
This fix doesn't appear to work.
This is my relevant .vimrc
:
set tags=./.tags;~/
let g:easytags_file = '~/.tags' " Default tags file.
let g:easytags_cmd = 'ctags'
let g:easytags_dynamic_files = 1 " Search tag files.
let g:easytags_auto_update = 0
let g:easytags_auto_highlight = 0
let g:easytags_updatetime_warn = 0 " Don't show updatetime annoying warning.
autocmd BufWritePost * call xolox#easytags#autoload('BufWritePost') " Update tags on save.
Please re-open.
I tested the code I suggested before I posted it, so it does work for me. Please run the following Vim command:
:set verbose=1
After running that Vim command, save a buffer in Vim (with the settings you specified above) to collect some debug logs. After the messages have gone, you can recall them with Vim's :messages
command. Please post the messages here so I can take a look at what the plug-in is doing.
This is the only thing I get on :mess
(mypipe.c just a regular c file):
"src/mypipe.c" 44L, 896C
"src/mypipe.c" 45L, 897C [w]
"src/mypipe.c" 45L, 897C [w]
I've no idea what's wrong.
Sorry about all of the back and forth. I just realized a mistake in my local testing (failed to reapply a setting, should have restarted Vim). While figuring this out I also realized there are already two options that can help you. Below is a quote from the documentation.
The
g:easytags_always_enabled
optionBy default the plug-in automatically generates and highlights tags when you stop typing for a few seconds (this works using the CursorHold automatic command). This means that when you edit a file, the dynamic highlighting won’t appear until you pause for a moment. If you don’t like this you can configure the plug-in to always enable dynamic highlighting:
:let g:easytags_always_enabled = 1
Be warned that after setting this option you’ll probably notice why it’s disabled by default: Every time you edit a file in Vim, the plug-in will first run Exuberant Ctags and then highlight the tags, and this slows Vim down quite a lot. I have some ideas on how to improve this latency by running Exuberant Ctags in the background so stay tuned!
Note: If you change this option it won’t apply until you restart Vim, so you’ll have to set this option in your vimrc script.
However what you asked for was to update the tags when writing a buffer to a file, while the above option will also update the tags when you read a buffer. If this bothers you then you can set the following in your vimrc script:
set tags=./.tags;~/
let g:easytags_file = '~/.tags' " Default tags file.
let g:easytags_cmd = 'ctags'
let g:easytags_dynamic_files = 1 " Search tag files.
let g:easytags_auto_update = 1
let g:easytags_auto_highlight = 1
let g:easytags_updatetime_warn = 0 " Don't show updatetime annoying warning.
let g:easytags_events = ['BufWritePost']
The g:easytags_events
options is currently undocumented, but if this resolves the problem for you, I could make it official :-).
Yup, this does it.
Thanks!
Go ahead and make it official, you have my blessing. :smile:
I've documented the option. Enjoy the plug-in and thanks for the feedback!
I'd very much like the option to update the
tags
file on buffer write, instead of using delayed intervals.Is there an option to add this?
Thanks.