File tree Expand file tree Collapse file tree 5 files changed +16
-6
lines changed
Expand file tree Collapse file tree 5 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 7676 },
7777 -- Jump to request line on run
7878 jump_to_request = false ,
79+ env_file = ' .env'
7980 })
8081 end
8182}
@@ -105,12 +106,13 @@ To run `rest.nvim` you should map the following commands:
105106
106107## Settings
107108
108- - ` result_split_horizontal ` opens result on a horizontal split (default opens
109+ - ` result_split_horizontal ` opens result on a horizontal split (default opens
109110 on vertical)
110111- ` skip_ssl_verification ` passes the ` -k ` flag to cURL in order to skip SSL verification,
111112 useful when using unknown certificates
112113- ` highlight ` allows to enable and configure the highlighting of the selected request when send,
113114- ` jump_to_request ` moves the cursor to the selected request line when send,
115+ - ` env_file ` specifies file name that consist environment variables (default: .env)
114116
115117## Usage
116118
Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ function, it looks like this by default:
6363` },`
6464` -- Jump to request line on run`
6565` jump_to_request = false,`
66+ ` env_file = '.env'`
6667`})`
6768
6869In this section we will be using `https://reqres.in/` for requests.
@@ -144,8 +145,8 @@ ENVIRONMENT VARIABLES *rest-nvim-usage-environment-variables*
144145To use environment variables, the following syntax is used: `{{VARIABLE_NAME}}`
145146
146147These environment variables can be obtained from:
148+ - File in the current working directory (env_file in config or '.env')
147149 - System
148- - `.env` file in the current working directory
149150
150151
151152===============================================================================
Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ rest-nvim-license rest-nvim.txt /*rest-nvim-license*
88rest-nvim-quick-start rest-nvim.txt /*rest-nvim-quick-start*
99rest-nvim-usage rest-nvim.txt /*rest-nvim-usage*
1010rest-nvim-usage-commands rest-nvim.txt /*rest-nvim-usage-commands*
11+ rest-nvim-usage-dynamic-variables rest-nvim.txt /*rest-nvim-usage-dynamic-variables*
1112rest-nvim-usage-environment-variables rest-nvim.txt /*rest-nvim-usage-environment-variables*
13+ rest-nvim-usage-external-files rest-nvim.txt /*rest-nvim-usage-external-files*
1214rest-nvim-usage-requests rest-nvim.txt /*rest-nvim-usage-requests*
1315rest-nvim.txt rest-nvim.txt /*rest-nvim.txt*
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ local config = {
1313 show_headers = true ,
1414 },
1515 jump_to_request = false ,
16+ env_file = " .env" ,
1617}
1718
1819--- Get a configuration value
Original file line number Diff line number Diff line change 1+ local config = require (" rest-nvim.config" )
2+
13local random = math.random
24math.randomseed (os.time ())
35
@@ -45,17 +47,19 @@ M.read_file = function(file)
4547 return lines
4648end
4749
48- -- read_env_file Reads the environment variables found in the `.env` file and
49- -- returns a table with the variables
50+ -- read_env_file Reads the environment variables found in the env_file option
51+ -- (defualt: .env) specified in configuration and returns a table with the
52+ -- variables
5053M .read_env_file = function ()
5154 local variables = {}
55+ local env_file = " /" .. (config .get (" env_file" ) or " .env" )
5256
5357 -- Directories to search for env files
5458 local env_file_paths = {
5559 -- current working directory
56- vim .fn .getcwd () .. " /.env " ,
60+ vim .fn .getcwd () .. env_file ,
5761 -- directory of the currently opened file
58- vim .fn .expand (" %:p:h" ) .. " /.env " ,
62+ vim .fn .expand (" %:p:h" ) .. env_file ,
5963 }
6064
6165 -- If there's an env file in the current working dir
You can’t perform that action at this time.
0 commit comments