]> git.zndr.dk Git - dotfiles.git/commitdiff
Move cscope.out into .git
authorJannik ZANDER <jannikz@gmail.com>
Sun, 15 May 2016 08:16:55 +0000 (10:16 +0200)
committerJannik ZANDER <jannikz@gmail.com>
Sun, 15 May 2016 08:16:55 +0000 (10:16 +0200)
.git_template/hooks/cscope
.git_template/hooks/gtags
.vimrc

index 494e20cd2ea93a32e0c706584296da575bc5383d..42f95222e7b8645daf7d6168a2bbc3e281b4fdc3 100644 (file)
@@ -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"
index 9ceba973e138b7bd256042ef1db9161372ede454..d30547d3b7c4c8dca0f86ea6775d47d9731320a2 100644 (file)
@@ -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 46a3a83f459090417ff5c7a268380e081c303245..b45fc4b3ac55c4386a258d459adc8a59601e94cc 100644 (file)
--- 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 <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"
 "
 "
 " Section: Mappings {{{1