Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

automatically re-index file on save #111

Open
theimpostor opened this issue Jun 22, 2018 · 12 comments
Open

automatically re-index file on save #111

theimpostor opened this issue Jun 22, 2018 · 12 comments

Comments

@theimpostor
Copy link

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.

@mckellyln
Copy link

mckellyln commented Jun 25, 2018

I agree. I'll work on an autocmd to do this.

@mckellyln
Copy link

mckellyln commented Jun 25, 2018

Does this work ?

autocmd FileWritePost,FileAppendPost * call rtags#ReindexFile()

@mckellyln
Copy link

Shouldn't the code in rdm 'see' the file was changed and reindex on its own ?

@theimpostor
Copy link
Author

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 Andersbakken/rtags#1172. Hence I think it'd be nice if the plugin had an option to enable the automatic re-index on save.

@mckellyln
Copy link

ok, perhaps -

autocmd FileWritePost,FileAppendPost *.{c,h,cpp,hpp,ipp} call rtags#ReindexFile()

@theimpostor
Copy link
Author

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()

@mckellyln
Copy link

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.

@theimpostor
Copy link
Author

Cool, if you add it I can switch to your clone locally.

@mckellyln
Copy link

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

@lyuts
Copy link
Owner

lyuts commented Jul 23, 2018

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

?

@mckellyln
Copy link

I have mine set to 1048576 (I think I increased it manually)
@lyuts thx for vim-rtags.

@theimpostor
Copy link
Author

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

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

No branches or pull requests

3 participants