3 files changed,
21 insertions(+),
19 deletions(-)
Author:
Oleksandr Smirnov
olexsmir@gmail.com
Committed at:
2026-04-19 22:50:04 +0300
Authored at:
2026-04-19 22:48:08 +0300
Change ID:
ooymvnuxmsrnrrpnkxoqlvmztkwsmmsk
Parent:
ab9e65f
jump to
| M | lua/curl.lua |
| M | readme |
| M | stylua.toml |
M
lua/curl.lua
··· 29 29 end 30 30 31 31 if not H.query_autocmd_set then 32 - vim.api.nvim_create_autocmd( 33 - { "BufReadPost", "BufNewFile", "BufEnter", "BufWinEnter", "BufFilePost" }, 34 - { 35 - group = vim.api.nvim_create_augroup("curl_nvim_query_files", { clear = true }), 36 - pattern = "*.curl", 37 - callback = function(args) 38 - H.attach_curl_buffer(args.buf) 39 - end, 40 - } 41 - ) 32 + vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile", "BufEnter", "BufWinEnter", "BufFilePost" }, { 33 + group = vim.api.nvim_create_augroup("curl_nvim_query_files", { clear = true }), 34 + pattern = "*.curl", 35 + callback = function(args) 36 + H.attach_curl_buffer(args.buf) 37 + end, 38 + }) 42 39 for _, buf in ipairs(vim.api.nvim_list_bufs()) do 43 40 H.attach_curl_buffer(buf) 44 41 end ··· 113 110 return line:match "^%s*curl%s" or line:match "^%s*curl$" or line:match "^%s*https?://" 114 111 end 115 112 116 -local function save_query_buffer(buf, file) 113 +function H.save_query_buffer(buf, file) 117 114 if not H.is_valid_buf(buf) then return end 118 115 file = file or vim.api.nvim_buf_get_name(buf) 119 116 if not H.is_curl_file(file) then return end ··· 173 170 group = vim.api.nvim_create_augroup("curl_nvim_cache_" .. buf, { clear = true }), 174 171 buffer = buf, 175 172 callback = function() 176 - save_query_buffer(buf, file) 173 + H.save_query_buffer(buf, file) 177 174 end, 178 175 }) 179 176 end ··· 326 323 327 324 function H.write_formatted_output(output) 328 325 if output == "" or vim.fn.executable "jq" ~= 1 then 329 - vim.schedule(function() H.write_output(output, false) end) 326 + vim.schedule(function() 327 + H.write_output(output, false) 328 + end) 330 329 return 331 330 end 332 331 ··· 339 338 end 340 339 end 341 340 if not json_index then 342 - vim.schedule(function() H.write_output(output, false) end) 341 + vim.schedule(function() 342 + H.write_output(output, false) 343 + end) 343 344 return 344 345 end 345 346 ··· 353 354 local text, is_json = output, false 354 355 if result.code == 0 and result.stdout and result.stdout ~= "" then 355 356 is_json = true 356 - text = #headers > 0 and (table.concat(headers, "\n") .. "\n" .. result.stdout) 357 - or result.stdout 357 + text = #headers > 0 and (table.concat(headers, "\n") .. "\n" .. result.stdout) or result.stdout 358 358 end 359 - vim.schedule(function() H.write_output(text, is_json) end) 359 + vim.schedule(function() 360 + H.write_output(text, is_json) 361 + end) 360 362 end) 361 363 end 362 364