Skip to content

Commit

Permalink
fix: remove stylua edits
Browse files Browse the repository at this point in the history
  • Loading branch information
Rasmus-Bertell committed Nov 23, 2023
1 parent 042d6d2 commit 0d22f4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
6 changes: 3 additions & 3 deletions lua/rest-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ local function load_external_payload(fileimport_string)
end
end


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

local body = ""
Expand Down Expand Up @@ -152,8 +153,7 @@ rest.run_request = function(req, opts)
local spliced_body = nil
if not req.body.inline and req.body.filename_tpl then
curl_raw_args = vim.tbl_extend("force", curl_raw_args, {
"--data-binary", "@" .. load_external_payload(req.body.filename_tpl),
})
'--data-binary', '@'..load_external_payload(req.body.filename_tpl)})
else
spliced_body = splice_body(result.headers, result.body)
end
Expand Down
35 changes: 18 additions & 17 deletions lua/rest-nvim/request/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ local function get_importfile_name(bufnr, start_line, stop_line)
local fileimport_inlined
fileimport_line = vim.api.nvim_buf_get_lines(bufnr, import_line - 1, import_line, false)
-- check second char against '@' (meaning "dont inline")
fileimport_inlined = string.sub(fileimport_line[1], 2, 2) ~= "@"
fileimport_inlined = string.sub(fileimport_line[1], 2, 2) ~= '@'
fileimport_string = string.gsub(fileimport_line[1], "<@?", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
return fileimport_inlined, fileimport_string

end
return nil
end
Expand All @@ -41,7 +42,7 @@ local function get_body(bufnr, start_line, stop_line)
local inline, importfile = get_importfile_name(bufnr, start_line, stop_line)
local lines -- an array of strings
if importfile ~= nil then
return { external = true, inline = inline, filename_tpl = importfile }
return { external = true; inline = inline; filename_tpl = importfile }
else
lines = vim.api.nvim_buf_get_lines(bufnr, start_line, stop_line, false)
end
Expand All @@ -62,7 +63,7 @@ local function get_body(bufnr, start_line, stop_line)
end
end

return { external = false, inline = false, body_tpl = lines2 }
return { external = false; inline = false; body_tpl = lines2 }
end

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

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

local host = headers[utils.key(headers, "host")] or ""
local host = headers[utils.key(headers,"host")] or ""
parsed_url.url = host:gsub("%s+", "") .. parsed_url.url
headers[utils.key(headers, "host")] = nil
headers[utils.key(headers,"host")] = nil

local body = get_body(bufnr, body_start, end_line)

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

local req = {
method = parsed_url.method,
url = parsed_url.url,
http_version = parsed_url.http_version,
headers = headers,
raw = curl_args,
body = body,
bufnr = bufnr,
start_line = start_line,
end_line = end_line,
script_str = script_str,
}
method = parsed_url.method,
url = parsed_url.url,
http_version = parsed_url.http_version,
headers = headers,
raw = curl_args,
body = body,
bufnr = bufnr,
start_line = start_line,
end_line = end_line,
script_str = script_str,
}

return true, req
end
Expand Down Expand Up @@ -392,7 +393,7 @@ M.highlight = function(bufnr, start_line, end_line)
higroup,
{ start_line - 1, 0 },
{ end_line - 1, end_column },
{ regtype = "c", inclusive = false }
{ regtype = "c"; inclusive = false }
)

vim.defer_fn(function()
Expand Down

0 comments on commit 0d22f4a

Please sign in to comment.