Skip to content

Commit ee3f047

Browse files
committed
feat(env_vars): add a quiet parameter to read_file to decide whether to fail silently if an environment file is not found, some cleanups
1 parent 070660b commit ee3f047

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lua/rest-nvim/parser/env_vars.lua

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ local env_vars = {}
1010

1111
local utils = require("rest-nvim.utils")
1212

13-
-- NOTE: vim.loop has been renamed to vim.uv in Neovim >= 0.10 and will be removed later
14-
local uv = vim.uv or vim.loop
15-
1613
---Get the environment variables file filetype
1714
---@param env_file string The environment file path
1815
---@return string|nil
@@ -31,8 +28,10 @@ end
3128

3229
---Read the environment variables file from the rest.nvim configuration
3330
---and store all the environment variables in the `vim.env` metatable
31+
---@param quiet boolean Whether to fail silently if an environment file is not found, defaults to `false`
3432
---@see vim.env
35-
function env_vars.read_file()
33+
function env_vars.read_file(quiet)
34+
quiet = quiet or false
3635
local path = _G._rest_nvim.env_file
3736
local logger = _G._rest_nvim.logger
3837

@@ -65,8 +64,10 @@ function env_vars.read_file()
6564
vim.env[k] = v
6665
end
6766
else
68-
---@diagnostic disable-next-line need-check-nil
69-
logger:error("Current environment file '" .. path .. "' was not found in the current working directory")
67+
if not quiet then
68+
---@diagnostic disable-next-line need-check-nil
69+
logger:error("Current environment file '" .. path .. "' was not found in the current working directory")
70+
end
7071
end
7172
end
7273

0 commit comments

Comments
 (0)