I am using ctags
to generate tags and put set tags+=~/.vim/tags/cpp
(just followed this wiki page) in .vimrc
.In my vimrc
file there is also the setting like below so I can auto sync the nerdtree viewer for the current file(see this):
" returns true iff is NERDTree open/active
function! rc:isNTOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
" returns true iff focused window is NERDTree window
function! rc:isNTFocused()
return -1 != match(expand('%'), 'NERD_Tree')
endfunction
" calls NERDTreeFind iff NERDTree is active, current window contains a modifiable file, and we're not in vimdiff
function! rc:syncTree()
if &modifiable && rc:isNTOpen() && !rc:isNTFocused() && strlen(expand('%')) > 0 && !&diff
NERDTreeFind
wincmd p
endif
endfunction
autocmd BufEnter * call rc:syncTree()
The problem lies in that ~/.vim
is actually a symbolic link to another folder(So I can manage all my dotfiles using git or other VCSs easily). When I use Ctrl+] to look for a definition(whose tag information is in ~/.vim/tags/cpp), there would be always the error:
detected while processing function rc:syncTree..<SNR>15_findAndRevealPath..102:
line 2:
E605: Exception not caught: NERDTree.InvalidArgumentsError: /home/hongxuchen/.vim/tags/cpp_src/stl_iterator.h should be under /home/hongxuchen/data_backup/dotfiles/_vim/tags/cpp_src
Does it mean that I have to use set tags+=/real/path/to/cpp
instead in vimrc
?
In Vim, the resolve()
function can process symbolic links. Try replacing in plugin/NERD_tree.vim
function! s:findAndRevealPath()
try
let p = s:Path.New(expand("%:p"))
with
function! s:findAndRevealPath()
try
let p = s:Path.New(resolve(expand("%:p")))
If that works, I'd send a patch to the plugin's author.