Skip to content

Commit 2030bf6

Browse files
committed
fix(functions): proper env variables file loading order, fixes #308
1 parent 2387bc5 commit 2030bf6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lua/rest-nvim/functions.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ function functions.exec(scope)
5555
local req_results = {}
5656

5757
if scope == "cursor" then
58+
-- Load environment variables from the env file before parsing the request
59+
env_vars.read_file(true)
60+
5861
local req = parser.parse(
5962
---@diagnostic disable-next-line param-type-mismatch
6063
parser.look_behind_until(parser.get_node_at_cursor(), "request")
@@ -65,8 +68,6 @@ function functions.exec(scope)
6568
-- Set up a _rest_nvim_req_data Lua global table that holds the parsed request
6669
-- so the values can be modified from the pre-request hooks
6770
_G._rest_nvim_req_data = req
68-
-- Load environment variables from the env file
69-
env_vars.read_file(true)
7071
-- Run pre-request hooks
7172
api.exec_pre_request_hooks()
7273
-- Clean the _rest_nvim_req_data global after running the pre-request hooks
@@ -98,8 +99,6 @@ function functions.exec(scope)
9899
-- Set up a _rest_nvim_req_data Lua global table that holds the parsed request
99100
-- so the values can be modified from the pre-request hooks
100101
_G._rest_nvim_req_data = req
101-
-- Load environment variables from the env file
102-
env_vars.read_file(true)
103102
-- Run pre-request hooks
104103
api.exec_pre_request_hooks()
105104
-- Clean the _rest_nvim_req_data global after running the pre-request hooks

0 commit comments

Comments
 (0)