Use ctags before cscope

cscope does not well support c++ (e.g. enum declared in extern "C"
https://sourceforge.net/p/cscope/bugs/249/, anonym struct ...)
So use ctags first (set csto=1)
also remove so duplicate code and simplify it as cscopetag option is
enabled
This commit is contained in:
Mathieu Maret 2016-10-20 11:07:07 +02:00
parent 7fa349eed9
commit ae3db8b6ef
2 changed files with 8 additions and 25 deletions

View File

@ -5,27 +5,25 @@
" if compiled with --enable-cscope " if compiled with --enable-cscope
if has("cscope") if has("cscope")
if exists("g:loaded_cscope") || &cp if exists("g:loaded_cscope") || &cp
finish finish
endif endif
let g:loaded_cscope = 1.0 let g:loaded_cscope = 1.0
function! GoToDefinition() function! GoToDefinition()
try try
execute "cscope find g " . expand("<cword>") execute "tag " . expand("<cword>")
catch /:E259:/ catch /:E257:/
try execute "normal! gd"
execute "tag " . expand("<cword>") execute "nohlsearch"
catch /:E257:/
execute "normal! gd"
execute "nohlsearch"
endtry
endtry endtry
endfunction endfunction
nmap <silent> , :call GoToDefinition()<CR>
nmap <silent> ; <C-t>
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag set cscopetag
" use ctags before cscope " use ctags before cscope
set csto=0 set csto=1
" add any cscope database in current directory " add any cscope database in current directory
if filereadable("cscope.out") if filereadable("cscope.out")
cscope add cscope.out cscope add cscope.out

15
.vimrc
View File

@ -219,21 +219,6 @@ set mat=5
" go to declaration with F5 " go to declaration with F5
" map <silent> <F5> gd:nohlsearch<CR> " map <silent> <F5> gd:nohlsearch<CR>
" imap <F5> <ESC><F5>i " imap <F5> <ESC><F5>i
" try to go to definition or declaration with , and go back with ;
function GoToDefinition()
try
execute "cscope find g " . expand("<cword>")
catch /:E259:/
try
execute "tag " . expand("<cword>")
catch /:E257:/
execute "normal! gd"
execute "nohlsearch"
endtry
endtry
endfunction
nmap <silent> , :call GoToDefinition()<CR>
nmap <silent> ; <C-t>
" plugin taglist " plugin taglist
let Tlist_Ctags_Cmd = '/usr/bin/ctags' let Tlist_Ctags_Cmd = '/usr/bin/ctags'