4040
4141M .select_entry = function ()
4242 local entry = M .get_current_entry ()
43- if not entry then return end
43+ if not entry then
44+ return
45+ end
4446
45- local full_path = vim .fn .fnamemodify (entry .filename , " :p" )
46- if not vim .fn .filereadable (full_path ) then return end
47+ local full_path = vim .fn .fnamemodify (entry .filename , ' :p' )
48+ if not vim .fn .filereadable (full_path ) then
49+ return
50+ end
4751
48- vim .cmd (" edit " .. full_path )
52+ vim .cmd (' edit ' .. full_path )
4953 api .nvim_win_set_cursor (0 , { entry .lnum , entry .col - 1 })
5054end
5155
@@ -70,16 +74,20 @@ function M.get_current_entry()
7074 local cursor_pos = api .nvim_win_get_cursor (0 )
7175 local line = api .nvim_buf_get_lines (bufnr , cursor_pos [1 ] - 1 , cursor_pos [1 ], false )[1 ]
7276
73- if not line then return nil end
77+ if not line then
78+ return nil
79+ end
7480
75- local filename , lnum , col = line :match (" ([^:]+):(%d+):(%d+):" )
76- if not filename or not lnum or not col then return nil end
81+ local filename , lnum , col = line :match (' ([^:]+):(%d+):(%d+):' )
82+ if not filename or not lnum or not col then
83+ return nil
84+ end
7785
7886 return {
7987 filename = filename ,
8088 lnum = tonumber (lnum ),
8189 col = tonumber (col ),
82- text = line :match (" :[^:]+$" ):sub (2 ),
90+ text = line :match (' :[^:]+$' ):sub (2 ),
8391 }
8492end
8593
@@ -93,7 +101,7 @@ function M.get_all_entries()
93101 col = item .col ,
94102 text = item .text ,
95103 display_lnum = display_lnum - 1 ,
96- is_replace_finish = item .is_replace_finish or false
104+ is_replace_finish = item .is_replace_finish or false ,
97105 })
98106 end
99107 end
103111M .send_to_qf = function ()
104112 local entries = M .get_all_entries ()
105113 if # entries == 0 then
106- vim .notify (" No entries to send to quickfix" )
114+ vim .notify (' No entries to send to quickfix' )
107115 return
108116 end
109117
@@ -118,7 +126,7 @@ M.send_to_qf = function()
118126 end
119127
120128 vim .fn .setqflist (qf_list )
121- vim .cmd (" copen" )
129+ vim .cmd (' copen' )
122130end
123131
124132-- input that comand to run on vim
@@ -154,7 +162,7 @@ function M.run_current_replace()
154162 if entry then
155163 M .run_replace ({ entry })
156164 else
157- vim .notify (" Not found any entry to replace." )
165+ vim .notify (' Not found any entry to replace.' )
158166 end
159167end
160168
@@ -163,7 +171,7 @@ local is_running = false
163171function M .run_replace (entries )
164172 entries = entries or M .get_all_entries ()
165173 if # entries == 0 then
166- vim .notify (" No entries to replace" )
174+ vim .notify (' No entries to replace' )
167175 return
168176 end
169177
@@ -185,14 +193,14 @@ function M.run_replace(entries)
185193 )
186194 -- Trigger renderer redraw
187195 if state .renderer then
188- print (" redrawing" )
196+ print (' redrawing' )
189197 state .renderer :redraw ()
190198 end
191199 end
192200 end ,
193201 on_error = function (result )
194202 if result .ref then
195- vim .notify (" Error replacing: " .. result .value , vim .log .levels .ERROR )
203+ vim .notify (' Error replacing: ' .. result .value , vim .log .levels .ERROR )
196204 -- Add error mark to the line
197205 local bufnr = api .nvim_get_current_buf ()
198206 local line = result .ref .display_lnum
@@ -205,7 +213,7 @@ function M.run_replace(entries)
205213 )
206214 -- Trigger renderer redraw
207215 if state .renderer then
208- print (" redrawing" )
216+ print (' redrawing' )
209217 state .renderer :redraw ()
210218 end
211219 end
0 commit comments