term: terminal now handled to outside runtime
This commit is contained in:
parent
3fd8bf1070
commit
8aecd13324
|
@ -6,36 +6,10 @@ require "config.neovide"
|
|||
|
||||
vim.keymap.set("t", "<c-d>", "<C-\\><C-n>", { silent = true, desc = "Exit Terminal Mode" })
|
||||
|
||||
if vim.env.ZELLIJ ~= nil then
|
||||
vim.keymap.set("n", "<leader>z", function()
|
||||
local cwd = vim.fn.expand "%:p:h"
|
||||
vim.system {
|
||||
"zellij",
|
||||
"run",
|
||||
"--close-on-exit",
|
||||
"--cwd",
|
||||
cwd,
|
||||
"--in-place",
|
||||
"--",
|
||||
"lazygit",
|
||||
}
|
||||
end, { desc = "Open Lazygit (Zellij)" })
|
||||
elseif vim.fn.executable "hyprctl" == 1 and vim.fn.executable "footclient" == 1 then
|
||||
vim.keymap.set("n", "<leader>z", function()
|
||||
local cwd = vim.fn.expand "%:p:h"
|
||||
vim.system {
|
||||
"hyprctl",
|
||||
"dispatch",
|
||||
"exec",
|
||||
"--",
|
||||
"foot",
|
||||
"--app-id=lazygit",
|
||||
"--title=lazygit",
|
||||
"--working-directory=" .. cwd,
|
||||
"--",
|
||||
"lazygit",
|
||||
}
|
||||
end, { desc = "Open Lazygit (Foot)" })
|
||||
if vim.fn.executable "lazygit" == 1 then
|
||||
require "config.lazygit"
|
||||
end
|
||||
|
||||
vim.keymap.set("n", "<F5>", [[<cmd>silent !footclient --no-wait<cr>]], { desc = "Open New terminal" })
|
||||
if vim.fn.executable "hyprctl" == 1 and vim.fn.executable "footclient" == 1 then
|
||||
require "config.terminal"
|
||||
end
|
||||
|
|
31
lua/config/lazygit.lua
Normal file
31
lua/config/lazygit.lua
Normal file
|
@ -0,0 +1,31 @@
|
|||
if vim.env.ZELLIJ ~= nil and not vim.g.neovide then
|
||||
-- currently running inside zellij session and not inside neovide
|
||||
vim.keymap.set("n", "<leader>z", function()
|
||||
local cwd = vim.fn.expand "%:p:h"
|
||||
vim.system {
|
||||
"zellij",
|
||||
"run",
|
||||
"--close-on-exit",
|
||||
"--cwd",
|
||||
cwd,
|
||||
"--in-place",
|
||||
"--",
|
||||
"lazygit",
|
||||
}
|
||||
end, { desc = "Open Lazygit (Zellij)" })
|
||||
elseif vim.fn.executable "hyprctl" == 1 and vim.fn.executable "foot" == 1 then
|
||||
vim.keymap.set("n", "<leader>z", function()
|
||||
vim.system {
|
||||
"hyprctl",
|
||||
"dispatch",
|
||||
"exec",
|
||||
"--",
|
||||
"foot",
|
||||
"--app-id=lazygit",
|
||||
"--title=lazygit",
|
||||
"--working-directory=" .. vim.fn.getcwd(),
|
||||
"--",
|
||||
"lazygit",
|
||||
}
|
||||
end, { desc = "Open Lazygit (Foot)" })
|
||||
end
|
44
lua/config/terminal.lua
Normal file
44
lua/config/terminal.lua
Normal file
|
@ -0,0 +1,44 @@
|
|||
local session_id = math.random(1, 100000)
|
||||
local app_id = ([[neovim-terminal-%d]]):format(session_id)
|
||||
local class = ([[class:%s]]):format(app_id)
|
||||
|
||||
vim.keymap.set("n", "<F5>", function()
|
||||
vim.system({ "hyprctl", "clients", "-j" }, { text = true }, function(output)
|
||||
for _, client in ipairs(vim.json.decode(output.stdout)) do
|
||||
if client.class == app_id then
|
||||
-- focus instead of open new
|
||||
vim.system { "hyprctl", "dispatch", "focuswindow", class }
|
||||
return
|
||||
end
|
||||
end
|
||||
vim.schedule(function()
|
||||
vim.system({
|
||||
"hyprctl",
|
||||
"dispatch",
|
||||
"exec",
|
||||
"--",
|
||||
"footclient",
|
||||
"--working-directory",
|
||||
vim.fn.getcwd(),
|
||||
"--app-id",
|
||||
app_id,
|
||||
"--title=neovim-terminal",
|
||||
}, {}, function()
|
||||
vim.defer_fn(function()
|
||||
vim.system {
|
||||
"hyprctl",
|
||||
"dispatch",
|
||||
"resizewindowpixel",
|
||||
([[exact 80%% 100%%,%s]]):format(class),
|
||||
}
|
||||
end, 50)
|
||||
end)
|
||||
vim.api.nvim_create_autocmd("VimLeave", {
|
||||
pattern = "*",
|
||||
callback = function()
|
||||
vim.system { "hyprctl", "dispatch", "closewindow", class }
|
||||
end,
|
||||
})
|
||||
end)
|
||||
end)
|
||||
end, { desc = "Open New terminal" })
|
Loading…
Reference in a new issue