Skip to content

Commit ef06dae

Browse files
author
Matthieu Coudron
committed
feat: support variables in path towards the file to load as well
It is now possible to run: < {{HOME}}/my_json_file
1 parent 8c719ed commit ef06dae

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lua/rest-nvim/request/init.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ local function get_importfile_name(bufnr, start_line, stop_line)
1919
local fileimport_string
2020
local fileimport_line
2121
fileimport_line = vim.api.nvim_buf_get_lines(bufnr, import_line - 1, import_line, false)
22-
fileimport_string =
23-
string.gsub(fileimport_line[1], "<", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
24-
-- local fileimport_path = path:new(fileimport_string)
25-
-- if fileimport_path:is_absolute() then
26-
if path:new(fileimport_string):is_absolute() then
27-
return fileimport_string
22+
fileimport_string = string.gsub(fileimport_line[1], "<", "", 1)
23+
:gsub("^%s+", "")
24+
:gsub("%s+$", "")
25+
fileimport_spliced = utils.replace_vars(fileimport_string)
26+
if path:new(fileimport_spliced):is_absolute() then
27+
return fileimport_spliced
2828
else
2929
local file_dirname = vim.fn.expand("%:p:h")
30-
local file_name = path:new(path:new(file_dirname), fileimport_string)
30+
local file_name = path:new(path:new(file_dirname), fileimport_spliced)
3131
return file_name:absolute()
3232
end
3333
end

0 commit comments

Comments
 (0)