Skip to content

Commit

Permalink
feat: support variables in path towards the file to load as well
Browse files Browse the repository at this point in the history
It is now possible to run:
< {{HOME}}/my_json_file
  • Loading branch information
teto committed Aug 22, 2022
1 parent 8c719ed commit ef06dae
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lua/rest-nvim/request/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ local function get_importfile_name(bufnr, start_line, stop_line)
local fileimport_string
local fileimport_line
fileimport_line = vim.api.nvim_buf_get_lines(bufnr, import_line - 1, import_line, false)
fileimport_string =
string.gsub(fileimport_line[1], "<", "", 1):gsub("^%s+", ""):gsub("%s+$", "")
-- local fileimport_path = path:new(fileimport_string)
-- if fileimport_path:is_absolute() then
if path:new(fileimport_string):is_absolute() then
return fileimport_string
fileimport_string = string.gsub(fileimport_line[1], "<", "", 1)
:gsub("^%s+", "")
:gsub("%s+$", "")
fileimport_spliced = utils.replace_vars(fileimport_string)
if path:new(fileimport_spliced):is_absolute() then
return fileimport_spliced
else
local file_dirname = vim.fn.expand("%:p:h")
local file_name = path:new(path:new(file_dirname), fileimport_string)
local file_name = path:new(path:new(file_dirname), fileimport_spliced)
return file_name:absolute()
end
end
Expand Down

0 comments on commit ef06dae

Please sign in to comment.