diff --git a/nvim/init.vim b/nvim/init.vim index 310eeff..489e29d 100644 --- a/nvim/init.vim +++ b/nvim/init.vim @@ -9,7 +9,6 @@ Plug 'ervandew/supertab' " of words. Plug 'easymotion/vim-easymotion' " Fuzzy search -Plug 'junegunn/fzf.vim' Plug 'liuchengxu/vim-clap' " Remove extraneous whitespace when edit mode is exited Plug 'thirtythreeforty/lessspace.vim' @@ -37,6 +36,8 @@ Plug 'rbong/vim-flog' " For tmux yank Plug 'vim-utils/vim-husk' " Tags +Plug 'sk1418/QFGrep' +Plug 'steffanc/cscopemaps.vim' Plug 'ludovicchabant/vim-gutentags' Plug 'deoplete-plugins/deoplete-tag' " GDB @@ -244,6 +245,7 @@ nnoremap ghr :GitGutterPreviewHunk nnoremap gqf :GitGutterQuickFix nnoremap ggf :GitGutterFold " For Cscope +nnoremap cu :NeomakeSh cscope -bqR nnoremap cr :cs reset " For Neomake nnoremap nm :Neomake @@ -455,46 +457,39 @@ autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk " Automatically resize the window autocmd VimResized * wincmd = -" CScope & fuzzy integration -" Taken from https://gist.github.com/amitab/cd051f1ea23c588109c6cfcb7d1d5776 -" However, the above gist has completely wrong mappings -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', 'bw'], - \ '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) +" 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=" endfunction function! CscopeQuery(option) call inputsave() - if a:option == '9' - let query = input('Assignments to: ') - elseif a:option == '3' - let query = input('Functions calling: ') - elseif a:option == '2' - let query = input('Functions called by: ') - elseif a:option == '6' - let query = input('Egrep: ') - elseif a:option == '7' - let query = input('File: ') - elseif a:option == '1' - let query = input('Definition: ') - elseif a:option == '8' - let query = input('Files #including: ') - elseif a:option == '0' + if a:option == "s" let query = input('C Symbol: ') - elseif a:option == '4' + 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 @@ -507,25 +502,25 @@ function! CscopeQuery(option) endif endfunction -nnoremap ss :call Cscope('0', expand('')) -nnoremap sg :call Cscope('1', expand('')) -nnoremap sd :call Cscope('2', expand('')) -nnoremap sc :call Cscope('3', expand('')) -nnoremap st :call Cscope('4', expand('')) -nnoremap se :call Cscope('6', expand('')) -nnoremap sf :call Cscope('7', expand('')) -nnoremap si :call Cscope('8', expand('')) -nnoremap sa :call Cscope('9', expand('')) +nnoremap ss :call Cscope("s", expand('')) +nnoremap sg :call Cscope("g", expand('')) +nnoremap sd :call Cscope("d", expand('')) +nnoremap sc :call Cscope("c", expand('')) +nnoremap st :call Cscope("t", expand('')) +nnoremap se :call Cscope("e", expand('')) +nnoremap sf :call Cscope("f", expand('')) +nnoremap si :call Cscope("i", expand('')) +nnoremap sa :call Cscope("a", expand('')) -nnoremap ss :call CscopeQuery('0') -nnoremap sg :call CscopeQuery('1') -nnoremap sd :call CscopeQuery('2') -nnoremap sc :call CscopeQuery('3') -nnoremap st :call CscopeQuery('4') -nnoremap se :call CscopeQuery('6') -nnoremap sf :call CscopeQuery('7') -nnoremap si :call CscopeQuery('8') -nnoremap sa :call CscopeQuery('9') +nnoremap ss :call CscopeQuery("s") +nnoremap sg :call CscopeQuery("g") +nnoremap sd :call CscopeQuery("d") +nnoremap sc :call CscopeQuery("c") +nnoremap st :call CscopeQuery("t") +nnoremap se :call CscopeQuery("e") +nnoremap sf :call CscopeQuery("f") +nnoremap si :call CscopeQuery("i") +nnoremap sa :call CscopeQuery("a") function! NvimGdbNoTKeymaps() tnoremap