@@ -235,45 +235,49 @@ local rest_command_tbl = {
235235 if not req_node then
236236 return
237237 end
238- local req = parser ().parse (req_node , 0 )
239- if not req then
240- logger ().error (" failed to parse request" )
241- vim .notify (
242- " failed to parse request. See `:Rest logs` for more info" ,
243- vim .log .levels .ERROR ,
244- { title = " rest.nvim" }
245- )
246- return
247- end
248- local curl_command = require (" rest-nvim.client.curl.cli" ).builder .build_command (req )
249- vim .fn .setreg (" +" , curl_command .. " \n " )
250- vim .notify (" Copied curl command to clipboard" , vim .log .levels .INFO , { title = " rest.nvim" })
238+ require (" nio" ).run (function ()
239+ local req = parser ().parse (req_node , 0 )
240+ if not req then
241+ logger ().error (" failed to parse request" )
242+ vim .notify (
243+ " failed to parse request. See `:Rest logs` for more info" ,
244+ vim .log .levels .ERROR ,
245+ { title = " rest.nvim" }
246+ )
247+ return
248+ end
249+ local curl_command = require (" rest-nvim.client.curl.cli" ).builder .build_command (req )
250+ vim .fn .setreg (" +" , curl_command .. " \n " )
251+ vim .notify (" Copied curl command to clipboard" , vim .log .levels .INFO , { title = " rest.nvim" })
252+ end )
251253 elseif args [1 ] == " comment" then
252254 local req_node = parser ().get_request_node (args [2 ])
253255 if not req_node then
254256 return
255257 end
256- local req = parser ().parse (req_node , 0 )
257- if not req then
258- logger ().error (" failed to parse request" )
259- vim .notify (
260- " failed to parse request. See `:Rest logs` for more info" ,
261- vim .log .levels .ERROR ,
262- { title = " rest.nvim" }
258+ require (" nio" ).run (function ()
259+ local req = parser ().parse (req_node , 0 )
260+ if not req then
261+ logger ().error (" failed to parse request" )
262+ vim .notify (
263+ " failed to parse request. See `:Rest logs` for more info" ,
264+ vim .log .levels .ERROR ,
265+ { title = " rest.nvim" }
266+ )
267+ return
268+ end
269+ local curl_command = require (" rest-nvim.client.curl.cli" ).builder .build_command (req )
270+ local start = req_node :range ()
271+ vim .api .nvim_buf_set_lines (
272+ 0 ,
273+ start ,
274+ start ,
275+ false ,
276+ vim .tbl_map (function (line )
277+ return " # " .. line
278+ end , vim .split (curl_command , " \n " ))
263279 )
264- return
265- end
266- local curl_command = require (" rest-nvim.client.curl.cli" ).builder .build_command (req )
267- local start = req_node :range ()
268- vim .api .nvim_buf_set_lines (
269- 0 ,
270- start ,
271- start ,
272- false ,
273- vim .tbl_map (function (line )
274- return " # " .. line
275- end , vim .split (curl_command , " \n " ))
276- )
280+ end )
277281 -- elseif args[1] == "to-http" then
278282 -- -- TODO: convert comment with curl to http request and insert it below
279283 else
0 commit comments