dotfiles/nvim/.config/nvim/after/ftplugin/qf.vim
Sanchayan Maity bc6a097739 nvim: Miscellaneous clean up
1. Clean up the remnants of Neomake and grepper config left behind
2. Drop quickui and use a custom preview function for items in QF
window stolen from floaterm plugin's author
3. Cleanups for vim default configuration settings like wildignore

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-05-22 15:33:11 +05:30

43 lines
1.1 KiB
VimL

" Quit vim if the last window is qf
autocmd BufEnter <buffer> if winnr('$') < 2| q | endif
setlocal scrolloff=0
setlocal nowrap
setlocal norelativenumber number
setlocal linebreak
setlocal nolist
setlocal nocursorline
setlocal nobuflisted
setlocal nospell
nnoremap <buffer> [- :colder<CR>
nnoremap <buffer> ]+ :cnewer<CR>
nnoremap <buffer> <Leader>g :Cfilter<SPACE>
nnoremap <buffer> o <CR><C-w>p
nnoremap <silent> <buffer> p :call <SID>preview_file()<CR>
let b:qf_isLoc = ! empty(getloclist(0))
if b:qf_isLoc == 1
nnoremap <buffer> q <CR>:lclose<CR>
else
nnoremap <buffer> q <CR>:cclose<CR>
endif
" Taken from https://github.com/voldikss/dotfiles
function! s:preview_file()
let winwidth = &columns
let cur_list = b:qf_isLoc == 1 ? getloclist('.') : getqflist()
let cur_line = getline(line('.'))
let cur_file = fnameescape(substitute(cur_line, '|.*$', '', ''))
if cur_line =~# '|\d\+'
let cur_pos = substitute(cur_line, '^\(.\{-}|\)\(\d\+\)\(.*\)', '\2', '')
execute 'vertical pedit! +'.cur_pos.' '.cur_file
else
execute 'vertical pedit! '.cur_file
endif
wincmd P
execute 'vert resize '.(winwidth / 2)
wincmd p
endfunction