mirror of
https://github.com/NotAShelf/direnv.nvim.git
synced 2025-10-03 15:33:35 +00:00
let the user view .envrc before approval
This commit is contained in:
parent
4dfc8758a1
commit
e962f02437
1 changed files with 68 additions and 52 deletions
|
@ -2,7 +2,7 @@ local M = {}
|
||||||
|
|
||||||
---@class DirenvConfig
|
---@class DirenvConfig
|
||||||
---@field bin string Path to direnv executable
|
---@field bin string Path to direnv executable
|
||||||
--- @field autoload_direnv boolean Automatically load direnv when opening files
|
---@field autoload_direnv boolean|string Automatically load direnv when opening files. true/false or "confirm" to show file first
|
||||||
---@field cache_ttl integer Cache TTL in milliseconds for direnv status checks
|
---@field cache_ttl integer Cache TTL in milliseconds for direnv status checks
|
||||||
---@field statusline table Configuration for statusline integration
|
---@field statusline table Configuration for statusline integration
|
||||||
---@field statusline.enabled boolean Enable statusline integration
|
---@field statusline.enabled boolean Enable statusline integration
|
||||||
|
@ -405,6 +405,21 @@ M.check_direnv = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Status 1 means the .envrc file needs approval
|
-- Status 1 means the .envrc file needs approval
|
||||||
|
if M.config.autoload_direnv == "confirm" then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd("edit " .. path)
|
||||||
|
vim.defer_fn(function()
|
||||||
|
local choice = vim.fn.confirm(
|
||||||
|
"Load environment from " .. path .. "?",
|
||||||
|
"&Yes\n&No",
|
||||||
|
1
|
||||||
|
)
|
||||||
|
if choice == 1 then
|
||||||
|
M.allow_direnv()
|
||||||
|
end
|
||||||
|
end, 100)
|
||||||
|
end)
|
||||||
|
else
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
local choice = vim.fn.confirm(
|
local choice = vim.fn.confirm(
|
||||||
path .. " is not allowed by direnv. What would you like to do?",
|
path .. " is not allowed by direnv. What would you like to do?",
|
||||||
|
@ -420,6 +435,7 @@ M.check_direnv = function()
|
||||||
-- Ignore means do nothing
|
-- Ignore means do nothing
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
M._get_rc_status(on_exit)
|
M._get_rc_status(on_exit)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue