@@ -32,10 +32,8 @@ def _loc():
3232 return Loc (path = path , row = row , col = col )
3333
3434
35- def _run (loc , opts = []):
36- cmd = ["clutter" , "-i" , "" , "r" , "--loc" , f'{ loc .path } :{ loc .row } .{ loc .col + 1 } ' ]
37-
38- cmd .extend (opts )
35+ def _run (opts = []):
36+ cmd = ["clutter" , "-i" , "" ] + opts
3937
4038 proc = subprocess .run (cmd , capture_output = True )
4139
@@ -78,12 +76,16 @@ def _run(loc, opts=[]):
7876 return matches
7977
8078
79+ def _resolve_opts (loc ):
80+ return ["r" , "--loc" , f'{ loc .path } :{ loc .row } .{ loc .col + 1 } ' ]
81+
82+
8183def resolve1 (which ):
8284 loc = _loc ()
8385 if not loc :
8486 return
8587
86- matches = _run (loc , opts = [f'-{ which } ' , '-c' ])
88+ matches = _run (_resolve_opts ( loc ) + [f'-{ which } ' , '-c' ])
8789
8890 if not matches :
8991 return
@@ -111,11 +113,23 @@ def resolve_list():
111113 if not loc :
112114 return
113115
114- _render_list (_run (loc ), loc )
116+ _render_list (_run (_resolve_opts (loc )), loc )
117+
118+
119+ def search (mode , args ):
120+ cmd = ['s' ]
121+
122+ if mode :
123+ cmd .append (f'-{ mode } ' )
124+
125+ cmd .extend (args )
126+
127+ _render_list (_run (cmd ))
115128
116129
117- def _render_list (matches , loc ):
130+ def _render_list (matches , loc = None ):
118131 if not matches :
132+ print ('clutter: no matches' )
119133 return
120134
121135 vim .command ('call setloclist(0, [], "f")' )
@@ -129,7 +143,7 @@ def _render_list(matches, loc):
129143 )
130144 )
131145
132- if m .path == loc .path and m .line == loc .row and m .col <= loc .col <= m .endcol :
146+ if loc and m .path == loc .path and m .line == loc .row and m .col <= loc .col <= m .endcol :
133147 vim .command ('call setloclist(0, [], "a", {"idx": %d})' % i )
134148
135149 i += 1
0 commit comments