summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugues Hiegel <hugues@hiegel.fr>2011-10-19 15:24:23 +0200
committerHugues Hiegel <hugues@hiegel.fr>2011-10-19 15:24:23 +0200
commit61aabbe40d782af5ee9af8d0b2295950aa1afeaa (patch)
tree3336a40981e1c565812db89e50429d5259d157cc
parent0b51b5d5ca8ba5720ba6d89c7c7cccbf9403f987 (diff)
[Vim] cscope power
-rw-r--r--vimrc30
1 files changed, 22 insertions, 8 deletions
diff --git a/vimrc b/vimrc
index 8d2cfae..3416a55 100644
--- a/vimrc
+++ b/vimrc
@@ -81,6 +81,21 @@ autocmd BufReadPost *
\ exe "normal zz" |
\ endif
+function! CscopeSearch(csearch)
+
+ let @/=a:csearch
+ set hls
+
+ let l:prompt = "Rechercher '".a:csearch."' avec cscope [cdefgist] : "
+
+ echo l:prompt
+ let l:ctype=nr2char(getchar())
+ redraw
+ echo l:prompt.l:ctype." "
+
+ return 'set hls | cscope find '.l:ctype.' '.a:csearch
+endfunction
+
" Load local cscope db if exists
if filereadable( expand("$PWD/tags") )
set tags=tags
@@ -89,18 +104,17 @@ elseif filereadable( expand("$PWD/ctags.out") )
elseif has("cscope")
if filereadable( expand("$PWD/cscope.out") )
set cst
+ cscope add $PWD/cscope.out
+
" cscope macros
- map <C-]> :cs find g <C-R>=expand("<cword>")<CR><CR> " find global definition
- map <C-[> :cs find c <C-R>=expand("<cword>")<CR><CR> " find callers of function under cursor
- map <C-\> :cs find t <C-R>=expand("<cword>")<CR><CR> " find assignments to variable under cursor
- map <C-s> :cs find s <C-R>=expand("<cword>")<CR><CR> " find string under cursor
- map <C-f> :cs find f <C-R>=expand("<cword>")<CR><CR> " find file under cursor
- map <C-i> :cs find i <C-R>=expand("<cword>")<CR><CR> " find files including file under cursor
- map <C-i> :cs find I %<CR> " find files including current file
- cs add $PWD/cscope.out
+ nmap <ESC>c :execute CscopeSearch(expand("<cword>"))<CR>
+ nmap <ESC>f :execute CscopeSearch(expand("<cfile>"))<CR>
+ nmap <ESC>% :execute CscopeSearch(expand("%:t"))<CR>
+ nmap <ESC>r :execute CscopeSearch(input("Rechercher : "))<CR>
endif
endif
+
" F*cking trailing whitespaces
autocmd BufRead * highlight ExtraWhitespace ctermbg=red guibg=red
autocmd BufRead * match ExtraWhitespace /\s\+$\| \+\ze\t\| /