feat: switch from lazy to vim.pack

This commit is contained in:
2026-04-10 14:42:25 +02:00
parent 190b3ecebd
commit 28c45c8390
35 changed files with 1168 additions and 1455 deletions
+81 -89
View File
@@ -1,96 +1,88 @@
---@type LazyPluginSpec
return {
"saghen/blink.cmp",
-- use a release tag to download pre-built binaries
version = "1.*",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
completion = {
documentation = {
auto_show = true,
window = {
winhighlight = "",
},
},
ghost_text = {
enabled = true,
},
list = {
selection = {
preselect = false,
auto_insert = false,
},
},
menu = {
border = "none",
draw = {
align_to = "simple_label",
columns = {
{ "simple_label" },
{ "kind_icon", "label_description", gap = 1 },
},
components = {
simple_label = {
width = { fill = true, max = 60 },
text = function(ctx)
return ctx.label
end,
highlight = function(ctx)
local highlights = {
{
0,
#ctx.label,
group = ctx.deprecated
and "BlinkCmpLabelDeprecated"
or "BlinkCmpLabel",
},
}
for _, idx in ipairs(ctx.label_matched_indices) do
table.insert(highlights, {
idx,
idx + 1,
group = "BlinkCmpLabelMatch",
})
end
return highlights
end,
},
},
},
},
},
fuzzy = {
implementation = "prefer_rust_with_warning",
},
signature = {
enabled = true,
require("blink.cmp").setup({
completion = {
documentation = {
auto_show = true,
window = {
winhighlight = "",
show_documentation = false,
},
},
sources = {
default = {
"lsp",
"path",
},
transform_items = function(_, items)
return vim.tbl_filter(function(item)
return item.kind
~= require("blink.cmp.types").CompletionItemKind.Snippet
end, items)
end,
ghost_text = {
enabled = true,
},
keymap = {
preset = "none",
["<Tab>"] = { "insert_next", "fallback" },
["<S-Tab>"] = { "insert_prev", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<C-k>"] = { "show_signature", "hide_signature", "fallback" },
["<C-n>"] = { "snippet_forward", "fallback" },
["<C-p>"] = { "snippet_backward", "fallback" },
list = {
selection = {
preselect = false,
auto_insert = false,
},
},
menu = {
border = "none",
draw = {
align_to = "simple_label",
columns = {
{ "simple_label" },
{ "kind_icon", "label_description", gap = 1 },
},
components = {
simple_label = {
width = { fill = true, max = 60 },
text = function(ctx)
return ctx.label
end,
highlight = function(ctx)
local highlights = {
{
0,
#ctx.label,
group = ctx.deprecated
and "BlinkCmpLabelDeprecated"
or "BlinkCmpLabel",
},
}
for _, idx in ipairs(ctx.label_matched_indices) do
table.insert(highlights, {
idx,
idx + 1,
group = "BlinkCmpLabelMatch",
})
end
return highlights
end,
},
},
},
},
},
}
fuzzy = {
implementation = "prefer_rust_with_warning",
},
signature = {
enabled = true,
window = {
winhighlight = "",
show_documentation = false,
},
},
sources = {
default = {
"lsp",
"path",
},
transform_items = function(_, items)
return vim.tbl_filter(function(item)
return item.kind
~= require("blink.cmp.types").CompletionItemKind.Snippet
end, items)
end,
},
keymap = {
preset = "none",
["<Tab>"] = { "insert_next", "fallback" },
["<S-Tab>"] = { "insert_prev", "fallback" },
["<CR>"] = { "accept", "fallback" },
["<C-k>"] = { "show_signature", "hide_signature", "fallback" },
["<C-n>"] = { "snippet_forward", "fallback" },
["<C-p>"] = { "snippet_backward", "fallback" },
},
})
+5 -11
View File
@@ -1,11 +1,5 @@
-- https://github.com/numToStr/Comment.nvim
---@type LazyPluginSpec
return {
"numToStr/Comment.nvim",
event = "VeryLazy",
opts = {
--ignore empty lines
ignore = "^$",
},
}
---@diagnostic disable-next-line: missing-fields
require("Comment").setup({
--ignore empty lines
ignore = "^$",
})
+1 -9
View File
@@ -1,9 +1 @@
-- https://github.com/j-hui/fidget.nvim
---@type LazyPluginSpec
return {
"j-hui/fidget.nvim",
tag = "legacy",
event = "LspAttach",
config = true,
}
require("fidget").setup()
-10
View File
@@ -1,10 +0,0 @@
-- https://github.com/rbong/vim-flog
---@type LazyPluginSpec
return {
"rbong/vim-flog",
---@type LazyKeysSpec[]
keys = {
{ "<leader>gl", vim.cmd.Flog, mode = "n" },
},
}
-99
View File
@@ -1,99 +0,0 @@
-- https://github.com/tpope/vim-fugitive
local function open_git_status()
local previous_win = vim.api.nvim_get_current_win()
vim.cmd("leftabove vertical G")
vim.api.nvim_win_set_width(0, 50)
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
vim.api.nvim_set_current_win(previous_win)
end
local function get_git_status_win()
local current_tabpage = vim.api.nvim_get_current_tabpage()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
local buf = vim.api.nvim_win_get_buf(win)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if
buftype == "nowrite"
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
then
return win
end
end
end
local function toggle_git_status()
local win = get_git_status_win()
if win then
vim.api.nvim_win_close(win, false)
return
end
open_git_status()
end
---@type LazyPluginSpec
return {
"tpope/vim-fugitive",
event = "VeryLazy",
---@type LazyKeysSpec[]
keys = {
{
"<leader>gd",
vim.cmd.Gvdiffsplit,
mode = "n",
},
{
"<leader>gD",
function()
vim.cmd.Gvdiffsplit("HEAD")
end,
mode = "n",
},
{
"<leader>gh",
vim.cmd.Ghdiffsplit,
mode = "n",
},
{
"<leader>gH",
function()
vim.cmd.Ghdiffsplit("HEAD")
end,
mode = "n",
},
{
"<leader>gc",
function()
vim.cmd.G("commit")
end,
mode = "n",
},
{
"<leader>ga",
function()
vim.cmd.G("commit --amend")
end,
mode = "n",
},
{
"<leader>gp",
function()
vim.cmd.G("push")
end,
mode = "n",
},
{
"<leader>gg",
toggle_git_status,
mode = "n",
},
},
config = function()
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
vim.fn["fugitive#ReloadStatus"]()
end,
})
end,
}
+57 -64
View File
@@ -1,65 +1,58 @@
-- https://github.com/lewis6991/gitsigns.nvim
---@type LazyPluginSpec
return {
"lewis6991/gitsigns.nvim",
event = "VeryLazy",
opts = {
preview_config = {
border = "single",
},
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set(
"n",
"<leader>gv",
gs.select_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr })
vim.keymap.set("x", "<leader>gs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { buffer = bufnr })
vim.keymap.set(
{ "n", "x" },
"<leader>gu",
gs.undo_stage_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>g?",
gs.preview_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gb", function()
gs.blame_line({ full = true, ignore_whitespace = true })
end, { buffer = bufnr })
vim.keymap.set({ "n", "x" }, "]g", function()
gs.next_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
vim.keymap.set({ "n", "x" }, "[g", function()
gs.prev_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
end,
attach_to_untracked = true,
sign_priority = 100,
require("gitsigns").setup({
preview_config = {
border = "single",
},
}
on_attach = function(bufnr)
local gs = package.loaded.gitsigns
vim.keymap.set(
"n",
"<leader>gv",
gs.select_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gs", gs.stage_hunk, { buffer = bufnr })
vim.keymap.set("x", "<leader>gs", function()
gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end, { buffer = bufnr })
vim.keymap.set(
{ "n", "x" },
"<leader>gu",
gs.undo_stage_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gr", gs.reset_hunk, { buffer = bufnr })
vim.keymap.set(
"x",
"<leader>gr",
":Gitsigns reset_hunk<CR>",
{ buffer = bufnr }
)
vim.keymap.set(
"n",
"<leader>g?",
gs.preview_hunk,
{ buffer = bufnr }
)
vim.keymap.set("n", "<leader>gb", function()
gs.blame_line({ full = true, ignore_whitespace = true })
end, { buffer = bufnr })
vim.keymap.set({ "n", "x" }, "]g", function()
gs.next_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
vim.keymap.set({ "n", "x" }, "[g", function()
gs.prev_hunk({
wrap = true,
navigation_message = true,
foldopen = true,
preview = true,
})
end)
end,
attach_to_untracked = true,
sign_priority = 100,
})
+1 -5
View File
@@ -1,5 +1 @@
---@type LazyPluginSpec
return {
"MagicDuck/grug-far.nvim",
config = true,
}
require("grug-far").setup()
-5
View File
@@ -1,5 +0,0 @@
---@type LazyPluginSpec
return {
"neovim/nvim-lspconfig",
config = require("lsp").setup,
}
+50 -58
View File
@@ -1,60 +1,52 @@
---@type LazyPluginSpec
return {
"owallb/mason-auto-install.nvim",
dependencies = {
"neovim/nvim-lspconfig",
},
---@type MasonAutoInstall.Config
opts = {
packages = {
{
"bash-language-server",
dependencies = { "shellcheck", "shfmt" },
},
-- "clangd",
{
"cmake-language-server",
dependencies = { "golines" },
},
"gopls",
"hyprls",
{
"intelephense",
dependencies = { "phpcs" },
},
"jedi-language-server",
{
"lemminx",
dependencies = { "xmlformatter" },
},
"lua-language-server",
"mesonlsp",
"oxfmt",
"oxlint",
"ruff",
"pyright",
"pyrefly",
{
"prettier",
filetypes = {
"json",
"jsonc",
"markdown",
"html",
"css",
"scss",
"less",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
},
"rust-analyzer",
"svelte-language-server",
"tailwindcss-language-server",
"tsgo",
"zls",
require("mason-auto-install").setup({
packages = {
{
"bash-language-server",
dependencies = { "shellcheck", "shfmt" },
},
-- "clangd",
{
"cmake-language-server",
dependencies = { "golines" },
},
"gopls",
"hyprls",
{
"intelephense",
dependencies = { "phpcs" },
},
"jedi-language-server",
{
"lemminx",
dependencies = { "xmlformatter" },
},
"lua-language-server",
"mesonlsp",
"oxfmt",
"oxlint",
"ruff",
"pyright",
"pyrefly",
{
"prettier",
filetypes = {
"json",
"jsonc",
"markdown",
"html",
"css",
"scss",
"less",
"javascript",
"javascriptreact",
"typescript",
"typescriptreact",
},
},
"rust-analyzer",
"svelte-language-server",
"tailwindcss-language-server",
"tsgo",
"zls",
},
}
})
+1 -8
View File
@@ -1,8 +1 @@
-- https://github.com/williamboman/mason.nvim
---@type LazyPluginSpec
return {
"williamboman/mason.nvim",
event = "VeryLazy",
config = true,
}
require("mason").setup()
-17
View File
@@ -1,17 +0,0 @@
-- https://github.com/rcarriga/nvim-notify
---@type LazyPluginSpec
return {
"rcarriga/nvim-notify",
priority = 900,
lazy = false,
opts = {
render = "default",
stages = "static",
},
config = function(_, opts)
---@type notify
vim.notify = require("notify")
vim.notify.setup(opts)
end,
}
-19
View File
@@ -1,19 +0,0 @@
-- https://github.com/NvChad/nvim-colorizer.lua
---@type LazyPluginSpec
return {
"NvChad/nvim-colorizer.lua",
enabled = false,
opts = {
user_default_options = {
names = false,
RGB = false,
RRGGBB = true,
RRGGBBAA = true,
AARRGGBB = true,
rgb_fn = true,
hsl_fn = true,
mode = "virtualtext",
},
},
}
-93
View File
@@ -1,93 +0,0 @@
-- https://github.com/igorlfs/nvim-dap-view
---@type LazyPluginSpec
return {
"rcarriga/nvim-dap-ui",
dependencies = { "mfussenegger/nvim-dap", "nvim-neotest/nvim-nio" },
keys = {
{
"<Leader>du",
function()
require("dapui").toggle()
end,
},
{
"<Leader>de",
function()
---@diagnostic disable-next-line: missing-fields
require("dapui").eval(nil, { context = "hover", enter = true })
end,
mode = { "x", "n" },
},
{
"<Leader>dw",
function()
require("dapui").elements.watches.add(vim.fn.expand("<cexpr>"))
end,
},
},
opts = {
controls = {
element = "repl",
enabled = false,
},
expand_lines = true,
floating = {
border = "single",
mappings = {
close = { "q", "<Esc>" },
},
},
force_buffers = true,
icons = {
collapsed = "+",
current_frame = "*",
expanded = "-",
},
layouts = {
{
elements = {
{
id = "scopes",
size = 0.25,
},
{
id = "breakpoints",
size = 0.25,
},
{
id = "stacks",
size = 0.25,
},
{
id = "watches",
size = 0.25,
},
},
position = "right",
size = 50,
},
{
elements = {
{
id = "repl",
},
},
position = "bottom",
size = 15,
},
},
mappings = {
edit = "e",
expand = { "<CR>", "<2-LeftMouse>", "<Tab>" },
open = "o",
remove = "d",
repl = "r",
toggle = "t",
},
render = {
indent = 1,
max_value_lines = 100,
},
},
}
+3
View File
@@ -0,0 +1,3 @@
local dap_view = require("dap-view")
dap_view.setup()
vim.keymap.set("n", "<Leader>du", dap_view.toggle)
+141 -206
View File
@@ -1,217 +1,152 @@
-- https://github.com/mfussenegger/nvim-dap
local hover = require("dap.hover")
local log = require("log")
local dap = require("dap")
---@type LazyPluginSpec
return {
"mfussenegger/nvim-dap",
lazy = false,
keys = {
{
"<Leader>db",
function()
require("dap").toggle_breakpoint()
end,
},
{
"<Leader>df",
function()
require("dap").focus_frame()
end,
},
{
"<PageUp>",
function()
require("dap").up()
end,
},
{
"<PageDown>",
function()
require("dap").down()
end,
},
{
"<Leader>dh",
hover,
mode = { "n", "x" },
},
{
"<Leader>dr",
function()
require("dap").repl.toggle()
end,
mode = { "n", "x" },
},
{
"<F2>",
function()
require("dap").step_into()
end,
},
{
"<F3>",
function()
require("dap").step_over()
end,
},
{
"<F4>",
function()
require("dap").step_out()
end,
},
{
"<F5>",
function()
require("dap").continue()
end,
},
{
"<F9>",
function()
require("dap").terminate()
end,
},
},
config = function()
local dap = require("dap")
vim.api.nvim_set_hl(0, "DebugPC", {
bg = "NONE",
fg = "NONE",
})
vim.api.nvim_set_hl(0, "DebugPC", {
bg = "NONE",
fg = "NONE",
})
vim.api.nvim_create_user_command(
"Debug",
---@param opts vim.api.keyset.create_user_command.command_args
function(opts)
local cfgs = dap.configurations[vim.bo.filetype]
if not cfgs then
log.error(
"No configurations available for filetype %s",
vim.bo.filetype
)
return
end
vim.api.nvim_create_user_command(
"Debug",
---@param opts vim.api.keyset.create_user_command.command_args
function(opts)
local cfgs = dap.configurations[vim.bo.filetype]
if not cfgs then
log.error(
"No configurations available for filetype %s",
vim.bo.filetype
)
return
end
local function run_config(cfg)
local all_args = vim.fn.split(opts.args)
cfg.program = all_args[1]
local function run_config(cfg)
local all_args = vim.fn.split(opts.args)
cfg.program = all_args[1]
local args = {}
for i = 2, #all_args do
table.insert(args, all_args[i])
end
cfg.args = args
local args = {}
for i = 2, #all_args do
table.insert(args, all_args[i])
end
cfg.args = args
dap.run(cfg)
end
dap.run(cfg)
end
if #cfgs == 1 then
run_config(cfgs[1])
return
end
if #cfgs == 1 then
run_config(cfgs[1])
return
end
local names = {}
for _, c in ipairs(cfgs) do
table.insert(names, c.name)
end
local names = {}
for _, c in ipairs(cfgs) do
table.insert(names, c.name)
end
vim.ui.select(names, {
prompt = "Select DAP configuration to use:",
}, function(choice, idx)
if choice and idx then
run_config(cfgs[idx])
end
end)
end,
{
nargs = "+",
---@param ArgLead string
---@param CmdLine string
complete = function(ArgLead, CmdLine, CursorPos)
local _, spaces = CmdLine:sub(1, CursorPos):gsub("%s+", "")
if spaces == 1 then
return vim.fn.getcompletion(ArgLead, "file")
end
end,
}
)
-- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap" },
}
dap.adapters.lldb = {
type = "executable",
command = "lldb-dap",
}
dap.adapters.python = {
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.c = {
{
type = "gdb",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
-- dap.configurations.c = {
-- {
-- type = "lldb",
-- request = "launch",
-- name = "Launch",
-- program = function()
-- local path = vim.fn.input({
-- prompt = "Path to executable: ",
-- default = vim.fn.getcwd() .. "/",
-- completion = "file",
-- })
-- return (path and path ~= "") and path or dap.ABORT
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- console = "internalConsole",
-- },
-- }
dap.configurations.cpp = dap.configurations.c
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
},
}
vim.ui.select(names, {
prompt = "Select DAP configuration to use:",
}, function(choice, idx)
if choice and idx then
run_config(cfgs[idx])
end
end)
end,
{
nargs = "+",
---@param ArgLead string
---@param CmdLine string
complete = function(ArgLead, CmdLine, CursorPos)
local _, spaces = CmdLine:sub(1, CursorPos):gsub("%s+", "")
if spaces == 1 then
return vim.fn.getcompletion(ArgLead, "file")
end
end,
}
)
-- https://sourceware.org/gdb/current/onlinedocs/gdb#Debugger-Adapter-Protocol
dap.adapters.gdb = {
type = "executable",
command = "gdb",
args = { "--interpreter=dap" },
}
dap.adapters.lldb = {
type = "executable",
command = "lldb-dap",
}
dap.adapters.python = {
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.c = {
{
type = "gdb",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
stopAtBeginningOfMainSubprogram = false,
},
}
-- dap.configurations.c = {
-- {
-- type = "lldb",
-- request = "launch",
-- name = "Launch",
-- program = function()
-- local path = vim.fn.input({
-- prompt = "Path to executable: ",
-- default = vim.fn.getcwd() .. "/",
-- completion = "file",
-- })
-- return (path and path ~= "") and path or dap.ABORT
-- end,
-- cwd = "${workspaceFolder}",
-- stopAtBeginningOfMainSubprogram = false,
-- console = "internalConsole",
-- },
-- }
dap.configurations.cpp = dap.configurations.c
dap.configurations.python = {
{
type = "python",
request = "launch",
name = "Launch",
program = function()
local path = vim.fn.input({
prompt = "Path to executable: ",
default = vim.fn.getcwd() .. "/",
completion = "file",
})
return (path and path ~= "") and path or dap.ABORT
end,
cwd = "${workspaceFolder}",
},
}
vim.keymap.set("n", "<Leader>db", dap.toggle_breakpoint)
vim.keymap.set("n", "<Leader>df", dap.focus_frame)
vim.keymap.set("n", "<PageUp>", dap.up)
vim.keymap.set("n", "<PageDown>", dap.down)
vim.keymap.set({ "n", "x" }, "<Leader>dh", require("dap.hover"))
vim.keymap.set({ "n", "x" }, "<Leader>dr", dap.repl.toggle)
vim.keymap.set("n", "<F2>", dap.step_into)
vim.keymap.set("n", "<F3>", dap.step_over)
vim.keymap.set("n", "<F4>", dap.step_out)
vim.keymap.set("n", "<F5>", dap.continue)
vim.keymap.set("n", "<F9>", dap.terminate)
+1
View File
@@ -0,0 +1 @@
require("lsp").setup()
+6
View File
@@ -0,0 +1,6 @@
vim.notify = require("notify")
---@diagnostic disable-next-line: missing-fields
vim.notify.setup({
render = "default",
stages = "static",
})
+207 -231
View File
@@ -34,241 +34,217 @@ local function disable_highlights()
})
end
---@type LazyPluginSpec
return {
"nvim-tree/nvim-tree.lua",
dependencies = {
"tpope/vim-fugitive",
"nvim-tree/nvim-web-devicons",
},
event = "VimEnter",
keys = {
{
"<leader>tt",
function()
require("nvim-tree.api").tree.toggle({
find_file = true,
focus = false,
})
end,
},
{
"ga",
function()
require("nvim-tree.api").tree.open()
end,
},
},
config = function()
---@class nvim_tree.api.decorator.UserDecorator
local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
vim.keymap.set("n", "<leader>tt", function()
require("nvim-tree.api").tree.toggle({ find_file = true, focus = false, })
end)
---@class GitIgnoreDecorator: nvim_tree.api.decorator.UserDecorator
local GitIgnoreDecorator = UserDecorator:extend()
---@class nvim_tree.api.decorator.UserDecorator
local UserDecorator = require("nvim-tree.api").decorator.UserDecorator
function GitIgnoreDecorator:new()
self.enabled = true
self.highlight_range = "name"
self.icon_placement = "none"
self.file_hl = "NvimTreeGitFileIgnoredHL"
self.folder_hl = "NvimTreeGitFolderIgnoredHL"
---@class GitIgnoreDecorator: nvim_tree.api.decorator.UserDecorator
local GitIgnoreDecorator = UserDecorator:extend()
function GitIgnoreDecorator:new()
self.enabled = true
self.highlight_range = "name"
self.icon_placement = "none"
self.file_hl = "NvimTreeGitFileIgnoredHL"
self.folder_hl = "NvimTreeGitFolderIgnoredHL"
end
---@param node Node
---@return string? highlight_group
function GitIgnoreDecorator:highlight_group(node)
local status = node.git_status
if not status then
return
end
if status.file == "!!" then
return self.file_hl
elseif status.dir and status.dir.direct == "!!" then
return self.folder_hl
end
end
local signs = require("lsp").diagnostic_signs
require("nvim-tree").setup({
on_attach = function(bufnr)
local function opts(desc)
return {
desc = "nvim-tree: " .. desc,
buffer = bufnr,
noremap = true,
silent = true,
nowait = true,
}
end
---@param node Node
---@return string? highlight_group
function GitIgnoreDecorator:highlight_group(node)
local status = node.git_status
if not status then
return
end
local api = require("nvim-tree.api")
api.config.mappings.default_on_attach(bufnr)
if status.file == "!!" then
return self.file_hl
elseif status.dir and status.dir.direct == "!!" then
return self.folder_hl
end
end
vim.keymap.del("n", "D", { buffer = bufnr })
vim.keymap.del("n", "bt", { buffer = bufnr })
local signs = require("lsp").diagnostic_signs
require("nvim-tree").setup({
on_attach = function(bufnr)
local function opts(desc)
return {
desc = "nvim-tree: " .. desc,
buffer = bufnr,
noremap = true,
silent = true,
nowait = true,
}
end
local api = require("nvim-tree.api")
api.config.mappings.default_on_attach(bufnr)
vim.keymap.del("n", "D", { buffer = bufnr })
vim.keymap.del("n", "bt", { buffer = bufnr })
vim.keymap.set("n", "d", api.fs.trash, opts("Trash"))
vim.keymap.set(
"n",
"bd",
api.marks.bulk.trash,
opts("Trash Bookmarked")
)
vim.keymap.set("n", "<C-l>", api.node.open.edit, opts("Open"))
vim.keymap.set(
"n",
"<C-h>",
api.node.navigate.parent_close,
opts("Close Directory")
)
end,
hijack_cursor = true,
hijack_netrw = false,
view = {
width = 50,
preserve_window_proportions = true,
},
renderer = {
full_name = true,
root_folder_label = function(path)
local label = vim.fn.fnamemodify(path, ":~")
local git_head = vim.fn.FugitiveHead()
if git_head ~= "" then
label = label .. ("  %s"):format(git_head)
end
return label
end,
special_files = {},
decorators = {
"Git",
GitIgnoreDecorator,
"Open",
"Modified",
"Bookmark",
"Diagnostics",
"Copied",
"Cut",
},
highlight_modified = "icon",
highlight_bookmarks = "name",
highlight_clipboard = "all",
indent_markers = {
enable = true,
icons = {
corner = "",
none = "",
},
},
icons = {
git_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "after",
symlink_arrow = " -> ",
show = {
file = true,
folder = true,
folder_arrow = false,
bookmarks = false,
},
web_devicons = {
file = {
color = false,
},
},
glyphs = {
modified = "*",
git = {
unstaged = "M",
staged = "M",
unmerged = "!",
renamed = "R",
untracked = "?",
deleted = "D",
ignored = " ",
},
},
},
},
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
icons = {
hint = signs.text[vim.diagnostic.severity.HINT],
info = signs.text[vim.diagnostic.severity.INFO],
warning = signs.text[vim.diagnostic.severity.WARN],
error = signs.text[vim.diagnostic.severity.ERROR],
},
},
modified = {
enable = true,
},
filters = {
git_ignored = false,
custom = { "^\\.git$" },
},
live_filter = {
prefix = "Filter: ",
always_show_folders = false,
},
filesystem_watchers = {
enable = true,
},
actions = {
use_system_clipboard = false,
change_dir = {
enable = false,
},
expand_all = {
exclude = { ".venv", "build" },
},
open_file = {
window_picker = {
enable = false,
},
},
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
help = {
sort_by = "desc",
},
sync_root_with_cwd = true,
git = {
show_on_open_dirs = false,
},
})
override_highlights()
disable_highlights()
vim.api.nvim_create_autocmd("QuitPre", {
callback = function()
local tree_wins = {}
local floating_wins = {}
local wins = vim.api.nvim_list_wins()
for _, w in ipairs(wins) do
local bufname =
vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
if bufname:match("NvimTree_") ~= nil then
table.insert(tree_wins, w)
end
if vim.api.nvim_win_get_config(w).relative ~= "" then
table.insert(floating_wins, w)
end
end
if 1 == #wins - #floating_wins - #tree_wins then
-- Should quit, so we close all invalid windows.
for _, w in ipairs(tree_wins) do
vim.api.nvim_win_close(w, true)
end
end
end,
})
vim.keymap.set("n", "d", api.fs.trash, opts("Trash"))
vim.keymap.set(
"n",
"bd",
api.marks.bulk.trash,
opts("Trash Bookmarked")
)
vim.keymap.set("n", "<C-l>", api.node.open.edit, opts("Open"))
vim.keymap.set(
"n",
"<C-h>",
api.node.navigate.parent_close,
opts("Close Directory")
)
end,
}
hijack_cursor = true,
hijack_netrw = false,
view = {
width = 50,
preserve_window_proportions = true,
},
renderer = {
full_name = true,
root_folder_label = function(path)
local label = vim.fn.fnamemodify(path, ":~")
local git_head = vim.fn.FugitiveHead()
if git_head ~= "" then
label = label .. ("  %s"):format(git_head)
end
return label
end,
special_files = {},
decorators = {
"Git",
GitIgnoreDecorator,
"Open",
"Modified",
"Bookmark",
"Diagnostics",
"Copied",
"Cut",
},
highlight_modified = "icon",
highlight_bookmarks = "name",
highlight_clipboard = "all",
indent_markers = {
enable = true,
icons = {
corner = "",
none = "",
},
},
icons = {
git_placement = "after",
diagnostics_placement = "signcolumn",
bookmarks_placement = "after",
symlink_arrow = " -> ",
show = {
file = true,
folder = true,
folder_arrow = false,
bookmarks = false,
},
web_devicons = {
file = {
color = false,
},
},
glyphs = {
modified = "*",
git = {
unstaged = "M",
staged = "M",
unmerged = "!",
renamed = "R",
untracked = "?",
deleted = "D",
ignored = " ",
},
},
},
},
update_focused_file = {
enable = true,
},
diagnostics = {
enable = true,
show_on_dirs = true,
icons = {
hint = signs.text[vim.diagnostic.severity.HINT],
info = signs.text[vim.diagnostic.severity.INFO],
warning = signs.text[vim.diagnostic.severity.WARN],
error = signs.text[vim.diagnostic.severity.ERROR],
},
},
modified = {
enable = true,
},
filters = {
git_ignored = false,
custom = { "^\\.git$" },
},
live_filter = {
prefix = "Filter: ",
always_show_folders = false,
},
filesystem_watchers = {
enable = true,
},
actions = {
use_system_clipboard = false,
change_dir = {
enable = false,
},
expand_all = {
exclude = { ".venv", "build" },
},
open_file = {
window_picker = {
enable = false,
},
},
},
notify = {
threshold = vim.log.levels.WARN,
absolute_path = false,
},
help = {
sort_by = "desc",
},
sync_root_with_cwd = true,
git = {
show_on_open_dirs = false,
},
})
override_highlights()
disable_highlights()
vim.api.nvim_create_autocmd("QuitPre", {
callback = function()
local tree_wins = {}
local floating_wins = {}
local wins = vim.api.nvim_list_wins()
for _, w in ipairs(wins) do
local bufname =
vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
if bufname:match("NvimTree_") ~= nil then
table.insert(tree_wins, w)
end
if vim.api.nvim_win_get_config(w).relative ~= "" then
table.insert(floating_wins, w)
end
end
if 1 == #wins - #floating_wins - #tree_wins then
-- Should quit, so we close all invalid windows.
for _, w in ipairs(tree_wins) do
vim.api.nvim_win_close(w, true)
end
end
end,
})
+36 -45
View File
@@ -1,7 +1,6 @@
-- https://github.com/nvim-treesitter/nvim-treesitter
local log = require("log")
local languages = {
"dap_repl",
"bash",
"zsh",
"python",
@@ -23,54 +22,46 @@ local languages = {
"markdown",
"go",
"svelte",
{ "scss", extra_ft = { "css" } },
"scss",
"tsx",
"typescript",
"yaml",
}
---@type LazyPluginSpec
return {
"nvim-treesitter/nvim-treesitter",
lazy = false,
build = function()
local ts = require("nvim-treesitter")
ts.install(languages):await(ts.update)
end,
dependencies = {
{
"LiadOz/nvim-dap-repl-highlights",
config = true,
},
},
config = function()
local ts = require("nvim-treesitter")
ts.install(languages):await(function()
local filetypes = {}
for i, value in ipairs(languages) do
local lang = value
if type(value) == "table" then
lang = value[1]
for _, ft in ipairs(value.extra_ft) do
vim.treesitter.language.register(lang, ft)
end
filetypes[i] = lang
end
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
if not vim.list_contains(filetypes, ft) then
table.insert(filetypes, ft)
end
local ts = require("nvim-treesitter")
ts.setup({
install_dir = string.format("%s/nvim-treesitter", vim.fn.stdpath("data"))
})
ts.install(languages):await(function(err)
if err then
log.error("Error: %s", err)
return
end
---@diagnostic disable-next-line: redefined-local
ts.update():await(function(err)
if err then
log.error("Error: %s", err)
return
end
local filetypes = {}
for _, lang in ipairs(languages) do
for _, ft in ipairs(vim.treesitter.language.get_filetypes(lang)) do
if not vim.list_contains(filetypes, ft) then
table.insert(filetypes, ft)
end
end
end
vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function()
vim.treesitter.start()
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end,
})
end)
end,
}
vim.api.nvim_create_autocmd("FileType", {
pattern = filetypes,
callback = function()
vim.treesitter.start()
vim.wo.foldmethod = "expr"
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
end,
})
end
)
end)
+31 -43
View File
@@ -1,45 +1,33 @@
---@type LazyPluginSpec
return {
"stevearc/oil.nvim",
keys = {
{
"<leader>fe",
function()
vim.cmd.Oil("--float")
end,
mode = "n",
},
require("oil").setup({
default_file_explorer = true,
columns = {
-- "icon",
"permissions",
"size",
"mtime",
},
---@type oil.SetupOpts
opts = {
default_file_explorer = true,
columns = {
-- "icon",
"permissions",
"size",
"mtime",
},
delete_to_trash = true,
float = {
max_width = 80,
max_height = 20,
},
skip_confirm_for_simple_edits = true,
watch_for_changes = false,
keymaps = {
["<Esc>"] = "actions.close",
["q"] = "actions.close",
["<C-s>"] = false,
["<C-h>"] = "actions.parent",
["<C-l>"] = "actions.select",
["<C-r>"] = "actions.refresh",
},
view_options = {
show_hidden = true,
natural_order = false,
},
win_options = {
colorcolumn = "",
},
delete_to_trash = true,
float = {
max_width = 80,
max_height = 20,
},
}
skip_confirm_for_simple_edits = true,
watch_for_changes = false,
keymaps = {
["<Esc>"] = "actions.close",
["q"] = "actions.close",
["<C-s>"] = false,
["<C-h>"] = "actions.parent",
["<C-l>"] = "actions.select",
["<C-r>"] = "actions.refresh",
},
view_options = {
show_hidden = true,
natural_order = false,
},
win_options = {
colorcolumn = "",
},
})
vim.keymap.set("n", "<leader>fe", function() vim.cmd.Oil("--float") end)
+24 -31
View File
@@ -1,33 +1,26 @@
---@type LazyPluginSpec
return {
"navarasu/onedark.nvim",
priority = 1000,
config = function()
require("onedark").setup({ style = "darker" })
require("onedark").setup({ style = "darker" })
local c = require("onedark.colors")
local highlights = {
["@string.special.url"] = { fg = "NONE", fmt = "NONE" },
["@lsp.type.macro.gotmpl"] = { fg = "NONE", fmt = "NONE" },
Cursor = { fg = c.bg, bg = c.fg, fmt = "NONE" },
FloatTitle = { fg = c.orange, bg = c.bg_d },
NormalFloat = { bg = c.bg_d },
FloatBorder = { bg = c.bg_d },
TabLine = { fg = c.grey, bg = c.bg1 },
TabLineSel = { fg = c.fg, bg = c.bg2 },
TabLineFill = { bg = c.bg1 },
EndOfBuffer = { fg = "NONE", bg = "NONE" },
NvimTreeIndentMarker = { fg = c.bg3 },
TelescopeNormal = { bg = c.bg_d },
TelescopeTitle = { fg = c.orange, bg = c.bg_d },
TelescopePromptBorder = { fg = c.grey, bg = c.bg_d },
TelescopeResultsBorder = { fg = c.grey, bg = c.bg_d },
TelescopePreviewBorder = { fg = c.grey, bg = c.bg_d },
DiffAdd = { bg = "#1a2f22" },
DiffChange = { bg = "#15304a" },
DiffDelete = { bg = "#311c1e" },
}
require("onedark").set_options("highlights", highlights)
require("onedark").load()
end,
local c = require("onedark.colors")
local highlights = {
["@string.special.url"] = { fg = "NONE", fmt = "NONE" },
["@lsp.type.macro.gotmpl"] = { fg = "NONE", fmt = "NONE" },
Cursor = { fg = c.bg, bg = c.fg, fmt = "NONE" },
FloatTitle = { fg = c.orange, bg = c.bg_d },
NormalFloat = { bg = c.bg_d },
FloatBorder = { bg = c.bg_d },
TabLine = { fg = c.grey, bg = c.bg1 },
TabLineSel = { fg = c.fg, bg = c.bg2 },
TabLineFill = { bg = c.bg1 },
EndOfBuffer = { fg = "NONE", bg = "NONE" },
NvimTreeIndentMarker = { fg = c.bg3 },
TelescopeNormal = { bg = c.bg_d },
TelescopeTitle = { fg = c.orange, bg = c.bg_d },
TelescopePromptBorder = { fg = c.grey, bg = c.bg_d },
TelescopeResultsBorder = { fg = c.grey, bg = c.bg_d },
TelescopePreviewBorder = { fg = c.grey, bg = c.bg_d },
DiffAdd = { bg = "#1a2f22" },
DiffChange = { bg = "#15304a" },
DiffDelete = { bg = "#311c1e" },
}
require("onedark").set_options("highlights", highlights)
require("onedark").load()
+8 -15
View File
@@ -1,16 +1,9 @@
---@type LazyPluginSpec
return {
"hedyhli/outline.nvim",
lazy = true,
cmd = { "Outline", "OutlineOpen" },
keys = { -- Example mapping to toggle outline
{ "<leader>o", "<cmd>Outline<CR>", desc = "Toggle outline" },
require("outline").setup({
outline_window = {
relative_width = false,
split_command = "aboveleft 40vsp",
focus_on_open = false,
},
opts = {
outline_window = {
relative_width = false,
split_command = "aboveleft 40vsp",
focus_on_open = false,
},
},
}
})
vim.keymap.set("n", "<leader>o", "<cmd>Outline<CR>")
+168 -181
View File
@@ -1,194 +1,181 @@
-- https://github.com/nvim-telescope/telescope.nvim
local telescope = require("telescope")
local builtin = require("telescope.builtin")
local actions = require("telescope.actions")
local utils = require("telescope.utils")
---@type LazyPluginSpec
return {
"nvim-telescope/telescope.nvim",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
"debugloop/telescope-undo.nvim",
"rcarriga/nvim-notify",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
telescope.setup({
defaults = {
mappings = {
n = {
q = actions.close,
["<C-c>"] = actions.close,
["<C-l>"] = actions.select_default,
["<C-u>"] = actions.results_scrolling_up,
["<C-d>"] = actions.results_scrolling_down,
},
},
file_ignore_patterns = {
"^%.git/",
},
layout_config = {
height = 30,
width = 80,
scroll_speed = 3,
},
},
config = function()
local telescope = require("telescope")
local builtin = require("telescope.builtin")
local actions = require("telescope.actions")
local utils = require("telescope.utils")
telescope.setup({
defaults = {
mappings = {
n = {
q = actions.close,
["<C-c>"] = actions.close,
["<C-l>"] = actions.select_default,
["<C-u>"] = actions.results_scrolling_up,
["<C-d>"] = actions.results_scrolling_down,
},
extensions = {
undo = {
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").yank_deletions,
["<C-cr>"] = false,
["<C-r>"] = false,
["<C-y>"] = require("telescope-undo.actions").yank_additions,
},
file_ignore_patterns = {
"^%.git/",
},
layout_config = {
height = 30,
width = 80,
scroll_speed = 3,
n = {
["u"] = false,
},
},
extensions = {
undo = {
mappings = {
i = {
["<cr>"] = require("telescope-undo.actions").yank_deletions,
["<C-cr>"] = false,
["<C-r>"] = false,
["<C-y>"] = require("telescope-undo.actions").yank_additions,
},
n = {
["u"] = false,
},
},
},
},
pickers = {
oldfiles = {
initial_mode = "normal",
},
buffers = {
initial_mode = "normal",
mappings = {
n = {
["<C-x>"] = actions.delete_buffer,
},
},
pickers = {
oldfiles = {
initial_mode = "normal",
},
buffers = {
initial_mode = "normal",
mappings = {
n = {
["<C-x>"] = actions.delete_buffer,
},
},
},
live_grep = {
layout_config = {
width = 160,
preview_width = 80,
},
},
highlights = {
layout_config = {
width = 160,
preview_width = 80,
},
},
diagnostics = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_definitions = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_type_definitions = {
initial_mode = "normal",
},
lsp_implementations = {
initial_mode = "normal",
},
lsp_references = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
git_status = {
initial_mode = "normal",
},
},
live_grep = {
layout_config = {
width = 160,
preview_width = 80,
},
})
},
highlights = {
layout_config = {
width = 160,
preview_width = 80,
},
},
diagnostics = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_definitions = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
lsp_type_definitions = {
initial_mode = "normal",
},
lsp_implementations = {
initial_mode = "normal",
},
lsp_references = {
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
},
git_status = {
initial_mode = "normal",
},
},
})
vim.keymap.set("n", "<leader>ff", function()
builtin.find_files({
hidden = true,
no_ignore = true,
no_ignore_parent = true,
previewer = false,
})
end)
vim.keymap.set("n", "<leader>fr", function()
builtin.oldfiles({
only_cwd = true,
hidden = true,
previewer = false,
})
end)
vim.keymap.set("n", "<leader>fg", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
previewer = true,
})
end)
vim.keymap.set("n", "<leader>fG", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
cwd = utils.buffer_dir(),
previewer = true,
})
end)
vim.keymap.set("n", "<leader>fb", function()
builtin.buffers({ previewer = false, sort_mru = true })
end)
vim.keymap.set("n", "<leader>fd", function()
builtin.diagnostics({
bufnr = 0,
})
end)
vim.keymap.set("n", "<leader>ff", function()
builtin.find_files({
hidden = true,
no_ignore = true,
no_ignore_parent = true,
previewer = false,
})
end)
vim.keymap.set("n", "<leader>dl", builtin.diagnostics)
vim.keymap.set("n", "grt", builtin.lsp_type_definitions)
vim.keymap.set("n", "gd", builtin.lsp_definitions)
vim.keymap.set("n", "gri", builtin.lsp_implementations)
vim.keymap.set("n", "grr", builtin.lsp_references)
vim.keymap.set("n", "<leader>fr", function()
builtin.oldfiles({
only_cwd = true,
hidden = true,
previewer = false,
})
end)
telescope.load_extension("fzf")
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", function()
telescope.extensions.notify.notify({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
vim.keymap.set("n", "<leader>fg", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
previewer = true,
})
end)
telescope.load_extension("undo")
vim.keymap.set("n", "<leader>fu", function()
telescope.extensions.undo.undo({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
end,
}
vim.keymap.set("n", "<leader>fG", function()
builtin.live_grep({
additional_args = function(_)
return {
"--hidden",
"--iglob=!.venv",
"--iglob=!vendor",
"--iglob=!.git",
}
end,
cwd = utils.buffer_dir(),
previewer = true,
})
end)
vim.keymap.set("n", "<leader>fb", function()
builtin.buffers({ previewer = false, sort_mru = true })
end)
vim.keymap.set("n", "<leader>fd", function()
builtin.diagnostics({
bufnr = 0,
})
end)
vim.keymap.set("n", "<leader>dl", builtin.diagnostics)
vim.keymap.set("n", "grt", builtin.lsp_type_definitions)
vim.keymap.set("n", "gd", builtin.lsp_definitions)
vim.keymap.set("n", "gri", builtin.lsp_implementations)
vim.keymap.set("n", "grr", builtin.lsp_references)
telescope.load_extension("fzf")
telescope.load_extension("notify")
vim.keymap.set("n", "<leader>fn", function()
telescope.extensions.notify.notify({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
telescope.load_extension("undo")
vim.keymap.set("n", "<leader>fu", function()
telescope.extensions.undo.undo({
initial_mode = "normal",
layout_config = {
width = 160,
preview_width = 80,
},
})
end)
+4 -19
View File
@@ -1,20 +1,5 @@
local function undo_tree_tab()
vim.cmd.tabnew()
vim.cmd.bprevious()
vim.cmd.UndotreeToggle()
vim.cmd.UndotreeFocus()
end
vim.cmd.packadd("nvim.undotree")
---@type LazyPluginSpec
return {
"mbbill/undotree",
keys = {
{ "<leader>uu", undo_tree_tab, mode = "n" },
},
init = function(_)
vim.g.undotree_WindowLayout = 2
vim.g.undotree_DiffCommand = "diff -u"
vim.g.undotree_SplitWidth = 50
vim.g.undotree_DiffpanelHeight = 20
end,
}
vim.keymap.set("n", "<leader>uu", function()
require("undotree").open({ command = "leftabove40vnew" })
end)
+1
View File
@@ -0,0 +1 @@
vim.keymap.set("n", "<leader>gl", vim.cmd.Flog)
+46
View File
@@ -0,0 +1,46 @@
local function open_git_status()
local previous_win = vim.api.nvim_get_current_win()
vim.cmd("leftabove vertical G")
vim.api.nvim_win_set_width(0, 50)
vim.api.nvim_set_option_value("winfixwidth", true, { scope = "local" })
vim.api.nvim_set_current_win(previous_win)
end
local function get_git_status_win()
local current_tabpage = vim.api.nvim_get_current_tabpage()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(current_tabpage)) do
local buf = vim.api.nvim_win_get_buf(win)
local buftype = vim.api.nvim_get_option_value("buftype", { buf = buf })
if
buftype == "nowrite"
and vim.api.nvim_buf_get_name(buf):match("^fugitive://.*%.git//$")
then
return win
end
end
end
local function toggle_git_status()
local win = get_git_status_win()
if win then
vim.api.nvim_win_close(win, false)
return
end
open_git_status()
end
vim.keymap.set("n", "<leader>gd", vim.cmd.Gvdiffsplit)
vim.keymap.set("n", "<leader>gD", function() vim.cmd.Gvdiffsplit("HEAD") end)
vim.keymap.set("n", "<leader>gh", vim.cmd.Ghdiffsplit)
vim.keymap.set("n", "<leader>gH", function() vim.cmd.Ghdiffsplit("HEAD") end)
vim.keymap.set("n", "<leader>gc", function() vim.cmd.G("commit") end)
vim.keymap.set("n", "<leader>ga", function() vim.cmd.G("commit --amend") end)
vim.keymap.set("n", "<leader>gp", function() vim.cmd.G("push") end)
vim.keymap.set("n", "<leader>gg", toggle_git_status)
vim.api.nvim_create_autocmd("BufWritePost", {
callback = function()
vim.fn["fugitive#ReloadStatus"]()
end,
})