aboutsummaryrefslogtreecommitdiffhomepage
path: root/.config/nvim/my/after/ftplugin/qf.vim
blob: 364759c71d360e65cc88fed4e8b8ff7f38732ba0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
scriptencoding utf-8


if exists('b:did_ftplugin_qf_after')
    finish
endif



nnoremap <buffer> p <Return>zz<C-w>p
nnoremap <silent> <buffer> dd :call <SID>del_entry()<Return>
xnoremap <silent> <buffer> d :call <SID>del_entry()<Return>
nnoremap <silent> <buffer> u :<C-u>call <SID>undo_entry()<Return>


if exists('*s:undo_entry')
    finish
endif


function! s:undo_entry()
    let history = get(w:, 'qf_history', [])
    if !empty(history)
        call setqflist(remove(history, -1), 'r')
    endif
endfunction

function! s:del_entry() range
    let qf = getqflist()
    let history = get(w:, 'qf_history', [])
    call add(history, copy(qf))
    let w:qf_history = history
    unlet! qf[a:firstline - 1 : a:lastline - 1]
    call setqflist(qf, 'r')
    execute a:firstline
endfunction



let b:did_ftplugin_qf_after = 1