Skip to content

Commit 3ab950f

Browse files
Format source code
1 parent 4b1ae8a commit 3ab950f

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

lua/rest-nvim/utils/init.lua

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,41 +93,46 @@ end
9393
M.get_node_value = function(node, bufnr)
9494
local start_row, start_col, _, end_col = node:range()
9595
local line = vim.api.nvim_buf_get_lines(bufnr, start_row, start_row + 1, false)[1]
96-
return line and string.sub(line, start_col + 1, end_col):gsub('^["\'](.*)["\']$', '%1') or nil
96+
return line and string.sub(line, start_col + 1, end_col):gsub("^[\"'](.*)[\"']$", "%1") or nil
9797
end
9898

9999
M.read_document_variables = function()
100100
local variables = {}
101101
local bufnr = vim.api.nvim_get_current_buf()
102102
local parser = vim.treesitter.get_parser(bufnr)
103-
if not parser then return variables end
103+
if not parser then
104+
return variables
105+
end
104106

105107
local first_tree = parser:trees()[1]
106-
if not first_tree then return variables end
108+
if not first_tree then
109+
return variables
110+
end
107111

108112
local root = first_tree:root()
109-
if not root then return variables end
113+
if not root then
114+
return variables
115+
end
110116

111117
for node in root:iter_children() do
112118
local type = node:type()
113-
if type == 'header' then
119+
if type == "header" then
114120
local name = node:named_child(0)
115121
local value = node:named_child(1)
116122
variables[M.get_node_value(name, bufnr)] = M.get_node_value(value, bufnr)
117-
elseif type ~= 'comment' then
123+
elseif type ~= "comment" then
118124
break
119125
end
120126
end
121127
return variables
122-
123128
end
124129

125130
M.read_variables = function()
126131
local first = M.read_env_file()
127132
local second = M.read_dynamic_variables()
128133
local third = M.read_document_variables()
129134

130-
return vim.tbl_extend('force', first, second, third)
135+
return vim.tbl_extend("force", first, second, third)
131136
end
132137

133138
-- replace_vars replaces the env variables fields in the provided string

0 commit comments

Comments
 (0)