vim-rtags
vim-rtags copied to clipboard
automatically re-index file on save
I find I have to re-index the file after every change, otherwise the jumps don't work. Would be great if the plugin had an option to do this for you.
Thanks for the awesome plugin.
I agree. I'll work on an autocmd to do this.
Does this work ?
autocmd FileWritePost,FileAppendPost * call rtags#ReindexFile()
Shouldn't the code in rdm 'see' the file was changed and reindex on its own ?
That command appears to work. I wonder if instead of setting it for all filetypes maybe it should be restricted to c and cpp.
Also, rtags should be watching files for changes - but there are bugs. See https://github.com/Andersbakken/rtags/issues/1172. Hence I think it'd be nice if the plugin had an option to enable the automatic re-index on save.
ok, perhaps -
autocmd FileWritePost,FileAppendPost *.{c,h,cpp,hpp,ipp} call rtags#ReindexFile()
That looks like it would work! Do we need BufWritePost also?
I thought there was an easy way to use the vim filetype to filter other autocommands. This is what I came up with, seems to work:
autocmd Filetype c,cpp autocmd BufWritePost,FileWritePost,FileAppendPost <buffer> call rtags#ReindexFile()
I can add to the plugin to do this, and I have several other changes I've made to my clone which I find helpful. I haven't seen any updates or PRs accepted to it in a while though.
Cool, if you add it I can switch to your clone locally.
@theimpostor my repo has this switch now -
let g:rtagsAutoReindexOnWrite=1
To enable. My repo is at: https://github.com/mckellyln/vim-rtags but I have not yet updated the docs for my changes.
AFAIK, rdm uses inotify to monitor changes to project files. That's why I'd expect it to reindex files once those are modified. @theimpostor , how big is your project? Is it bigger than the value in
cat /proc/sys/fs/inotify/max_user_watches
?
I have mine set to 1048576 (I think I increased it manually) @lyuts thx for vim-rtags.
@lyuts I am on osx high sierra, and it's not clear to me what the file watch limit is. I do have a bunch of projects indexed, I will try reducing this number and see if the autoindexing works again. Thanks for the suggestion.