vim-rake
vim-rake copied to clipboard
C extensions `tags` update
Hi,
I'm playing with ruby C extensions + browsing ruby source (also related to https://github.com/tpope/rbenv-ctags/pull/5) and I notice an issue: after tags are used once to jump to ruby source or include dir, vim's tags option looses tags for ruby C source.
This is a bummer, because the majority of C functions or macros "exposed" to users via ruby.h almost always delegate to some internal ruby functions.. So in most cases a single tags jump is not enough.
I compared how this works when editing ruby files and then making a tags jump to ruby std lib. In this case tags option is handled nicely.
This PR contains a proof of concept solution for the problem: if a user opens a ruby C extension file an autocmd is registered (once). While vim's cwd is inside a ruby project, path and tags options for C files will be updated.
Feedback is appreciated!
I did something vaguely similar in fireplace.vim and it was a huge pain. My advice would be not to activate all of rake.vim; copy 'path' and 'tags' only. Something vaguely like seems like it would work while being pretty conservative:
au FileType c,cpp
\ if !empty(getbufvar('#', 'rake_root')) && getbufvar('#', '&filetype') =~# '^\%(c\|cpp\)$' |
\ let &l:path = getbufvar('#', '&path') |
\ let &l:tags = getbufvar('#', '&tags') |
\ endif
Thanks for the pointer, the PR is updated.
Please note that aside from copying l:path and l:tags we also have to carry around the b:rake_root variable in ruby source C files.
Other than that I've tested this and things work.
Yeah I don't like the sound of that. After that rbenv-ctags request is ready I'll play with it more myself.
All right, thanks for that.