nvim: Switch to QF for cscope
While we have gone back and forth between quickfix and fzf for cscope, it makes sense for cscope results to be loaded in quickfix window. Results loaded in fzf window will disappear once selected since that's how fuzzy finding is used but we do not want to have that behaviour with results of tools like cscope. Also use a plugin this time instead of having our own function. The plugin also provides the added advantage of jumping to a global definition instead of even opening that in a window. Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
parent
0a771b40b0
commit
5497c1b1b6
1 changed files with 23 additions and 75 deletions
|
@ -41,8 +41,6 @@ Plug 'rbong/vim-flog'
|
||||||
Plug 'whiteinge/diffconflicts'
|
Plug 'whiteinge/diffconflicts'
|
||||||
" For tmux yank
|
" For tmux yank
|
||||||
Plug 'vim-utils/vim-husk'
|
Plug 'vim-utils/vim-husk'
|
||||||
" Tags
|
|
||||||
Plug 'steffanc/cscopemaps.vim', { 'for': 'c' }
|
|
||||||
" GDB
|
" GDB
|
||||||
Plug 'sakhnik/nvim-gdb', { 'do': ':UpdateRemotePlugins' }
|
Plug 'sakhnik/nvim-gdb', { 'do': ':UpdateRemotePlugins' }
|
||||||
" Lisp
|
" Lisp
|
||||||
|
@ -84,6 +82,7 @@ Plug 'sbdchd/neoformat'
|
||||||
Plug 'neomake/neomake'
|
Plug 'neomake/neomake'
|
||||||
" Quickfix
|
" Quickfix
|
||||||
Plug 'sk1418/QFGrep'
|
Plug 'sk1418/QFGrep'
|
||||||
|
Plug 'ronakg/quickr-cscope.vim'
|
||||||
Plug 'stefandtw/quickfix-reflector.vim'
|
Plug 'stefandtw/quickfix-reflector.vim'
|
||||||
" Absolute essentials miscellaneous
|
" Absolute essentials miscellaneous
|
||||||
Plug 'tpope/vim-surround'
|
Plug 'tpope/vim-surround'
|
||||||
|
@ -405,25 +404,17 @@ augroup c_maps
|
||||||
au FileType c nmap <LocalLeader>cu :NeomakeSh cscope -bqR<CR>
|
au FileType c nmap <LocalLeader>cu :NeomakeSh cscope -bqR<CR>
|
||||||
au FileType c nmap <LocalLeader>cr :cs reset<CR>
|
au FileType c nmap <LocalLeader>cr :cs reset<CR>
|
||||||
|
|
||||||
au FileType c nmap <silent> <LocalLeader>s :call Cscope('0', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>s <Plug>(quickr_cscope_symbols)
|
||||||
au FileType c nmap <silent> <LocalLeader>g :call Cscope('1', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>g <Plug>(quickr_cscope_global)
|
||||||
au FileType c nmap <silent> <LocalLeader>d :call Cscope('2', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>h <Plug>(quickr_cscope_global_split)
|
||||||
au FileType c nmap <silent> <LocalLeader>c :call Cscope('3', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>v <Plug>(quickr_cscope_global_vert_split)
|
||||||
au FileType c nmap <silent> <LocalLeader>t :call Cscope('4', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>d <Plug>(quickr_cscope_functions)
|
||||||
au FileType c nmap <silent> <LocalLeader>e :call Cscope('6', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>c <Plug>(quickr_cscope_callers)
|
||||||
au FileType c nmap <silent> <LocalLeader>f :call Cscope('7', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>t <Plug>(quickr_cscope_text)
|
||||||
au FileType c nmap <silent> <LocalLeader>i :call Cscope('8', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>e <Plug>(quickr_cscope_egrep)
|
||||||
au FileType c nmap <silent> <LocalLeader>a :call Cscope('9', expand('<cword>'))<CR>
|
au FileType c nmap <silent> <LocalLeader>f <Plug>(quickr_cscope_files)
|
||||||
|
au FileType c nmap <silent> <LocalLeader>i <Plug>(quickr_cscope_includes)
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>s :call CscopeQuery('0')<CR>
|
au FileType c nmap <silent> <LocalLeader>a <Plug>(quickr_cscope_assignments)
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>g :call CscopeQuery('1')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>d :call CscopeQuery('2')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>c :call CscopeQuery('3')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>t :call CscopeQuery('4')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>e :call CscopeQuery('6')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>f :call CscopeQuery('7')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>i :call CscopeQuery('8')<CR>
|
|
||||||
au FileType c nmap <silent> <LocalLeader><LocalLeader>a :call CscopeQuery('9')<CR>
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup rust_maps
|
augroup rust_maps
|
||||||
|
@ -456,10 +447,14 @@ augroup toggle_search
|
||||||
autocmd InsertLeave * setlocal hlsearch
|
autocmd InsertLeave * setlocal hlsearch
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Close QF window if it is last window
|
augroup quickfix
|
||||||
augroup quickfix_close
|
|
||||||
au!
|
au!
|
||||||
|
" Close QF window if it is last window
|
||||||
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
|
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
|
||||||
|
" Existing bindings for QFGrep
|
||||||
|
" <Leader>g input pattern to do further filtering
|
||||||
|
" <Leader>v input pattern to do further inverted filtering
|
||||||
|
" <Leader>r restore the Quickfix/location list with original entries
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup terminal_job
|
augroup terminal_job
|
||||||
|
@ -662,64 +657,17 @@ let g:psc_ide_auto_imports = 1
|
||||||
|
|
||||||
" FZF
|
" FZF
|
||||||
let g:fzf_mru_no_sort = 1
|
let g:fzf_mru_no_sort = 1
|
||||||
|
let $FZF_DEFAULT_OPTS='--layout=reverse'
|
||||||
|
let g:fzf_layout = { 'window': 'call CreateCentredFloatingWindow()' }
|
||||||
|
|
||||||
|
" Quickr
|
||||||
|
let g:quickr_cscope_keymaps = 0
|
||||||
|
|
||||||
" ----------------------------- Functions ------------------------------------
|
" ----------------------------- Functions ------------------------------------
|
||||||
function! Cscope(option, query)
|
|
||||||
let color = '{ x = $1; $1 = ""; z = $3; $3 = ""; printf "\033[34m%s\033[0m:\033[31m%s\033[0m\011\033[37m%s\033[0m\n", x,z,$0; }'
|
|
||||||
let opts = {
|
|
||||||
\ 'source': "cscope -dL" . a:option . " " . a:query . " | awk '" . color . "'",
|
|
||||||
\ 'options': ['--ansi', '--prompt', '> ',
|
|
||||||
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
|
|
||||||
\ '--color', 'info:144,prompt:161,spinner:135,pointer:135,marker:118',
|
|
||||||
\ '--color', 'fg:252,bg:233,hl:67,fg+:252,bg+:235,hl+:81'],
|
|
||||||
\ 'window': 'call CreateCentredFloatingWindow()'
|
|
||||||
\ }
|
|
||||||
function! opts.sink(lines)
|
|
||||||
let data = split(a:lines)
|
|
||||||
let file = split(data[0], ":")
|
|
||||||
execute 'e ' . '+' . file[1] . ' ' . file[0]
|
|
||||||
endfunction
|
|
||||||
call fzf#run(opts)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! CscopeQuery(option)
|
|
||||||
call inputsave()
|
|
||||||
if a:option == '0'
|
|
||||||
let query = input('C Symbol: ')
|
|
||||||
elseif a:option == '1'
|
|
||||||
let query = input('Definition: ')
|
|
||||||
elseif a:option == '2'
|
|
||||||
let query = input('Functions called by: ')
|
|
||||||
elseif a:option == '3'
|
|
||||||
let query = input('Functions calling: ')
|
|
||||||
elseif a:option == '4'
|
|
||||||
let query = input('Text: ')
|
|
||||||
elseif a:option == '6'
|
|
||||||
let query = input('Egrep: ')
|
|
||||||
elseif a:option == '7'
|
|
||||||
let query = input('File: ')
|
|
||||||
elseif a:option == '8'
|
|
||||||
let query = input('Files #including: ')
|
|
||||||
elseif a:option == '9'
|
|
||||||
let query = input('Assignments to: ')
|
|
||||||
else
|
|
||||||
echo "Invalid option!"
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
call inputrestore()
|
|
||||||
if query != ""
|
|
||||||
call Cscope(a:option, query)
|
|
||||||
else
|
|
||||||
echom "Cancelled Search!"
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
function! NvimGdbNoTKeymaps()
|
function! NvimGdbNoTKeymaps()
|
||||||
tnoremap <silent> <buffer> <Esc> <C-\><C-n>
|
tnoremap <silent> <buffer> <Esc> <C-\><C-n>
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
let $FZF_DEFAULT_OPTS='--layout=reverse'
|
|
||||||
let g:fzf_layout = { 'window': 'call CreateCentredFloatingWindow()' }
|
|
||||||
" Stolen from https://github.com/camspiers/dotfiles/blob/master/files/.config/nvim/init.vim
|
" Stolen from https://github.com/camspiers/dotfiles/blob/master/files/.config/nvim/init.vim
|
||||||
function! CreateCentredFloatingWindow()
|
function! CreateCentredFloatingWindow()
|
||||||
let width = float2nr(&columns * 0.8)
|
let width = float2nr(&columns * 0.8)
|
||||||
|
|
Loading…
Reference in a new issue