-
-
Save kotp/57206f46b66624904b1a75636ab8034c to your computer and use it in GitHub Desktop.
Vim configuration for interacting with cscope databases (focus on Ruby).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if has("cscope") | |
"TODO: turn this all into a plugin. | |
set nocscopetag | |
set cscopequickfix=s-,c-,d-,i-,t-,e- | |
set nocscopeverbose | |
if filereadable(".git/cscope.out") | |
cscope add .git/cscope.out | |
endif | |
set cscopeverbose | |
"TODO: figure out which of these are useless in Ruby and disable them. | |
nnoremap <Leader>fs :cscope find s <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>fg :cscope find g <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>fc :cscope find c <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>ft :cscope find t <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>fe :cscope find e <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>ff :cscope find f <C-R>=expand("<cfile>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>fd :cscope find d <C-R>=expand("<cword>")<CR><CR>:botright cwindow<CR> | |
nnoremap <Leader>fi :cscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>:botright cwindow<CR> | |
"TODO: figure out how to get cstag output in quickfix or a popup menu. | |
map <C-_> :cstag <C-R>=expand("<cword>")<CR><CR> | |
function! CscopeRebuild() | |
cscope kill .git/cscope.out | |
silent execute "!./.git/hooks/cscope" | |
if v:shell_error | |
redraw! | |
echohl ErrorMsg | echo "Unable to run cscope command." | echohl None | |
else | |
if filereadable(".git/cscope.out") | |
redraw! | |
cscope add .git/cscope.out | |
else | |
redraw! | |
echohl ErrorMsg | echo "Unable to read cscope database." | echohl None | |
endif | |
endif | |
endfunction | |
command! Cscope call CscopeRebuild() | |
endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# NOTE: this is really .git/hooks/cscope but Gist doesn't like paths. | |
set -e | |
trap "rm -f .git/cscope.out.$$" EXIT | |
find . \( -name "*.rb" -o -name "*.erb" -o -name "*.haml" \) -print \ | |
-o -path "./.git" -prune \ | |
-o -path "./tmp" -prune \ | |
-o -path "./coverage" -prune \ | |
-o -path "./vendor" -prune | cscope -R -b -i - -f .git/cscope.out.$$ | |
mv .git/cscope.out.$$ .git/cscope.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment