mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #12888 from nguymin4/update-cfilter
vim-patch: Update cfilter to 1.1
This commit is contained in:
commit
78539dda95
@ -501,6 +501,29 @@ EXECUTE A COMMAND IN ALL THE BUFFERS IN QUICKFIX OR LOCATION LIST:
|
|||||||
< Otherwise it works the same as `:ldo`.
|
< Otherwise it works the same as `:ldo`.
|
||||||
{not in Vi}
|
{not in Vi}
|
||||||
|
|
||||||
|
FILTERING A QUICKFIX OR LOCATION LIST:
|
||||||
|
*cfilter-plugin* *:Cfilter* *:Lfilter*
|
||||||
|
If you have too many entries in a quickfix list, you can use the cfilter
|
||||||
|
plugin to reduce the number of entries. Load the plugin with: >
|
||||||
|
|
||||||
|
packadd cfilter
|
||||||
|
|
||||||
|
Then you can use the following commands to filter a quickfix/location list: >
|
||||||
|
|
||||||
|
:Cfilter[!] /{pat}/
|
||||||
|
:Lfilter[!] /{pat}/
|
||||||
|
|
||||||
|
The |:Cfilter| command creates a new quickfix list from the entries matching
|
||||||
|
{pat} in the current quickfix list. {pat} is a Vim |regular-expression|
|
||||||
|
pattern. Both the file name and the text of the entries are matched against
|
||||||
|
{pat}. If the optional ! is supplied, then the entries not matching {pat} are
|
||||||
|
used. The pattern can be optionally enclosed using one of the following
|
||||||
|
characters: ', ", /. If the pattern is empty, then the last used search
|
||||||
|
pattern is used.
|
||||||
|
|
||||||
|
The |:Lfilter| command does the same as |:Cfilter| but operates on the current
|
||||||
|
location list.
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
2. The error window *quickfix-window*
|
2. The error window *quickfix-window*
|
||||||
|
|
||||||
@ -1563,22 +1586,6 @@ The backslashes before the pipe character are required to avoid it to be
|
|||||||
recognized as a command separator. The backslash before each space is
|
recognized as a command separator. The backslash before each space is
|
||||||
required for the set command.
|
required for the set command.
|
||||||
|
|
||||||
*cfilter-plugin* *:Cfilter* *:Lfilter*
|
|
||||||
If you have too many matching messages, you can use the cfilter plugin to
|
|
||||||
reduce the number of entries. Load the plugin with: >
|
|
||||||
packadd cfilter
|
|
||||||
|
|
||||||
Then you can use these command: >
|
|
||||||
:Cfilter[!] /{pat}/
|
|
||||||
:Lfilter[!] /{pat}/
|
|
||||||
|
|
||||||
:Cfilter creates 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 does the same as :Cfilter but operates on the current location list.
|
|
||||||
|
|
||||||
=============================================================================
|
=============================================================================
|
||||||
8. The directory stack *quickfix-directory-stack*
|
8. The directory stack *quickfix-directory-stack*
|
||||||
|
|
||||||
|
41
runtime/pack/dist/opt/cfilter/plugin/cfilter.vim
vendored
41
runtime/pack/dist/opt/cfilter/plugin/cfilter.vim
vendored
@ -1,15 +1,17 @@
|
|||||||
" cfilter.vim: Plugin to filter entries from a quickfix/location list
|
" cfilter.vim: Plugin to filter entries from a quickfix/location list
|
||||||
" Last Change: May 12, 2018
|
" Last Change: Aug 23, 2018
|
||||||
" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
|
" Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
|
||||||
" Version: 1.0
|
" Version: 1.1
|
||||||
"
|
"
|
||||||
" Commands to filter the quickfix list:
|
" Commands to filter the quickfix list:
|
||||||
" :Cfilter[!] {pat}
|
" :Cfilter[!] /{pat}/
|
||||||
" Create a new quickfix list from entries matching {pat} in the current
|
" 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
|
" quickfix list. Both the file name and the text of the entries are
|
||||||
" matched against {pat}. If ! is supplied, then entries not matching
|
" matched against {pat}. If ! is supplied, then entries not matching
|
||||||
" {pat} are used.
|
" {pat} are used. The pattern can be optionally enclosed using one of
|
||||||
" :Lfilter[!] {pat}
|
" the following characters: ', ", /. If the pattern is empty, then the
|
||||||
|
" last used search pattern is used.
|
||||||
|
" :Lfilter[!] /{pat}/
|
||||||
" Same as :Cfilter but operates on the current location list.
|
" Same as :Cfilter but operates on the current location list.
|
||||||
"
|
"
|
||||||
if exists("loaded_cfilter")
|
if exists("loaded_cfilter")
|
||||||
@ -17,7 +19,7 @@ if exists("loaded_cfilter")
|
|||||||
endif
|
endif
|
||||||
let loaded_cfilter = 1
|
let loaded_cfilter = 1
|
||||||
|
|
||||||
func s:Qf_filter(qf, pat, bang)
|
func s:Qf_filter(qf, searchpat, bang)
|
||||||
if a:qf
|
if a:qf
|
||||||
let Xgetlist = function('getqflist')
|
let Xgetlist = function('getqflist')
|
||||||
let Xsetlist = function('setqflist')
|
let Xsetlist = function('setqflist')
|
||||||
@ -28,14 +30,31 @@ func s:Qf_filter(qf, pat, bang)
|
|||||||
let cmd = ':Lfilter' . a:bang
|
let cmd = ':Lfilter' . a:bang
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if a:bang == '!'
|
let firstchar = a:searchpat[0]
|
||||||
let cond = 'v:val.text !~# a:pat && bufname(v:val.bufnr) !~# a:pat'
|
let lastchar = a:searchpat[-1:]
|
||||||
|
if firstchar == lastchar &&
|
||||||
|
\ (firstchar == '/' || firstchar == '"' || firstchar == "'")
|
||||||
|
let pat = a:searchpat[1:-2]
|
||||||
|
if pat == ''
|
||||||
|
" Use the last search pattern
|
||||||
|
let pat = @/
|
||||||
|
endif
|
||||||
else
|
else
|
||||||
let cond = 'v:val.text =~# a:pat || bufname(v:val.bufnr) =~# a:pat'
|
let pat = a:searchpat
|
||||||
|
endif
|
||||||
|
|
||||||
|
if pat == ''
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
if a:bang == '!'
|
||||||
|
let cond = 'v:val.text !~# pat && bufname(v:val.bufnr) !~# pat'
|
||||||
|
else
|
||||||
|
let cond = 'v:val.text =~# pat || bufname(v:val.bufnr) =~# pat'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let items = filter(Xgetlist(), cond)
|
let items = filter(Xgetlist(), cond)
|
||||||
let title = cmd . ' ' . a:pat
|
let title = cmd . ' /' . pat . '/'
|
||||||
call Xsetlist([], ' ', {'title' : title, 'items' : items})
|
call Xsetlist([], ' ', {'title' : title, 'items' : items})
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user