-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cscope_maps: add gtags support for cscope_maps #360
base: master
Are you sure you want to change the base?
Conversation
@ludovicchabant merge? |
Isn't there already " we want gscope, ie gutentags_plus, to manage cscope for us
let g:gutentags_auto_add_gtags_cscope = 0
let g:gutentags_auto_add_cscope = 0
let g:gutentags_auto_add_pycscope = 0
" ...
let g:gutentags_modules = []
if executable('ctags') | let g:gutentags_modules += ['ctags'] | endif
if executable('gtags') | let g:gutentags_modules += ['gtags_cscope']
elseif executable('cscope') | let g:gutentags_modules += ['cscope'] | endif
if empty(g:gutentags_modules) | let g:gutentags_dont_load = 1 | endif
" ...
" manage our own maps
let g:gutentags_plus_nomap = 1 and then for my maps: "
" like the cscope interface, but uses gutentags-generated db
"
if !exists("g:gscope_done") | let g:gscope_done = 1 | else | finish | endif
if !has("cscope") || !has("channel") | finish | endif
nnoremap csa <plug>GscopeFindAssign
nnoremap csc <plug>GscopeFindCallingFunc
nnoremap csd <plug>GscopeFindCalledFunc
nnoremap cse <plug>GscopeFindEgrep
nnoremap csf <plug>GscopeFindFile
nnoremap csg <plug>GscopeFindDefinition
nnoremap csi <plug>GscopeFindInclude
nnoremap css <plug>GscopeFindSymbol
nnoremap cst <plug>GscopeFindText
nnoremap csz <plug>GscopeFindCtag
" cs[acdefgistz]/:
"
function! s:GsgAbbrev(cschar) abort
return (((getcmdtype() == ":" && (getcmdline() =~ ('^cs' . a:cschar)))
\ ? 'GscopeFind ' : 'cs') . a:cschar)
endfunction
let s:chars = "acdefgistz"
"if !has('patch-8.2.2658') | finish | endif " :for x in String
"for s:abb in s:chars
for s:abb in split(s:chars, '\zs')
exec 'cnoreabbrev <expr> cs' . s:abb . ' <SID>GsgAbbrev("' . s:abb . '")'
endfor
" cs[rhuk]/:
"
function! s:GsAbbrev(cschar, cmd) abort
return ((getcmdtype() == ":" && (getcmdline() =~ ('^cs' . a:cschar)))
\ ? a:cmd : ('cs' . a:cschar))
endfunction
for [cschar, cmd] in [
\ ['r', 'call gutentags#rescan()'],
\ ['h', 'call Gscope_menu()'],
\ ['u', 'GutentagsUpdate'],
\ ['k', 'GscopeKill'],
\ ]
let s:abb = 'cs' . cschar
let s:abbfunc = 'GsAbbrev("' . cschar . '", "' . cmd . '")'
let s:gsfunc = expand('<SID>') . s:abbfunc
exec 'nnoremap ' . s:abb . ' :' . cmd . '<return>'
exec 'cnoreabbrev <expr> ' . s:abb . ' ' . s:gsfunc
endfor
" menu for csh
"
function! Gscope_menu ()
echo
\"gscope find:\n"
\" (a)ssigns find places this is assigned to\n"
\" (c)allers find functions calling this function\n"
\" (d)epends find functions this one depends on\n"
\" (e)grep find this egrep pattern\n"
\" (f)ile find this file\n"
\" (g)lobal find this definition\n"
\" (i)nclude find files #including this file\n"
\" (s)ymbol find this C symbol\n"
\" (t)o find assignments to\n"
\" (z)tags find matching ctags\n"
\"? "
let gotchar = getchar()
execute "normal cs" . nr2char(gotchar)
endf
" gutentags_plus takes care of 'cscope add' and db management. restart every
" time we change working directory. this lets us start with an empty buffer
"
if !has('patch-8.0.1459') | finish | endif
augroup DirChangedGroup
au!
autocmd DirChanged global
\ if exists('*gutentags#rescan') | call gutentags#rescan() | endif
augroup END works for me without any patch. I am not sure if I'd need the maps if I didn't set |
cscope_maps is for the purpose of neovim, where things don't quite work well |
The cscope integration has been removed from nvim. I see that the patch related to cscope_map has been merged into the main branch, but it only supports cscope and not gtags, which doesn't seem very reasonable, so I made this PR to support gtags. |
Can gtags be made to place its files in gutentags_cache_dir, not the project root? |
it looks like the patch uses |
My bad, dodgy config. I had g:gutentags_cscope_executable_maps = 'gtags-cscope' rather than 'gtags' |
cscope has not been updated for a long time, so supporting gtags is a must-do