mirror of
https://github.com/NotAShelf/direnv.nvim.git
synced 2025-11-25 15:02:55 +00:00
Merge b815adc8a0 into 4dfc8758a1
This commit is contained in:
commit
6b77625ecf
1 changed files with 58 additions and 36 deletions
|
|
@ -7,11 +7,11 @@ local M = {}
|
||||||
--- @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
|
||||||
--- @field statusline.icon string Icon to show in statusline
|
--- @field statusline.icon string Icon to show in statusline
|
||||||
--- @field keybindings table Keybindings configuration
|
--- @field keybindings table | boolean Keybindings configuration
|
||||||
--- @field keybindings.allow string Keybinding to allow direnv
|
--- @field keybindings.allow string | boolean Keybinding to allow direnv
|
||||||
--- @field keybindings.deny string Keybinding to deny direnv
|
--- @field keybindings.deny string | boolean Keybinding to deny direnv
|
||||||
--- @field keybindings.reload string Keybinding to reload direnv
|
--- @field keybindings.reload string | boolean Keybinding to reload direnv
|
||||||
--- @field keybindings.edit string Keybinding to edit .envrc
|
--- @field keybindings.edit string | boolean Keybinding to edit .envrc
|
||||||
--- @field notifications table Notification settings
|
--- @field notifications table Notification settings
|
||||||
--- @field notifications.level integer Log level for notifications
|
--- @field notifications.level integer Log level for notifications
|
||||||
--- @field notifications.silent_autoload boolean Don't show notifications during autoload and initialization
|
--- @field notifications.silent_autoload boolean Don't show notifications during autoload and initialization
|
||||||
|
|
@ -70,7 +70,9 @@ local function setup_keymaps(keymaps, mode)
|
||||||
{ noremap = true, silent = true },
|
{ noremap = true, silent = true },
|
||||||
map[3] or {}
|
map[3] or {}
|
||||||
)
|
)
|
||||||
vim.keymap.set(mode, map[1], map[2], options)
|
if map[1] then
|
||||||
|
vim.keymap.set(mode, map[1], map[2], options)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -445,6 +447,24 @@ end
|
||||||
--- Setup the plugin with user configuration
|
--- Setup the plugin with user configuration
|
||||||
--- @param user_config? table User configuration table
|
--- @param user_config? table User configuration table
|
||||||
M.setup = function(user_config)
|
M.setup = function(user_config)
|
||||||
|
if user_config and user_config.keybindings == true then
|
||||||
|
user_config.keybindings = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function check_bind(command)
|
||||||
|
---@diagnostic disable-next-line: need-check-nil
|
||||||
|
if user_config.keybindings[command] == true then
|
||||||
|
---@diagnostic disable-next-line: need-check-nil
|
||||||
|
user_config.keybindings[command] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if user_config and user_config.keybindings then
|
||||||
|
for k, _ in pairs(user_config.keybindings) do
|
||||||
|
check_bind(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
M.config = vim.tbl_deep_extend("force", {
|
M.config = vim.tbl_deep_extend("force", {
|
||||||
bin = "direnv",
|
bin = "direnv",
|
||||||
autoload_direnv = false,
|
autoload_direnv = false,
|
||||||
|
|
@ -520,36 +540,38 @@ M.setup = function(user_config)
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Setup keybindings
|
-- Setup keybindings
|
||||||
setup_keymaps({
|
if M.config.keybindings then
|
||||||
{
|
setup_keymaps({
|
||||||
M.config.keybindings.allow,
|
{
|
||||||
function()
|
M.config.keybindings.allow,
|
||||||
M.allow_direnv()
|
function()
|
||||||
end,
|
M.allow_direnv()
|
||||||
{ desc = "Allow direnv" },
|
end,
|
||||||
},
|
{ desc = "Allow direnv" },
|
||||||
{
|
},
|
||||||
M.config.keybindings.deny,
|
{
|
||||||
function()
|
M.config.keybindings.deny,
|
||||||
M.deny_direnv()
|
function()
|
||||||
end,
|
M.deny_direnv()
|
||||||
{ desc = "Deny direnv" },
|
end,
|
||||||
},
|
{ desc = "Deny direnv" },
|
||||||
{
|
},
|
||||||
M.config.keybindings.reload,
|
{
|
||||||
function()
|
M.config.keybindings.reload,
|
||||||
M.check_direnv()
|
function()
|
||||||
end,
|
M.check_direnv()
|
||||||
{ desc = "Reload direnv" },
|
end,
|
||||||
},
|
{ desc = "Reload direnv" },
|
||||||
{
|
},
|
||||||
M.config.keybindings.edit,
|
{
|
||||||
function()
|
M.config.keybindings.edit,
|
||||||
M.edit_envrc()
|
function()
|
||||||
end,
|
M.edit_envrc()
|
||||||
{ desc = "Edit .envrc file" },
|
end,
|
||||||
},
|
{ desc = "Edit .envrc file" },
|
||||||
}, "n")
|
},
|
||||||
|
}, "n")
|
||||||
|
end
|
||||||
|
|
||||||
-- Check for .envrc files and set up autoload
|
-- Check for .envrc files and set up autoload
|
||||||
local group_id = vim.api.nvim_create_augroup("DirenvNvim", { clear = true })
|
local group_id = vim.api.nvim_create_augroup("DirenvNvim", { clear = true })
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue