nvim: init.vim: Revert back to using cscope with fzf

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2019-12-12 19:41:53 +05:30
parent 77f5543f45
commit c80bb00a55

View file

@ -384,25 +384,25 @@ augroup c_maps
au FileType c nmap <Leader>cu :NeomakeSh cscope -bqR<CR>
au FileType c nmap <Leader>cr :cs reset<CR>
au FileType c nmap <silent> <Leader>ss :call Cscope("s", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sg :call Cscope("g", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sd :call Cscope("d", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sc :call Cscope("c", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>st :call Cscope("t", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>se :call Cscope("e", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sf :call Cscope("f", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>si :call Cscope("i", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sa :call Cscope("a", expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>ss :call Cscope('0', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sg :call Cscope('1', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sd :call Cscope('2', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sc :call Cscope('3', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>st :call Cscope('4', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>se :call Cscope('6', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sf :call Cscope('7', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>si :call Cscope('8', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader>sa :call Cscope('9', expand('<cword>'))<CR>
au FileType c nmap <silent> <Leader><Leader>ss :call CscopeQuery("s")<CR>
au FileType c nmap <silent> <Leader><Leader>sg :call CscopeQuery("g")<CR>
au FileType c nmap <silent> <Leader><Leader>sd :call CscopeQuery("d")<CR>
au FileType c nmap <silent> <Leader><Leader>sc :call CscopeQuery("c")<CR>
au FileType c nmap <silent> <Leader><Leader>st :call CscopeQuery("t")<CR>
au FileType c nmap <silent> <Leader><Leader>se :call CscopeQuery("e")<CR>
au FileType c nmap <silent> <Leader><Leader>sf :call CscopeQuery("f")<CR>
au FileType c nmap <silent> <Leader><Leader>si :call CscopeQuery("i")<CR>
au FileType c nmap <silent> <Leader><Leader>sa :call CscopeQuery("a")<CR>
au FileType c nmap <silent> <Leader><Leader>ss :call CscopeQuery('0')<CR>
au FileType c nmap <silent> <Leader><Leader>sg :call CscopeQuery('1')<CR>
au FileType c nmap <silent> <Leader><Leader>sd :call CscopeQuery('2')<CR>
au FileType c nmap <silent> <Leader><Leader>sc :call CscopeQuery('3')<CR>
au FileType c nmap <silent> <Leader><Leader>st :call CscopeQuery('4')<CR>
au FileType c nmap <silent> <Leader><Leader>se :call CscopeQuery('6')<CR>
au FileType c nmap <silent> <Leader><Leader>sf :call CscopeQuery('7')<CR>
au FileType c nmap <silent> <Leader><Leader>si :call CscopeQuery('8')<CR>
au FileType c nmap <silent> <Leader><Leader>sa :call CscopeQuery('9')<CR>
augroup END
augroup rust_maps
@ -650,50 +650,56 @@ let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 10
" ----------------------------- Functions ------------------------------------
" For CScope and Quickfix
" https://medium.com/@lakshmankumar12/quickfix-and-location-list-in-vim-ca0292ac894d
" https://medium.com/@lakshmankumar12/vim-and-cscope-5f4558c8a8b8
function! Cscope(oper, currword)
execute "normal mZ"
execute "set csqf=" . a:oper . "-"
execute "lcs find " a:oper . " " . a:currword
execute "lopen"
execute "wincmd p"
execute "normal `Z"
execute "set csqf="
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'],
\ 'down': '40%'
\ }
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 == "s"
let query = input('C Symbol: ')
elseif a:option == "g"
let query = input('Definition: ')
elseif a:option == "d"
let query = input('Functions called by: ')
elseif a:option == "c"
let query = input('Functions calling: ')
elseif a:option == "t"
let query = input('Text: ')
elseif a:option == "e"
let query = input('Egrep: ')
elseif a:option == "f"
let query = input('File: ')
elseif a:option == "i"
let query = input('Files #including: ')
elseif a:option == "a"
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
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()