Skip to content

Commit

Permalink
vimrc: support cscope quickfix
Browse files Browse the repository at this point in the history
Signed-off-by: lilei <[email protected]>
  • Loading branch information
lilei committed Dec 1, 2019
1 parent 07e7a52 commit 706da01
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 13 deletions.
42 changes: 31 additions & 11 deletions vim/plugin/autoload_cscope.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ endif
function s:windowdir()
if winbufnr(0) == -1
let unislash = getcwd()
else
else
let unislash = fnamemodify(bufname(winbufnr(0)), ':p:h')
endif
return tr(unislash, '\', '/')
Expand Down Expand Up @@ -60,6 +60,26 @@ function s:Find_in_parent(fln,flsrt,flstp)
endwhile
return "Nothing"
endfunc

if !exists("g:is_autoloadcs_quickfix_open")
let s:is_autoloadcs_quickfix_open = 0
endif

function s:AutoloadcsQuickfixOpen()
cwindow
let s:is_autoloadcs_quickfix_open = 1
endfunction

function AutoloadcsQuickfixToggle()
if s:is_autoloadcs_quickfix_open == 1
cclose
let s:is_autoloadcs_quickfix_open = 0
else
cwindow
let s:is_autoloadcs_quickfix_open = 1
endif
endfunction

"
"==
" Cycle_macros_menus
Expand All @@ -78,14 +98,14 @@ function s:Cycle_macros_menus()
let s:menus_loaded = 1
set csto=0
set cst
silent! map <unique> <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>f :cs find f <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>i :cs find i <C-R>=expand("<cword>")<CR><CR>
silent! map <unique> <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>f :cs find f <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
silent! map <unique> <C-\>i :cs find i <C-R>=expand("<cword>")<CR><CR><CR>:call <SID>AutoloadcsQuickfixOpen()<CR>
if has("menu")
nmenu &Cscope.Find.Symbol<Tab><c-\\>s
\ :cs find s <C-R>=expand("<cword>")<CR><CR>
Expand All @@ -103,8 +123,8 @@ function s:Cycle_macros_menus()
\ :cs find f <C-R>=expand("<cword>")<CR><CR>
nmenu &Cscope.Find.Including<Tab><c-\\>i
\ :cs find i <C-R>=expand("<cword>")<CR><CR>
" nmenu &Cscope.Add :cs add
" nmenu &Cscope.Remove :cs kill
" nmenu &Cscope.Add :cs add
" nmenu &Cscope.Remove :cs kill
nmenu &Cscope.Reset :cs reset<cr>
nmenu &Cscope.Show :cs show<cr>
" Need to figure out how to do the add/remove. May end up writing
Expand Down
8 changes: 6 additions & 2 deletions vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let g:tagbar_left=1
let g:tagbar_width=30
let g:tagbar_sort = 0
let g:tagbar_compact = 1
nmap <F7> :TagbarToggle<cr>
nmap <F5> :TagbarToggle<cr>
" nerdtree
let NERDChristmasTree=0
Expand All @@ -61,7 +61,7 @@ let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos = "right"
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nmap <F6> :NERDTreeToggle<cr>
nmap <F7> :NERDTreeToggle<cr>
" airline
let g:airline#extensions#tabline#enabled = 1
Expand Down Expand Up @@ -112,3 +112,7 @@ if has("cscope") && filereadable("/usr/bin/cscope")
set cscopequickfix=s-,c-,d-,i-,t-,e-
endif

nmap <F3> :cp<cr>
nmap <F4> :cn<cr>
nmap <F6> :call AutoloadcsQuickfixToggle()<cr>
nmap <F8> :silent !ctags -R --fields=+lS && cscope -Rbqk<cr>

0 comments on commit 706da01

Please sign in to comment.