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:
parent
7fa349eed9
commit
ae3db8b6ef
@ -10,22 +10,20 @@ if has("cscope")
|
|||||||
let g:loaded_cscope = 1.0
|
let g:loaded_cscope = 1.0
|
||||||
|
|
||||||
function! GoToDefinition()
|
function! GoToDefinition()
|
||||||
try
|
|
||||||
execute "cscope find g " . expand("<cword>")
|
|
||||||
catch /:E259:/
|
|
||||||
try
|
try
|
||||||
execute "tag " . expand("<cword>")
|
execute "tag " . expand("<cword>")
|
||||||
catch /:E257:/
|
catch /:E257:/
|
||||||
execute "normal! gd"
|
execute "normal! gd"
|
||||||
execute "nohlsearch"
|
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
15
.vimrc
@ -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'
|
||||||
|
Loading…
Reference in New Issue
Block a user