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

@ -10,22 +10,20 @@ if has("cscope")
let g:loaded_cscope = 1.0
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>
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" use ctags before cscope
set csto=0
set csto=1
" add any cscope database in current directory
if filereadable("cscope.out")
cscope add cscope.out

15
.vimrc
View File

@ -219,21 +219,6 @@ set mat=5
" go to declaration with F5
" map <silent> <F5> gd:nohlsearch<CR>
" 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
let Tlist_Ctags_Cmd = '/usr/bin/ctags'