diff options
author | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-11-13 21:30:29 -0500 |
---|---|---|
committer | Jan Edmund Lazo <janedmundlazo@hotmail.com> | 2018-11-13 21:32:00 -0500 |
commit | 9e59fdf5f6522d91f1fb282465d3c6c0b8093daf (patch) | |
tree | 75e562ce509646944c98f90216e9274431d8e3f9 | |
parent | 091ae1e63fb36b28ec8a0cadfcfbb4e90859af1b (diff) | |
download | rneovim-9e59fdf5f6522d91f1fb282465d3c6c0b8093daf.tar.gz rneovim-9e59fdf5f6522d91f1fb282465d3c6c0b8093daf.tar.bz2 rneovim-9e59fdf5f6522d91f1fb282465d3c6c0b8093daf.zip |
vim-patch:8.1.0311: filtering entries in a quickfix list is not easy
Problem: Filtering entries in a quickfix list is not easy.
Solution: Add the cfilter plugin. (Yegappan Lakshmanan)
https://github.com/vim/vim/commit/8c5e0093c9badced73e382915fb024a5c3ea463b
-rw-r--r-- | runtime/pack/dist/opt/cfilter/plugin/cfilter.vim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim b/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim new file mode 100644 index 0000000000..7a6464fc98 --- /dev/null +++ b/runtime/pack/dist/opt/cfilter/plugin/cfilter.vim @@ -0,0 +1,43 @@ +" cfilter.vim: Plugin to filter entries from a quickfix/location list +" Last Change: May 12, 2018 +" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) +" Version: 1.0 +" +" Commands to filter the quickfix list: +" :Cfilter[!] {pat} +" Create a new quickfix list from entries matching {pat} in the current +" quickfix list. Both the file name and the text of the entries are +" matched against {pat}. If ! is supplied, then entries not matching +" {pat} are used. +" :Lfilter[!] {pat} +" Same as :Cfilter but operates on the current location list. +" +if exists("loaded_cfilter") + finish +endif +let loaded_cfilter = 1 + +func s:Qf_filter(qf, pat, bang) + if a:qf + let Xgetlist = function('getqflist') + let Xsetlist = function('setqflist') + let cmd = ':Cfilter' . a:bang + else + let Xgetlist = function('getloclist', [0]) + let Xsetlist = function('setloclist', [0]) + let cmd = ':Lfilter' . a:bang + endif + + if a:bang == '!' + let cond = 'v:val.text !~# a:pat && bufname(v:val.bufnr) !~# a:pat' + else + let cond = 'v:val.text =~# a:pat || bufname(v:val.bufnr) =~# a:pat' + endif + + let items = filter(Xgetlist(), cond) + let title = cmd . ' ' . a:pat + call Xsetlist([], ' ', {'title' : title, 'items' : items}) +endfunc + +com! -nargs=+ -bang Cfilter call s:Qf_filter(1, <q-args>, <q-bang>) +com! -nargs=+ -bang Lfilter call s:Qf_filter(0, <q-args>, <q-bang>) |