Mercurial > vim
annotate runtime/pack/dist/opt/cfilter/plugin/cfilter.vim @ 35294:87914e4b8178 default tip
check.vim complains about overlong comment lines
Commit: https://github.com/vim/vim/commit/32a5faa6d7592795c6ec77e44dc0357b92b8a681
Author: Christian Brabandt <cb@256bit.org>
Date: Thu May 30 09:51:47 2024 +0200
check.vim complains about overlong comment lines
Problem: check.vim complains about overlong comment lines
Solution: only check the length of non-commented lines
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 30 May 2024 10:00:04 +0200 |
parents | 01cbbc20df1f |
children |
rev | line source |
---|---|
29352 | 1 vim9script |
2 | |
3 # cfilter.vim: Plugin to filter entries from a quickfix/location list | |
32820
01cbbc20df1f
Use string interpolation (#12823)
Christian Brabandt <cb@256bit.org>
parents:
29352
diff
changeset
|
4 # Last Change: August 16, 2023 |
29352 | 5 # Maintainer: Yegappan Lakshmanan (yegappan AT yahoo DOT com) |
6 # Version: 2.0 | |
7 # | |
8 # Commands to filter the quickfix list: | |
9 # :Cfilter[!] /{pat}/ | |
10 # Create a new quickfix list from entries matching {pat} in the current | |
11 # quickfix list. Both the file name and the text of the entries are | |
12 # matched against {pat}. If ! is supplied, then entries not matching | |
13 # {pat} are used. The pattern can be optionally enclosed using one of | |
14 # the following characters: ', ", /. If the pattern is empty, then the | |
15 # last used search pattern is used. | |
16 # :Lfilter[!] /{pat}/ | |
17 # Same as :Cfilter but operates on the current location list. | |
18 # | |
14595
2b9c586918f8
patch 8.1.0311: filtering entries in a quickfix list is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
29352 | 20 def Qf_filter(qf: bool, searchpat: string, bang: string) |
21 var Xgetlist: func | |
22 var Xsetlist: func | |
23 var cmd: string | |
24 var firstchar: string | |
25 var lastchar: string | |
26 var pat: string | |
27 var title: string | |
28 var Cond: func | |
29 var items: list<any> | |
30 | |
31 if qf | |
32 Xgetlist = function('getqflist') | |
33 Xsetlist = function('setqflist') | |
32820
01cbbc20df1f
Use string interpolation (#12823)
Christian Brabandt <cb@256bit.org>
parents:
29352
diff
changeset
|
34 cmd = $':Cfilter{bang}' |
29352 | 35 else |
36 Xgetlist = function('getloclist', [0]) | |
37 Xsetlist = function('setloclist', [0]) | |
32820
01cbbc20df1f
Use string interpolation (#12823)
Christian Brabandt <cb@256bit.org>
parents:
29352
diff
changeset
|
38 cmd = $':Lfilter{bang}' |
29352 | 39 endif |
40 | |
41 firstchar = searchpat[0] | |
42 lastchar = searchpat[-1 :] | |
43 if firstchar == lastchar && | |
44 (firstchar == '/' || firstchar == '"' || firstchar == "'") | |
45 pat = searchpat[1 : -2] | |
46 if pat == '' | |
47 # Use the last search pattern | |
48 pat = @/ | |
14595
2b9c586918f8
patch 8.1.0311: filtering entries in a quickfix list is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 endif |
29352 | 50 else |
51 pat = searchpat | |
52 endif | |
14595
2b9c586918f8
patch 8.1.0311: filtering entries in a quickfix list is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 |
29352 | 54 if pat == '' |
55 return | |
56 endif | |
14637 | 57 |
29352 | 58 if bang == '!' |
59 Cond = (_, val) => val.text !~# pat && bufname(val.bufnr) !~# pat | |
60 else | |
61 Cond = (_, val) => val.text =~# pat || bufname(val.bufnr) =~# pat | |
62 endif | |
14637 | 63 |
29352 | 64 items = filter(Xgetlist(), Cond) |
32820
01cbbc20df1f
Use string interpolation (#12823)
Christian Brabandt <cb@256bit.org>
parents:
29352
diff
changeset
|
65 title = $'{cmd} /{pat}/' |
29352 | 66 Xsetlist([], ' ', {title: title, items: items}) |
67 enddef | |
14595
2b9c586918f8
patch 8.1.0311: filtering entries in a quickfix list is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 |
29352 | 69 command! -nargs=+ -bang Cfilter Qf_filter(true, <q-args>, <q-bang>) |
70 command! -nargs=+ -bang Lfilter Qf_filter(false, <q-args>, <q-bang>) | |
14595
2b9c586918f8
patch 8.1.0311: filtering entries in a quickfix list is not easy
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
29352 | 72 # vim: shiftwidth=2 sts=2 expandtab |