refactor(nvim): simplify lazy loading configuration
This commit is contained in:
1 parent
9c3613ce9c
commit
f117ced1dd
14 files changed
+827
-1207
No files matched your search
@@ -0,0 +1,89 @@
|
||||
--- Terminal configurations using toggleterm
|
||||
--- This module provides terminal toggle functions for various CLI tools
|
||||
--- @module config.terminals
|
||||
|
||||
local M = {}
|
||||
|
||||
--- Check if toggleterm is available
|
||||
--- @return boolean available Whether toggleterm is loaded
|
||||
local function is_toggleterm_available()
|
||||
local ok, _ = pcall(require, "toggleterm.terminal")
|
||||
return ok
|
||||
end
|
||||
|
||||
--- Initialize all terminal configurations
|
||||
--- Only runs if toggleterm is available
|
||||
function M.setup()
|
||||
if not is_toggleterm_available() then
|
||||
vim.notify("toggleterm not available, skipping terminal setup", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
local Terminal = require("toggleterm.terminal").Terminal
|
||||
|
||||
-- Claude terminal configuration
|
||||
local claude = Terminal:new({
|
||||
cmd = "claude",
|
||||
hidden = true,
|
||||
direction = "tab",
|
||||
close_on_exit = true,
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Yazi file manager terminal
|
||||
local yazi = Terminal:new({
|
||||
cmd = "yazi",
|
||||
hidden = true,
|
||||
direction = "tab",
|
||||
close_on_exit = true,
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Scooter find and replace terminal
|
||||
local scooter = Terminal:new({
|
||||
cmd = "scooter",
|
||||
hidden = true,
|
||||
direction = "vertical",
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Lazyjournal terminal
|
||||
local lazyjournal = Terminal:new({
|
||||
cmd = "lazyjournal",
|
||||
hidden = true,
|
||||
direction = "float",
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Mk (make) terminal
|
||||
local mk = Terminal:new({
|
||||
cmd = "mk",
|
||||
hidden = true,
|
||||
direction = "vertical",
|
||||
on_open = function(term)
|
||||
vim.cmd("startinsert!")
|
||||
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", { noremap = true, silent = true })
|
||||
end,
|
||||
})
|
||||
|
||||
-- Export toggle functions to module instead of global namespace
|
||||
M.claude_toggle = function() claude:toggle() end
|
||||
M.yazi_toggle = function() yazi:toggle() end
|
||||
M.scooter_toggle = function() scooter:toggle() end
|
||||
M.lazyjournal_toggle = function() lazyjournal:toggle() end
|
||||
M.mk_toggle = function() mk:toggle() end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in new issue
Block a user