Skip to content

Commit 08e5876

Browse files
NTBBloodbathgithub-actions[bot]
authored andcommitted
chore: autoformat with stylua
1 parent 734e696 commit 08e5876

3 files changed

Lines changed: 23 additions & 28 deletions

File tree

lua/rest-nvim/curl/init.lua

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,7 @@ local function create_callback(curl_cmd, opts)
208208
else
209209
vim.api.nvim_echo({
210210
{
211-
string.format(
212-
"Error running formatter %s on response body:\n%s",
213-
vim.inspect(formatter),
214-
stdout
215-
),
211+
string.format("Error running formatter %s on response body:\n%s", vim.inspect(formatter), stdout),
216212
"Error",
217213
},
218214
}, false, {})

lua/rest-nvim/init.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ local function load_external_payload(fileimport_string)
8383
end
8484
end
8585

86-
8786
-- @param headers table HTTP headers
8887
-- @param payload table of the form { external = bool, filename_tpl= path, body_tpl = string }
8988
-- with body_tpl an array of lines
@@ -101,7 +100,7 @@ local function splice_body(headers, payload)
101100
else
102101
lines = payload.body_tpl
103102
end
104-
local content_type = headers[utils.key(headers,"content-type")] or ""
103+
local content_type = headers[utils.key(headers, "content-type")] or ""
105104
local has_json = content_type:find("application/[^ ]*json")
106105

107106
local body = ""
@@ -140,8 +139,7 @@ end
140139
rest.run_request = function(req, opts)
141140
-- TODO rename result to request
142141
local result = req
143-
local curl_raw_args = config.get("skip_ssl_verification") and vim.list_extend(result.raw, { "-k" })
144-
or result.raw
142+
local curl_raw_args = config.get("skip_ssl_verification") and vim.list_extend(result.raw, { "-k" }) or result.raw
145143
opts = vim.tbl_deep_extend(
146144
"force", -- use value from rightmost map
147145
defaultRequestOpts,
@@ -153,7 +151,9 @@ rest.run_request = function(req, opts)
153151
local spliced_body = nil
154152
if not req.body.inline and req.body.filename_tpl then
155153
curl_raw_args = vim.tbl_extend("force", curl_raw_args, {
156-
'--data-binary', '@'..load_external_payload(req.body.filename_tpl)})
154+
"--data-binary",
155+
"@" .. load_external_payload(req.body.filename_tpl),
156+
})
157157
else
158158
spliced_body = splice_body(result.headers, result.body)
159159
end

lua/rest-nvim/request/init.lua

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,9 @@ local function get_importfile_name(bufnr, start_line, stop_line)
2121
local fileimport_inlined
2222
fileimport_line = vim.api.nvim_buf_get_lines(bufnr, import_line - 1, import_line, false)
2323
-- check second char against '@' (meaning "dont inline")
24-
fileimport_inlined = string.sub(fileimport_line[1], 2, 2) ~= '@'
24+
fileimport_inlined = string.sub(fileimport_line[1], 2, 2) ~= "@"
2525
fileimport_string = string.gsub(fileimport_line[1], "<@?", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
2626
return fileimport_inlined, fileimport_string
27-
2827
end
2928
return nil
3029
end
@@ -42,7 +41,7 @@ local function get_body(bufnr, start_line, stop_line)
4241
local inline, importfile = get_importfile_name(bufnr, start_line, stop_line)
4342
local lines -- an array of strings
4443
if importfile ~= nil then
45-
return { external = true; inline = inline; filename_tpl = importfile }
44+
return { external = true, inline = inline, filename_tpl = importfile }
4645
else
4746
lines = vim.api.nvim_buf_get_lines(bufnr, start_line, stop_line, false)
4847
end
@@ -63,7 +62,7 @@ local function get_body(bufnr, start_line, stop_line)
6362
end
6463
end
6564

66-
return { external = false; inline = false; body_tpl = lines2 }
65+
return { external = false, inline = false, body_tpl = lines2 }
6766
end
6867

6968
local function get_response_script(bufnr, start_line, stop_line)
@@ -285,9 +284,9 @@ M.buf_get_request = function(bufnr, curpos)
285284

286285
local curl_args, body_start = get_curl_args(bufnr, headers_end, end_line)
287286

288-
local host = headers[utils.key(headers,"host")] or ""
287+
local host = headers[utils.key(headers, "host")] or ""
289288
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
290-
headers[utils.key(headers,"host")] = nil
289+
headers[utils.key(headers, "host")] = nil
291290

292291
local body = get_body(bufnr, body_start, end_line)
293292

@@ -302,17 +301,17 @@ M.buf_get_request = function(bufnr, curpos)
302301
end
303302

304303
local req = {
305-
method = parsed_url.method,
306-
url = parsed_url.url,
307-
http_version = parsed_url.http_version,
308-
headers = headers,
309-
raw = curl_args,
310-
body = body,
311-
bufnr = bufnr,
312-
start_line = start_line,
313-
end_line = end_line,
314-
script_str = script_str,
315-
}
304+
method = parsed_url.method,
305+
url = parsed_url.url,
306+
http_version = parsed_url.http_version,
307+
headers = headers,
308+
raw = curl_args,
309+
body = body,
310+
bufnr = bufnr,
311+
start_line = start_line,
312+
end_line = end_line,
313+
script_str = script_str,
314+
}
316315

317316
return true, req
318317
end
@@ -393,7 +392,7 @@ M.highlight = function(bufnr, start_line, end_line)
393392
higroup,
394393
{ start_line - 1, 0 },
395394
{ end_line - 1, end_column },
396-
{ regtype = "c"; inclusive = false }
395+
{ regtype = "c", inclusive = false }
397396
)
398397

399398
vim.defer_fn(function()

0 commit comments

Comments
 (0)