mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-17 17:23:24 +02:00
feat(snacks): use terminal
This commit is contained in:
parent
45acfaacb5
commit
ad9d3d19b1
9 changed files with 77 additions and 89 deletions
|
@ -31,14 +31,6 @@ return {
|
|||
return vim.api.nvim_win_get_config(win).relative == ""
|
||||
end,
|
||||
},
|
||||
{
|
||||
ft = "lazyterm",
|
||||
title = "LazyTerm",
|
||||
size = { height = 0.4 },
|
||||
filter = function(buf)
|
||||
return not vim.b[buf].lazyterm_cmd
|
||||
end,
|
||||
},
|
||||
"Trouble",
|
||||
{ ft = "qf", title = "QuickFix" },
|
||||
{
|
||||
|
@ -103,6 +95,7 @@ return {
|
|||
end
|
||||
end
|
||||
|
||||
-- trouble
|
||||
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
|
||||
opts[pos] = opts[pos] or {}
|
||||
table.insert(opts[pos], {
|
||||
|
@ -116,6 +109,22 @@ return {
|
|||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- snacks float
|
||||
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
|
||||
opts[pos] = opts[pos] or {}
|
||||
table.insert(opts[pos], {
|
||||
ft = "snacks_terminal",
|
||||
size = { height = 0.4 },
|
||||
title = "%{b:snacks_terminal.id}: %{b:term_title}",
|
||||
filter = function(_buf, win)
|
||||
return vim.w[win].snacks_float
|
||||
and vim.w[win].snacks_float.position == pos
|
||||
and vim.w[win].snacks_float.relative == "editor"
|
||||
and not vim.w[win].trouble_preview
|
||||
end,
|
||||
})
|
||||
end
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -19,7 +19,8 @@ return {
|
|||
"fzf",
|
||||
"help",
|
||||
"lazy",
|
||||
"lazyterm",
|
||||
"snacks_terminal",
|
||||
"snacks_float",
|
||||
"mason",
|
||||
"neo-tree",
|
||||
"notify",
|
||||
|
|
|
@ -8,14 +8,14 @@ return {
|
|||
{
|
||||
"<leader>gG",
|
||||
function()
|
||||
LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false })
|
||||
Snacks.terminal({ "gitui" })
|
||||
end,
|
||||
desc = "GitUi (cwd)",
|
||||
},
|
||||
{
|
||||
"<leader>gg",
|
||||
function()
|
||||
LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false })
|
||||
Snacks.terminal({ "gitui" }, { cwd = LazyVim.root.get() })
|
||||
end,
|
||||
desc = "GitUi (Root Dir)",
|
||||
},
|
||||
|
|
|
@ -10,8 +10,35 @@ end
|
|||
|
||||
require("lazyvim.config").init()
|
||||
|
||||
-- Terminal Mappings
|
||||
local function term_nav(dir)
|
||||
---@param self snacks.terminal
|
||||
return function(self)
|
||||
return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
|
||||
vim.cmd.wincmd(dir)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
{ "folke/lazy.nvim", version = "*" },
|
||||
{ "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" },
|
||||
{ "folke/snacks.nvim", lazy = false, opts = {} },
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
---@type snacks.Config
|
||||
opts = {
|
||||
terminal = {
|
||||
float = {
|
||||
keys = {
|
||||
nav_h = { "<C-h>", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" },
|
||||
nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
|
||||
nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
|
||||
nav_l = { "<C-l>", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -254,7 +254,8 @@ return {
|
|||
"mason",
|
||||
"notify",
|
||||
"toggleterm",
|
||||
"lazyterm",
|
||||
"snacks_float",
|
||||
"snacks_terminal",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue