@@ -5,6 +5,7 @@ local config = require("rest-nvim.config")
55-- get_importfile returns in case of an imported file the absolute filename
66-- @param bufnr Buffer number, a.k.a id
77-- @param stop_line Line to stop searching
8+ -- @return tuple filename and whether we should inline it when invoking curl
89local function get_importfile_name (bufnr , start_line , stop_line )
910 -- store old cursor position
1011 local oldpos = vim .fn .getcurpos ()
@@ -17,10 +18,13 @@ local function get_importfile_name(bufnr, start_line, stop_line)
1718 if import_line > 0 then
1819 local fileimport_string
1920 local fileimport_line
21+ local fileimport_inlined
2022 fileimport_line = vim .api .nvim_buf_get_lines (bufnr , import_line - 1 , import_line , false )
21- fileimport_string =
22- string.gsub (fileimport_line [1 ], " <" , " " , 1 ):gsub (" ^%s+" , " " ):gsub (" %s+$" , " " )
23- return fileimport_string
23+ -- check second char against '@' (meaning "dont inline")
24+ fileimport_inlined = string.sub (fileimport_line [1 ], 2 , 2 ) ~= ' @'
25+ fileimport_string = string.gsub (fileimport_line [1 ], " <@?" , " " , 1 ):gsub (" ^%s+" , " " ):gsub (" %s+$" , " " )
26+ return fileimport_inlined , fileimport_string
27+
2428 end
2529 return nil
2630end
3539-- @return table { external = bool; filename_tpl or body_tpl; }
3640local function get_body (bufnr , start_line , stop_line )
3741 -- first check if the body should be imported from an external file
38- local importfile = get_importfile_name (bufnr , start_line , stop_line )
42+ local inline , importfile = get_importfile_name (bufnr , start_line , stop_line )
3943 local lines -- an array of strings
4044 if importfile ~= nil then
41- return { external = true , filename_tpl = importfile }
45+ return { external = true ; inline = inline ; filename_tpl = importfile }
4246 else
4347 lines = vim .api .nvim_buf_get_lines (bufnr , start_line , stop_line , false )
4448 end
@@ -59,7 +63,7 @@ local function get_body(bufnr, start_line, stop_line)
5963 end
6064 end
6165
62- return { external = false , body_tpl = lines2 }
66+ return { external = false ; inline = false ; body_tpl = lines2 }
6367end
6468
6569local function get_response_script (bufnr , start_line , stop_line )
@@ -393,8 +397,7 @@ M.highlight = function(bufnr, start_line, end_line)
393397 higroup ,
394398 { start_line - 1 , 0 },
395399 { end_line - 1 , end_column },
396- " c" ,
397- false
400+ { regtype = " c" ; inclusive = false }
398401 )
399402
400403 vim .defer_fn (function ()
0 commit comments