From: Jannik ZANDER Date: Sun, 15 May 2016 08:16:55 +0000 (+0200) Subject: Move cscope.out into .git X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=ad2b14434cea8f6e5f483691de06f91fd1fd8fcd;p=dotfiles.git Move cscope.out into .git --- diff --git a/.git_template/hooks/cscope b/.git_template/hooks/cscope index 494e20c..42f9522 100644 --- a/.git_template/hooks/cscope +++ b/.git_template/hooks/cscope @@ -7,4 +7,4 @@ git ls-files |\ grep -E '\.(c(pp)?|h)$' |\ awk '{print "\""$0"\""}' |\ cscope -R -b -i - -f "$dir/$$.cscope.out" -mv "$dir/$$.cscope.out" "$dir/../cscope.out" +mv "$dir/$$.cscope.out" "$dir/cscope.out" diff --git a/.git_template/hooks/gtags b/.git_template/hooks/gtags index 9ceba97..d30547d 100644 --- a/.git_template/hooks/gtags +++ b/.git_template/hooks/gtags @@ -2,8 +2,8 @@ set -e PATH="/usr/local/bin:$PATH" dir="`git rev-parse --git-dir`" -trap 'rm -rf "$dir/$$.gtags" EXIT INT TERM +trap 'rm -rf "$dir/$$.gtags/"' EXIT INT TERM mkdir "$dir/$$.gtags" git ls-files | \ gtags --file=- --skip-unreadable "$dir/$$.gtags" -mv "$dir/$$.gtags/*" "$dir/.." +mv "$dir/$$.gtags"/* "$dir/.." diff --git a/.vimrc b/.vimrc index 46a3a83..b45fc4b 100644 --- a/.vimrc +++ b/.vimrc @@ -95,7 +95,47 @@ let g:fzf_launcher = "In_a_new_term_function %s" " }}}2 " Section: Commands {{{1 -" ----------------------- +"----------------------- +" +if has("cscope") + 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 + + nnoremap fs :cscope find s =expand(""):botright cwindow + nnoremap fg :cscope find g =expand(""):botright cwindow + nnoremap fc :cscope find c =expand(""):botright cwindow + nnoremap ft :cscope find t =expand(""):botright cwindow + nnoremap fe :cscope find e =expand(""):botright cwindow + nnoremap ff :cscope find f =expand(""):botright cwindow + nnoremap fd :cscope find d =expand(""):botright cwindow + nnoremap fi :cscope find i ^=expand("")$:botright cwindow + "TODO: figure out how to get cstag output in quickfix or a popup menu. + map :cstag =expand("") + + 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" " " " Section: Mappings {{{1