This commit is contained in:
2026-04-04 09:43:55 -04:00
parent 956f9ef300
commit 0c4a2ab0e6
14 changed files with 662 additions and 1187 deletions
+16 -1
View File
@@ -2,4 +2,19 @@ vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
require("config") require("config")
require("plugins")
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git", "clone", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins", {
change_detection = { notify = false },
})
+21 -31
View File
@@ -1,31 +1,21 @@
vim.pack.add({ return {
{ "saghen/blink.cmp",
src = "https://github.com/saghen/blink.cmp", version = "^1",
version = vim.version.range("^1"), event = "InsertEnter", -- Lazy's native equivalent of the manual InsertEnter augroup
}, config = function()
}) require("blink.cmp").setup({
keymap = { preset = "super-tab" },
-- Lazy load on first insert mode entry (may not necessary) appearance = {
local group = vim.api.nvim_create_augroup("BlinkCmpLazyLoad", { clear = true }) nerd_font_variant = "mono",
use_nvim_cmp_as_default = true,
vim.api.nvim_create_autocmd("InsertEnter", { },
pattern = "*", completion = {
group = group, documentation = { auto_show = false },
once = true, },
callback = function() sources = {
require("blink.cmp").setup({ default = { "lsp", "path", "snippets", "buffer" },
keymap = { preset = "super-tab" }, },
appearance = { fuzzy = { implementation = "prefer_rust_with_warning" },
nerd_font_variant = "mono", })
use_nvim_cmp_as_default = true, end,
}, }
completion = {
documentation = { auto_show = false },
},
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
fuzzy = { implementation = "prefer_rust_with_warning" },
})
end,
})
+65 -77
View File
@@ -1,79 +1,67 @@
vim.pack.add({ "https://github.com/stevearc/conform.nvim" }) return {
"stevearc/conform.nvim",
config = function()
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
go = { "goimports", "gofmt" },
python = { "ruff_format", "black", stop_after_first = true },
json = { "biome", "prettier", stop_after_first = true },
markdown = { "prettier" },
javascript = { "biome", "prettier", stop_after_first = true },
typescript = { "biome", "prettier", stop_after_first = true },
javascriptreact = { "biome", "prettier", stop_after_first = true },
typescriptreact = { "biome", "prettier", stop_after_first = true },
css = { "prettier" },
html = { "prettier" },
toml = { "taplo" },
},
formatters = {
biome = { require_cwd = true },
},
default_format_opts = {
lsp_format = "fallback",
},
})
require("conform").setup({ vim.api.nvim_create_user_command("FormatDisable", function(opts)
formatters_by_ft = { if opts.bang then
lua = { "stylua" }, vim.b.disable_autoformat = true
go = { "goimports", "gofmt" }, else
python = { "ruff_format", "black", stop_after_first = true }, vim.g.disable_autoformat = true
json = { "biome", "prettier", stop_after_first = true }, end
markdown = { "prettier" }, vim.notify("Autoformat disabled" .. (opts.bang and " (buffer)" or " (global)"), vim.log.levels.WARN)
javascript = { "biome", "prettier", stop_after_first = true }, end, { desc = "Disable autoformat-on-save", bang = true })
typescript = { "biome", "prettier", stop_after_first = true },
javascriptreact = { "biome", "prettier", stop_after_first = true }, vim.api.nvim_create_user_command("FormatEnable", function()
typescriptreact = { "biome", "prettier", stop_after_first = true }, vim.b.disable_autoformat = false
css = { "prettier" }, vim.g.disable_autoformat = false
html = { "prettier" }, vim.notify("Autoformat enabled", vim.log.levels.INFO)
toml = { "taplo" }, end, { desc = "Re-enable autoformat-on-save" })
},
formatters = { local auto_format = true
biome = { require_cwd = true },
}, vim.keymap.set("n", "<leader>uf", function()
default_format_opts = { auto_format = not auto_format
lsp_format = "fallback", if auto_format then
}, vim.cmd("FormatEnable")
--[[ format_on_save = function(bufnr) else
local ignore_filetypes = { "sql", "yaml", "yml" } vim.cmd("FormatDisable")
if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then end
return end, { desc = "Toggle Autoformat" })
end
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then vim.keymap.set({ "n", "v" }, "<leader>cn", "<cmd>ConformInfo<cr>", { desc = "Conform Info" })
return
end vim.keymap.set({ "n", "v" }, "<leader>cf", function()
local bufname = vim.api.nvim_buf_get_name(bufnr) require("conform").format({ async = true }, function(err, did_edit)
if bufname:match("/node_modules/") then if not err and did_edit then
return vim.notify("Code formatted", vim.log.levels.INFO, { title = "Conform" })
end end
return { timeout_ms = 500, lsp_format = "fallback" } end)
end, { desc = "Format buffer" })
vim.keymap.set({ "n", "v" }, "<leader>cF", function()
require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 })
end, { desc = "Format Injected Langs" })
end, end,
]] }
})
vim.api.nvim_create_user_command("FormatDisable", function(opts)
if opts.bang then
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
vim.notify("Autoformat disabled" .. (opts.bang and " (buffer)" or " (global)"), vim.log.levels.WARN)
end, { desc = "Disable autoformat-on-save", bang = true })
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
vim.notify("Autoformat enabled", vim.log.levels.INFO)
end, { desc = "Re-enable autoformat-on-save" })
local auto_format = true
vim.keymap.set("n", "<leader>uf", function()
auto_format = not auto_format
if auto_format then
vim.cmd("FormatEnable")
else
vim.cmd("FormatDisable")
end
end, { desc = "Toggle Autoformat" })
vim.keymap.set({ "n", "v" }, "<leader>cn", "<cmd>ConformInfo<cr>", { desc = "Conform Info" })
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
require("conform").format({ async = true }, function(err, did_edit)
if not err and did_edit then
vim.notify("Code formatted", vim.log.levels.INFO, { title = "Conform" })
end
end)
end, { desc = "Format buffer" })
vim.keymap.set({ "n", "v" }, "<leader>cF", function()
require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 })
end, { desc = "Format Injected Langs" })
+283 -659
View File
@@ -1,665 +1,289 @@
vim.pack.add({ return {
"https://github.com/lewis6991/gitsigns.nvim", {
"https://github.com/sindrets/diffview.nvim", "lewis6991/gitsigns.nvim",
}) config = function()
require("gitsigns").setup({
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged_enable = true,
signcolumn = true,
numhl = false,
linehl = false,
word_diff = false,
watch_gitdir = { follow_files = true },
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false,
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol",
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
sign_priority = 6,
update_debounce = 100,
status_formatter = nil,
max_file_length = 40000,
preview_config = {
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
on_attach = function(bufnr)
local gitsigns = require("gitsigns")
require("gitsigns").setup({ local function map(mode, l, r, opts)
signs = { opts = opts or {}
add = { text = "" }, opts.buffer = bufnr
change = { text = "" }, vim.keymap.set(mode, l, r, opts)
delete = { text = "_" }, end
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true,
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
on_attach = function(bufnr)
local gitsigns = require("gitsigns")
local function map(mode, l, r, opts) -- Navigation
opts = opts or {} map("n", "]c", function()
opts.buffer = bufnr if vim.wo.diff then vim.cmd.normal({ "]c", bang = true })
vim.keymap.set(mode, l, r, opts) else gitsigns.nav_hunk("next") end
end end)
map("n", "[c", function()
if vim.wo.diff then vim.cmd.normal({ "[c", bang = true })
else gitsigns.nav_hunk("prev") end
end)
-- Navigation -- Actions
map("n", "]c", function() map("n", "<leader>hs", gitsigns.stage_hunk)
if vim.wo.diff then map("n", "<leader>hr", gitsigns.reset_hunk)
vim.cmd.normal({ "]c", bang = true }) map("v", "<leader>hs", function() gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end)
else map("v", "<leader>hr", function() gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end)
gitsigns.nav_hunk("next") map("n", "<leader>hS", gitsigns.stage_buffer)
end map("n", "<leader>hR", gitsigns.reset_buffer)
end) map("n", "<leader>hp", gitsigns.preview_hunk)
map("n", "<leader>hi", gitsigns.preview_hunk_inline)
map("n", "<leader>hb", function() gitsigns.blame_line({ full = true }) end)
map("n", "<leader>hd", gitsigns.diffthis)
map("n", "<leader>hD", function() gitsigns.diffthis("~") end)
map("n", "<leader>hQ", function() gitsigns.setqflist("all") end)
map("n", "<leader>hq", gitsigns.setqflist)
map("n", "[c", function() -- Toggles
if vim.wo.diff then map("n", "<leader>tb", gitsigns.toggle_current_line_blame)
vim.cmd.normal({ "[c", bang = true }) map("n", "<leader>tw", gitsigns.toggle_word_diff)
else
gitsigns.nav_hunk("prev")
end
end)
-- Actions -- Text object
map("n", "<leader>hs", gitsigns.stage_hunk) map({ "o", "x" }, "ih", gitsigns.select_hunk)
map("n", "<leader>hr", gitsigns.reset_hunk) end,
})
end,
},
{
"sindrets/diffview.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local actions = require("diffview.actions")
map("v", "<leader>hs", function() require("diffview").setup({
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) diff_binaries = false,
end) enhanced_diff_hl = false,
git_cmd = { "git" },
map("v", "<leader>hr", function() hg_cmd = { "hg" },
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) use_icons = true,
end) show_help_hints = true,
watch_index = true,
map("n", "<leader>hS", gitsigns.stage_buffer) icons = {
map("n", "<leader>hR", gitsigns.reset_buffer) folder_closed = "",
map("n", "<leader>hp", gitsigns.preview_hunk) folder_open = "",
map("n", "<leader>hi", gitsigns.preview_hunk_inline) },
signs = {
map("n", "<leader>hb", function() fold_closed = "",
gitsigns.blame_line({ full = true }) fold_open = "",
end) done = "",
},
map("n", "<leader>hd", gitsigns.diffthis) view = {
default = {
map("n", "<leader>hD", function() layout = "diff2_horizontal",
gitsigns.diffthis("~") disable_diagnostics = false,
end) winbar_info = false,
},
map("n", "<leader>hQ", function() merge_tool = {
gitsigns.setqflist("all") layout = "diff3_horizontal",
end) disable_diagnostics = true,
map("n", "<leader>hq", gitsigns.setqflist) winbar_info = true,
},
-- Toggles file_history = {
map("n", "<leader>tb", gitsigns.toggle_current_line_blame) layout = "diff2_horizontal",
map("n", "<leader>tw", gitsigns.toggle_word_diff) disable_diagnostics = false,
winbar_info = false,
-- Text object },
map({ "o", "x" }, "ih", gitsigns.select_hunk) },
end, file_panel = {
}) listing_style = "tree",
tree_options = {
-- Lua flatten_dirs = true,
local actions = require("diffview.actions") folder_statuses = "only_folded",
},
require("diffview").setup({ win_config = {
diff_binaries = false, -- Show diffs for binaries position = "left",
enhanced_diff_hl = false, -- See |diffview-config-enhanced_diff_hl| width = 35,
git_cmd = { "git" }, -- The git executable followed by default args. win_opts = {},
hg_cmd = { "hg" }, -- The hg executable followed by default args. },
use_icons = true, -- Requires nvim-web-devicons },
show_help_hints = true, -- Show hints for how to open the help panel file_history_panel = {
watch_index = true, -- Update views and index buffers when the git index changes. log_options = {
icons = { -- Only applies when use_icons is true. git = {
folder_closed = "", single_file = { diff_merges = "combined" },
folder_open = "", multi_file = { diff_merges = "first-parent" },
}, },
signs = { hg = {
fold_closed = "", single_file = {},
fold_open = "", multi_file = {},
done = "", },
}, },
view = { win_config = {
-- Configure the layout and behavior of different types of views. position = "bottom",
-- Available layouts: height = 16,
-- 'diff1_plain' win_opts = {},
-- |'diff2_horizontal' },
-- |'diff2_vertical' },
-- |'diff3_horizontal' commit_log_panel = {
-- |'diff3_vertical' win_config = {},
-- |'diff3_mixed' },
-- |'diff4_mixed' default_args = {
-- For more info, see |diffview-config-view.x.layout|. DiffviewOpen = {},
default = { DiffviewFileHistory = {},
-- Config for changed files, and staged files in diff views. },
layout = "diff2_horizontal", hooks = {},
disable_diagnostics = false, -- Temporarily disable diagnostics for diff buffers while in the view. keymaps = {
winbar_info = false, -- See |diffview-config-view.x.winbar_info| disable_defaults = false,
}, view = {
merge_tool = { { "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
-- Config for conflicted files in diff views during a merge or rebase. { "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
layout = "diff3_horizontal", { "n", "[F", actions.select_first_entry, { desc = "Open the diff for the first file" } },
disable_diagnostics = true, -- Temporarily disable diagnostics for diff buffers while in the view. { "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } },
winbar_info = true, -- See |diffview-config-view.x.winbar_info| { "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
}, { "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
file_history = { { "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
-- Config for changed files in file history views. { "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
layout = "diff2_horizontal", { "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel." } },
disable_diagnostics = false, -- Temporarily disable diagnostics for diff buffers while in the view. { "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle through available layouts." } },
winbar_info = false, -- See |diffview-config-view.x.winbar_info| { "n", "[x", actions.prev_conflict, { desc = "In the merge-tool: jump to the previous conflict" } },
}, { "n", "]x", actions.next_conflict, { desc = "In the merge-tool: jump to the next conflict" } },
}, { "n", "<leader>co", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } },
file_panel = { { "n", "<leader>ct", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } },
listing_style = "tree", -- One of 'list' or 'tree' { "n", "<leader>cb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } },
tree_options = { -- Only applies when listing_style is 'tree' { "n", "<leader>ca", actions.conflict_choose("all"), { desc = "Choose all the versions of a conflict" } },
flatten_dirs = true, -- Flatten dirs that only contain one single dir { "n", "dX", actions.conflict_choose("none"), { desc = "Delete the conflict region" } },
folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'. { "n", "<leader>cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } },
}, { "n", "<leader>cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } },
win_config = { -- See |diffview-config-win_config| { "n", "<leader>cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } },
position = "left", { "n", "<leader>cA", actions.conflict_choose_all("all"), { desc = "Choose all versions for the whole file" } },
width = 35, { "n", "g?", actions.help("view"), { desc = "Open the help panel" } },
win_opts = {}, },
}, file_panel = {
}, { "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
file_history_panel = { { "n", "<down>", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
log_options = { -- See |diffview-config-log_options| { "n", "k", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } },
git = { { "n", "<up>", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } },
single_file = { { "n", "<cr>", actions.select_entry, { desc = "Open the diff for the selected entry" } },
diff_merges = "combined", { "n", "o", actions.select_entry, { desc = "Open the diff for the selected entry" } },
}, { "n", "l", actions.select_entry, { desc = "Open the diff for the selected entry" } },
multi_file = { { "n", "<2-LeftMouse>", actions.select_entry, { desc = "Open the diff for the selected entry" } },
diff_merges = "first-parent", { "n", "-", actions.toggle_stage_entry, { desc = "Stage / unstage the selected entry" } },
}, { "n", "s", actions.toggle_stage_entry, { desc = "Stage / unstage the selected entry" } },
}, { "n", "S", actions.stage_all, { desc = "Stage all entries" } },
hg = { { "n", "U", actions.unstage_all, { desc = "Unstage all entries" } },
single_file = {}, { "n", "X", actions.restore_entry, { desc = "Restore entry to the state on the left side" } },
multi_file = {}, { "n", "L", actions.open_commit_log, { desc = "Open the commit log panel" } },
}, { "n", "zo", actions.open_fold, { desc = "Expand fold" } },
}, { "n", "h", actions.close_fold, { desc = "Collapse fold" } },
win_config = { -- See |diffview-config-win_config| { "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
position = "bottom", { "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
height = 16, { "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
win_opts = {}, { "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
}, { "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
}, { "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
commit_log_panel = { { "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
win_config = {}, -- See |diffview-config-win_config| { "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
}, { "n", "[F", actions.select_first_entry, { desc = "Open the diff for the first file" } },
default_args = { -- Default args prepended to the arg-list for the listed commands { "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } },
DiffviewOpen = {}, { "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
DiffviewFileHistory = {}, { "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
}, { "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
hooks = {}, -- See |diffview-config-hooks| { "n", "i", actions.listing_style, { desc = "Toggle between 'list' and 'tree' views" } },
keymaps = { { "n", "f", actions.toggle_flatten_dirs, { desc = "Flatten empty subdirectories in tree listing style" } },
disable_defaults = false, -- Disable the default keymaps { "n", "R", actions.refresh_files, { desc = "Update stats and entries in the file list" } },
view = { { "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
-- The `view` bindings are active in the diff buffers, only when the current { "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
-- tabpage is a Diffview. { "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ { "n", "[x", actions.prev_conflict, { desc = "Go to the previous conflict" } },
"n", { "n", "]x", actions.next_conflict, { desc = "Go to the next conflict" } },
"<tab>", { "n", "g?", actions.help("file_panel"), { desc = "Open the help panel" } },
actions.select_next_entry, { "n", "<leader>cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } },
{ desc = "Open the diff for the next file" }, { "n", "<leader>cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } },
}, { "n", "<leader>cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } },
{ { "n", "<leader>cA", actions.conflict_choose_all("all"), { desc = "Choose all versions for the whole file" } },
"n", { "n", "dX", actions.conflict_choose_all("none"), { desc = "Delete the conflict region for the whole file" } },
"<s-tab>", },
actions.select_prev_entry, file_history_panel = {
{ desc = "Open the diff for the previous file" }, { "n", "g!", actions.options, { desc = "Open the option panel" } },
}, { "n", "<C-A-d>", actions.open_in_diffview, { desc = "Open the entry under the cursor in a diffview" } },
{ { "n", "y", actions.copy_hash, { desc = "Copy the commit hash of the entry under the cursor" } },
"n", { "n", "L", actions.open_commit_log, { desc = "Show commit details" } },
"[F", { "n", "X", actions.restore_entry, { desc = "Restore file to the state from the selected entry" } },
actions.select_first_entry, { "n", "zo", actions.open_fold, { desc = "Expand fold" } },
{ desc = "Open the diff for the first file" }, { "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
}, { "n", "h", actions.close_fold, { desc = "Collapse fold" } },
{ { "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
"n", { "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
"]F", { "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
actions.select_last_entry, { "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
{ desc = "Open the diff for the last file" }, { "n", "<down>", actions.next_entry, { desc = "Bring the cursor to the next file entry" } },
}, { "n", "k", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } },
{ { "n", "<up>", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } },
"n", { "n", "<cr>", actions.select_entry, { desc = "Open the diff for the selected entry" } },
"gf", { "n", "o", actions.select_entry, { desc = "Open the diff for the selected entry" } },
actions.goto_file_edit, { "n", "l", actions.select_entry, { desc = "Open the diff for the selected entry" } },
{ desc = "Open the file in the previous tabpage" }, { "n", "<2-LeftMouse>", actions.select_entry, { desc = "Open the diff for the selected entry" } },
}, { "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } }, { "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, { "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } }, { "n", "<s-tab>", actions.select_prev_entry, { desc = "Open the diff for the previous file" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel." } }, { "n", "[F", actions.select_first_entry, { desc = "Open the diff for the first file" } },
{ { "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } },
"n", { "n", "gf", actions.goto_file_edit, { desc = "Open the file in the previous tabpage" } },
"g<C-x>", { "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
actions.cycle_layout, { "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ desc = "Cycle through available layouts." }, { "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
}, { "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ { "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
"n", { "n", "g?", actions.help("file_history_panel"), { desc = "Open the help panel" } },
"[x", },
actions.prev_conflict, option_panel = {
{ desc = "In the merge-tool: jump to the previous conflict" }, { "n", "<tab>", actions.select_entry, { desc = "Change the current option" } },
}, { "n", "q", actions.close, { desc = "Close the panel" } },
{ { "n", "g?", actions.help("option_panel"), { desc = "Open the help panel" } },
"n", },
"]x", help_panel = {
actions.next_conflict, { "n", "q", actions.close, { desc = "Close help menu" } },
{ desc = "In the merge-tool: jump to the next conflict" }, { "n", "<esc>", actions.close, { desc = "Close help menu" } },
}, },
{ },
"n", })
"<leader>co", end,
actions.conflict_choose("ours"), },
{ desc = "Choose the OURS version of a conflict" }, }
},
{
"n",
"<leader>ct",
actions.conflict_choose("theirs"),
{ desc = "Choose the THEIRS version of a conflict" },
},
{
"n",
"<leader>cb",
actions.conflict_choose("base"),
{ desc = "Choose the BASE version of a conflict" },
},
{
"n",
"<leader>ca",
actions.conflict_choose("all"),
{ desc = "Choose all the versions of a conflict" },
},
{ "n", "dx", actions.conflict_choose("none"), { desc = "Delete the conflict region" } },
{
"n",
"<leader>cO",
actions.conflict_choose_all("ours"),
{ desc = "Choose the OURS version of a conflict for the whole file" },
},
{
"n",
"<leader>cT",
actions.conflict_choose_all("theirs"),
{ desc = "Choose the THEIRS version of a conflict for the whole file" },
},
{
"n",
"<leader>cB",
actions.conflict_choose_all("base"),
{ desc = "Choose the BASE version of a conflict for the whole file" },
},
{
"n",
"<leader>cA",
actions.conflict_choose_all("all"),
{ desc = "Choose all the versions of a conflict for the whole file" },
},
{
"n",
"dX",
actions.conflict_choose_all("none"),
{ desc = "Delete the conflict region for the whole file" },
},
},
diff1 = {
-- Mappings in single window diff layouts
{ "n", "g?", actions.help({ "view", "diff1" }), { desc = "Open the help panel" } },
},
diff2 = {
-- Mappings in 2-way diff layouts
{ "n", "g?", actions.help({ "view", "diff2" }), { desc = "Open the help panel" } },
},
diff3 = {
-- Mappings in 3-way diff layouts
{
{ "n", "x" },
"2do",
actions.diffget("ours"),
{ desc = "Obtain the diff hunk from the OURS version of the file" },
},
{
{ "n", "x" },
"3do",
actions.diffget("theirs"),
{ desc = "Obtain the diff hunk from the THEIRS version of the file" },
},
{ "n", "g?", actions.help({ "view", "diff3" }), { desc = "Open the help panel" } },
},
diff4 = {
-- Mappings in 4-way diff layouts
{
{ "n", "x" },
"1do",
actions.diffget("base"),
{ desc = "Obtain the diff hunk from the BASE version of the file" },
},
{
{ "n", "x" },
"2do",
actions.diffget("ours"),
{ desc = "Obtain the diff hunk from the OURS version of the file" },
},
{
{ "n", "x" },
"3do",
actions.diffget("theirs"),
{ desc = "Obtain the diff hunk from the THEIRS version of the file" },
},
{ "n", "g?", actions.help({ "view", "diff4" }), { desc = "Open the help panel" } },
},
file_panel = {
{
"n",
"j",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"<down>",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"k",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<up>",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<cr>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"o",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"l",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"<2-LeftMouse>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"-",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry" },
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry" },
},
{ "n", "S", actions.stage_all, { desc = "Stage all entries" } },
{ "n", "U", actions.unstage_all, { desc = "Unstage all entries" } },
{
"n",
"X",
actions.restore_entry,
{ desc = "Restore entry to the state on the left side" },
},
{ "n", "L", actions.open_commit_log, { desc = "Open the commit log panel" } },
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{
"n",
"<tab>",
actions.select_next_entry,
{ desc = "Open the diff for the next file" },
},
{
"n",
"<s-tab>",
actions.select_prev_entry,
{ desc = "Open the diff for the previous file" },
},
{
"n",
"[F",
actions.select_first_entry,
{ desc = "Open the diff for the first file" },
},
{
"n",
"]F",
actions.select_last_entry,
{ desc = "Open the diff for the last file" },
},
{
"n",
"gf",
actions.goto_file_edit,
{ desc = "Open the file in the previous tabpage" },
},
{
"n",
"<C-w><C-f>",
actions.goto_file_split,
{ desc = "Open the file in a new split" },
},
{
"n",
"<C-w>gf",
actions.goto_file_tab,
{ desc = "Open the file in a new tabpage" },
},
{
"n",
"i",
actions.listing_style,
{ desc = "Toggle between 'list' and 'tree' views" },
},
{
"n",
"f",
actions.toggle_flatten_dirs,
{ desc = "Flatten empty subdirectories in tree listing style" },
},
{
"n",
"R",
actions.refresh_files,
{ desc = "Update stats and entries in the file list" },
},
{
"n",
"<leader>e",
actions.focus_files,
{ desc = "Bring focus to the file panel" },
},
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "[x", actions.prev_conflict, { desc = "Go to the previous conflict" } },
{ "n", "]x", actions.next_conflict, { desc = "Go to the next conflict" } },
{ "n", "g?", actions.help("file_panel"), { desc = "Open the help panel" } },
{
"n",
"<leader>cO",
actions.conflict_choose_all("ours"),
{ desc = "Choose the OURS version of a conflict for the whole file" },
},
{
"n",
"<leader>cT",
actions.conflict_choose_all("theirs"),
{ desc = "Choose the THEIRS version of a conflict for the whole file" },
},
{
"n",
"<leader>cB",
actions.conflict_choose_all("base"),
{ desc = "Choose the BASE version of a conflict for the whole file" },
},
{
"n",
"<leader>cA",
actions.conflict_choose_all("all"),
{ desc = "Choose all the versions of a conflict for the whole file" },
},
{
"n",
"dX",
actions.conflict_choose_all("none"),
{ desc = "Delete the conflict region for the whole file" },
},
},
file_history_panel = {
{ "n", "g!", actions.options, { desc = "Open the option panel" } },
{
"n",
"<C-A-d>",
actions.open_in_diffview,
{ desc = "Open the entry under the cursor in a diffview" },
},
{
"n",
"y",
actions.copy_hash,
{ desc = "Copy the commit hash of the entry under the cursor" },
},
{ "n", "L", actions.open_commit_log, { desc = "Show commit details" } },
{
"n",
"X",
actions.restore_entry,
{ desc = "Restore file to the state from the selected entry" },
},
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{
"n",
"j",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"<down>",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"k",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<up>",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<cr>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"o",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"l",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"<2-LeftMouse>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{
"n",
"<s-tab>",
actions.select_prev_entry,
{ desc = "Open the diff for the previous file" },
},
{
"n",
"[F",
actions.select_first_entry,
{ desc = "Open the diff for the first file" },
},
{ "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } },
{
"n",
"gf",
actions.goto_file_edit,
{ desc = "Open the file in the previous tabpage" },
},
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "g?", actions.help("file_history_panel"), { desc = "Open the help panel" } },
},
option_panel = {
{ "n", "<tab>", actions.select_entry, { desc = "Change the current option" } },
{ "n", "q", actions.close, { desc = "Close the panel" } },
{ "n", "g?", actions.help("option_panel"), { desc = "Open the help panel" } },
},
help_panel = {
{ "n", "q", actions.close, { desc = "Close help menu" } },
{ "n", "<esc>", actions.close, { desc = "Close help menu" } },
},
},
})
-11
View File
@@ -1,11 +0,0 @@
require("plugins.log-highlight")
require("plugins.whichkey")
require("plugins.treesitter")
require("plugins.neotree")
require("plugins.telescope")
require("plugins.blink")
require("plugins.conform")
require("plugins.git")
require("plugins.markdown")
require("plugins.theme")
require("plugins.lualine")
+3 -1
View File
@@ -1 +1,3 @@
vim.pack.add({ "https://github.com/fei6409/log-highlight.nvim" }) return {
"fei6409/log-highlight.nvim",
}
+53 -59
View File
@@ -1,59 +1,53 @@
vim.pack.add({ return {
"https://github.com/nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
"https://github.com/nvim-tree/nvim-web-devicons", dependencies = { "nvim-tree/nvim-web-devicons" },
}) config = function()
require("lualine").setup({
require("lualine").setup({ options = {
options = { icons_enabled = true,
icons_enabled = true, theme = "auto",
theme = "auto", component_separators = { left = "", right = "" },
component_separators = { left = "", right = "" }, section_separators = { left = "", right = "" },
section_separators = { left = "", right = "" }, disabled_filetypes = {
disabled_filetypes = { statusline = {},
statusline = {}, winbar = {},
winbar = {}, },
}, ignore_focus = {},
ignore_focus = {}, always_divide_middle = true,
always_divide_middle = true, always_show_tabline = true,
always_show_tabline = true, globalstatus = false,
globalstatus = false, refresh = {
refresh = { statusline = 1000,
statusline = 1000, tabline = 1000,
tabline = 1000, winbar = 1000,
winbar = 1000, refresh_time = 16,
refresh_time = 16, -- ~60fps events = {
events = { "WinEnter", "BufEnter", "BufWritePost", "SessionLoadPost",
"WinEnter", "FileChangedShellPost", "VimResized", "Filetype",
"BufEnter", "CursorMoved", "CursorMovedI", "ModeChanged",
"BufWritePost", },
"SessionLoadPost", },
"FileChangedShellPost", },
"VimResized", sections = {
"Filetype", lualine_a = { "mode" },
"CursorMoved", lualine_b = { "branch", "diff", "diagnostics" },
"CursorMovedI", lualine_c = { "filename" },
"ModeChanged", lualine_x = { "encoding", "fileformat", "filetype" },
}, lualine_y = { "progress" },
}, lualine_z = { "location" },
}, },
sections = { inactive_sections = {
lualine_a = { "mode" }, lualine_a = {},
lualine_b = { "branch", "diff", "diagnostics" }, lualine_b = {},
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype" }, lualine_x = { "location" },
lualine_y = { "progress" }, lualine_y = {},
lualine_z = { "location" }, lualine_z = {},
}, },
inactive_sections = { tabline = {},
lualine_a = {}, winbar = {},
lualine_b = {}, inactive_winbar = {},
lualine_c = { "filename" }, extensions = {},
lualine_x = { "location" }, })
lualine_y = {}, end,
lualine_z = {}, }
},
tabline = {},
winbar = {},
inactive_winbar = {},
extensions = {},
})
+7 -7
View File
@@ -1,7 +1,7 @@
vim.pack.add({ return {
'https://github.com/nvim-treesitter/nvim-treesitter', "MeanderingProgrammer/render-markdown.nvim",
-- 'https://github.com/nvim-mini/mini.nvim', -- if you use the mini.nvim suite dependencies = {
-- 'https://github.com/nvim-mini/mini.icons', -- if you use standalone mini plugins "nvim-treesitter/nvim-treesitter",
-- 'https://github.com/nvim-tree/nvim-web-devicons', -- if you prefer nvim-web-devicons "nvim-tree/nvim-web-devicons",
'https://github.com/MeanderingProgrammer/render-markdown.nvim', },
}) }
+8 -10
View File
@@ -1,11 +1,9 @@
vim.pack.add({ return {
{ "nvim-neo-tree/neo-tree.nvim",
src = 'https://github.com/nvim-neo-tree/neo-tree.nvim', version = "3.*",
version = vim.version.range('3') dependencies = {
"nvim-lua/plenary.nvim",
"MunifTanjim/nui.nvim",
"nvim-tree/nvim-web-devicons",
}, },
-- dependencies }
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/MunifTanjim/nui.nvim",
-- optional, but recommended
"https://github.com/nvim-tree/nvim-web-devicons",
})
+18 -13
View File
@@ -1,13 +1,18 @@
vim.pack.add({"https://github.com/nvim-telescope/telescope.nvim", return {
"https://github.com/nvim-lua/plenary.nvim", "nvim-telescope/telescope.nvim",
"https://github.com/BurntSushi/ripgrep", dependencies = {
"https://github.com/nvim-telescope/telescope-fzf-native.nvim", "nvim-lua/plenary.nvim",
"https://github.com/sharkdp/fd", "nvim-tree/nvim-web-devicons",
"https://github.com/nvim-tree/nvim-web-devicons"} {
) "nvim-telescope/telescope-fzf-native.nvim",
build = "make",
local builtin = require('telescope.builtin') },
vim.keymap.set('n', '<leader>ff', builtin.find_files, { desc = 'Telescope find files' }) },
vim.keymap.set('n', '<leader>fg', builtin.live_grep, { desc = 'Telescope live grep' }) config = function()
vim.keymap.set('n', '<leader>fb', builtin.buffers, { desc = 'Telescope buffers' }) local builtin = require("telescope.builtin")
vim.keymap.set('n', '<leader>fh', builtin.help_tags, { desc = 'Telescope help tags' }) vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
end,
}
+8 -3
View File
@@ -1,3 +1,8 @@
vim.pack.add({"https://github.com/catppuccin/nvim"}) return {
"catppuccin/nvim",
vim.cmd("colorscheme catppuccin") name = "catppuccin",
priority = 1000, -- Load before other plugins so colorscheme is set first
config = function()
vim.cmd("colorscheme catppuccin")
end,
}
+84 -137
View File
@@ -1,144 +1,91 @@
vim.pack.add({ return {
{ {
src = "https://github.com/nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
version = "main", branch = "main",
build = ":TSUpdate",
config = function()
require("nvim-treesitter").setup({})
require("nvim-treesitter").install({
"bash", "blade", "c", "comment", "css", "diff", "dockerfile",
"fish", "gitcommit", "gitignore", "go", "gomod", "gosum", "gowork",
"html", "ini", "javascript", "jsdoc", "json", "lua", "luadoc",
"luap", "make", "markdown", "markdown_inline", "nginx", "nix",
"proto", "python", "query", "regex", "rust", "scss", "sql",
"terraform", "toml", "tsx", "typescript", "vim", "vimdoc",
"xml", "yaml", "zig",
})
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
vim.api.nvim_create_autocmd("FileType", {
pattern = { "*" },
callback = function()
local filetype = vim.bo.filetype
if filetype and filetype ~= "" then
pcall(vim.treesitter.start)
end
end,
})
end,
}, },
{ {
src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/nvim-treesitter-textobjects",
version = "main", branch = "main",
}, dependencies = { "nvim-treesitter/nvim-treesitter" },
}) config = function()
require("nvim-treesitter-textobjects").setup({
select = {
enable = true,
lookahead = true,
selection_modes = {
["@parameter.outer"] = "v",
["@function.outer"] = "V",
["@class.outer"] = "<c-v>",
},
include_surrounding_whitespace = false,
},
move = {
enable = true,
set_jumps = true,
},
})
require("nvim-treesitter").setup({}) -- SELECT keymaps
require("nvim-treesitter").install({ local sel = require("nvim-treesitter-textobjects.select")
"bash", for _, map in ipairs({
"blade", { { "x", "o" }, "af", "@function.outer" },
"c", { { "x", "o" }, "if", "@function.inner" },
"comment", { { "x", "o" }, "ac", "@class.outer" },
"css", { { "x", "o" }, "ic", "@class.inner" },
"diff", { { "x", "o" }, "aa", "@parameter.outer" },
"dockerfile", { { "x", "o" }, "ia", "@parameter.inner" },
"fish", { { "x", "o" }, "ad", "@comment.outer" },
"gitcommit", { { "x", "o" }, "as", "@statement.outer" },
"gitignore", }) do
"go", vim.keymap.set(map[1], map[2], function()
"gomod", sel.select_textobject(map[3], "textobjects")
"gosum", end, { desc = "Select " .. map[3] })
"gowork",
"html",
"ini",
"javascript",
"jsdoc",
"json",
"lua",
"luadoc",
"luap",
"make",
"markdown",
"markdown_inline",
"nginx",
"nix",
"proto",
"python",
"query",
"regex",
"rust",
"scss",
"sql",
"terraform",
"toml",
"tsx",
"typescript",
"vim",
"vimdoc",
"xml",
"yaml",
"zig",
})
require("nvim-treesitter-textobjects").setup({
select = {
enable = true,
lookahead = true,
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},
include_surrounding_whitespace = false,
},
move = {
enable = true,
set_jumps = true,
},
})
-- SELECT keymaps
local sel = require("nvim-treesitter-textobjects.select")
for _, map in ipairs({
{ { "x", "o" }, "af", "@function.outer" },
{ { "x", "o" }, "if", "@function.inner" },
{ { "x", "o" }, "ac", "@class.outer" },
{ { "x", "o" }, "ic", "@class.inner" },
{ { "x", "o" }, "aa", "@parameter.outer" },
{ { "x", "o" }, "ia", "@parameter.inner" },
{ { "x", "o" }, "ad", "@comment.outer" },
{ { "x", "o" }, "as", "@statement.outer" },
}) do
vim.keymap.set(map[1], map[2], function()
sel.select_textobject(map[3], "textobjects")
end, { desc = "Select " .. map[3] })
end
-- MOVE keymaps
local mv = require("nvim-treesitter-textobjects.move")
for _, map in ipairs({
{ { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" },
{ { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" },
{ { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" },
{ { "n", "x", "o" }, "[[", mv.goto_previous_start, "@class.outer" },
{ { "n", "x", "o" }, "]M", mv.goto_next_end, "@function.outer" },
{ { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" },
{ { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
{ { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
}) do
local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
-- build a human-readable desc
local qstr = (type(query) == "table") and table.concat(query, ",") or query
vim.keymap.set(modes, lhs, function()
fn(query, "textobjects")
end, { desc = "Move to " .. qstr })
end
vim.api.nvim_create_autocmd("PackChanged", {
desc = "Handle nvim-treesitter updates",
group = vim.api.nvim_create_augroup("nvim-treesitter-pack-changed-update-handler", { clear = true }),
callback = function(event)
if event.data.kind == "update" then
local ok = pcall(vim.cmd, "TSUpdate")
if ok then
vim.notify("TSUpdate completed successfully!", vim.log.levels.INFO)
else
vim.notify("TSUpdate command not available yet, skipping", vim.log.levels.WARN)
end end
end
end,
})
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- MOVE keymaps
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" local mv = require("nvim-treesitter-textobjects.move")
for _, map in ipairs({
vim.api.nvim_create_autocmd("FileType", { { { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" },
pattern = { "*" }, { { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" },
callback = function() { { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" },
local filetype = vim.bo.filetype { { "n", "x", "o" }, "[[", mv.goto_previous_start, "@class.outer" },
if filetype and filetype ~= "" then { { "n", "x", "o" }, "]M", mv.goto_next_end, "@function.outer" },
local success = pcall(function() { { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" },
vim.treesitter.start() { { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
end) { { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
if not success then }) do
return local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
local qstr = (type(query) == "table") and table.concat(query, ",") or query
vim.keymap.set(modes, lhs, function()
fn(query, "textobjects")
end, { desc = "Move to " .. qstr })
end end
end end,
end, },
}) }
+96 -98
View File
@@ -1,98 +1,96 @@
vim.pack.add({ return {
"https://github.com/folke/which-key.nvim", "folke/which-key.nvim",
}) event = "VeryLazy",
config = function()
local wk = require("which-key") local wk = require("which-key")
wk.setup({ wk.setup({
preset = "helix", preset = "helix",
}) })
wk.add({ wk.add({
{ "<leader><tab>", group = "tabs" }, { "<leader><tab>", group = "tabs" },
{ "<leader>c", group = "code" }, { "<leader>c", group = "code" },
{ "<leader>d", group = "debug" }, { "<leader>d", group = "debug" },
{ "<leader>D", group = "Diffview", icon = { icon = "", color = "orange" } }, { "<leader>D", group = "Diffview", icon = { icon = "", color = "orange" } },
{ "<leader>p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } }, { "<leader>p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } },
{ "<leader>dp", group = "profiler" }, { "<leader>dp", group = "profiler" },
{ "<leader>f", group = "file/find" }, { "<leader>f", group = "file/find" },
{ "<leader>g", group = "git" }, { "<leader>g", group = "git" },
{ "<leader>gh", group = "hunks" }, { "<leader>gh", group = "hunks" },
{ "<leader>q", group = "quit/session" }, { "<leader>q", group = "quit/session" },
{ "<leader>s", group = "search" }, { "<leader>s", group = "search" },
{ "<leader>u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, { "<leader>u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } },
{ "<leader>x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, { "<leader>x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } },
{ "[", group = "prev" }, { "[", group = "prev" },
{ "]", group = "next" }, { "]", group = "next" },
{ "g", group = "goto" }, { "g", group = "goto" },
{ "gs", group = "surround" }, { "gs", group = "surround" },
{ "z", group = "fold" }, { "z", group = "fold" },
{ {
"<leader>b", "<leader>b",
group = "buffer", group = "buffer",
expand = function() expand = function()
return require("which-key.extras").expand.buf() return require("which-key.extras").expand.buf()
end, end,
}, },
{ {
"<leader>w", "<leader>w",
group = "windows", group = "windows",
proxy = "<c-w>", proxy = "<c-w>",
expand = function() expand = function()
return require("which-key.extras").expand.win() return require("which-key.extras").expand.win()
end, end,
}, },
-- better descriptions { "gx", desc = "Open with system app" },
{ "gx", desc = "Open with system app" }, {
{ "<leader>fC",
"<leader>fC", group = "Copy Path",
group = "Copy Path", {
{ "<leader>fCf",
"<leader>fCf", function()
function() vim.fn.setreg("+", vim.fn.expand("%:p"))
vim.fn.setreg("+", vim.fn.expand("%:p")) -- Copy full file path to clipboard vim.notify("Copied full file path: " .. vim.fn.expand("%:p"))
vim.notify("Copied full file path: " .. vim.fn.expand("%:p")) end,
end, desc = "Copy full file path",
desc = "Copy full file path", },
}, {
{ "<leader>fCn",
"<leader>fCn", function()
function() vim.fn.setreg("+", vim.fn.expand("%:t"))
vim.fn.setreg("+", vim.fn.expand("%:t")) -- Copy file name to clipboard vim.notify("Copied file name: " .. vim.fn.expand("%:t"))
vim.notify("Copied file name: " .. vim.fn.expand("%:t")) end,
end, desc = "Copy file name",
desc = "Copy file name", },
}, {
{ "<leader>fCr",
"<leader>fCr", function()
function() local cwd = vim.fn.getcwd()
local cwd = vim.fn.getcwd() -- Current working directory local full_path = vim.fn.expand("%:p")
local full_path = vim.fn.expand("%:p") -- Full file path local rel_path = full_path:sub(#cwd + 2)
local rel_path = full_path:sub(#cwd + 2) -- Remove cwd prefix and leading slash vim.fn.setreg("+", rel_path)
vim.fn.setreg("+", rel_path) -- Copy relative file path to clipboard vim.notify("Copied relative file path: " .. rel_path)
vim.notify("Copied relative file path: " .. rel_path) end,
end, desc = "Copy relative file path",
desc = "Copy relative file path", },
}, {
{ "<leader>?",
"<leader>?", function()
function() require("which-key").show({ global = false })
require("which-key").show({ global = false }) end,
end, desc = "Buffer Keymaps (which-key)",
desc = "Buffer Keymaps (which-key)", },
}, {
{ "<c-w><space>",
"<c-w><space>", function()
function() require("which-key").show({ keys = "<c-w>", loop = true })
require("which-key").show({ keys = "<c-w>", loop = true }) end,
end, desc = "Window Hydra Mode (which-key)",
desc = "Window Hydra Mode (which-key)", },
}, },
}, {
{ mode = { "n", "v" },
-- Nested mappings are allowed and can be added in any order { "<leader>q", "<cmd>q<cr>", desc = "Quit" },
-- Most attributes can be inherited or overridden on any level { "<leader>w", "<cmd>w<cr>", desc = "Write" },
-- There's no limit to the depth of nesting },
mode = { "n", "v" }, -- NORMAL and VISUAL mode })
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" }, -- no need to specify mode since it's inherited end,
{ "<leader>w", "<cmd>w<cr>", desc = "Write" }, }
},
})
-80
View File
@@ -1,80 +0,0 @@
{
"plugins": {
"blink.cmp": {
"rev": "b19413d",
"src": "https://github.com/saghen/blink.cmp",
"version": "1.0.0 - 2.0.0"
},
"conform.nvim": {
"rev": "8314f4c",
"src": "https://github.com/stevearc/conform.nvim"
},
"diffview.nvim": {
"rev": "4516612",
"src": "https://github.com/sindrets/diffview.nvim"
},
"fd": {
"rev": "5f95a78",
"src": "https://github.com/sharkdp/fd"
},
"gitsigns.nvim": {
"rev": "dfac404",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"log-highlight.nvim": {
"rev": "ca88628f6dd3b9bb46f9a7401669e24cf7de47a4",
"src": "https://github.com/fei6409/log-highlight.nvim"
},
"lualine.nvim": {
"rev": "47f91c4",
"src": "https://github.com/nvim-lualine/lualine.nvim"
},
"neo-tree.nvim": {
"rev": "f3df514",
"src": "https://github.com/nvim-neo-tree/neo-tree.nvim",
"version": "3.0.0 - 4.0.0"
},
"nui.nvim": {
"rev": "de74099",
"src": "https://github.com/MunifTanjim/nui.nvim"
},
"nvim": {
"rev": "6efc53e",
"src": "https://github.com/catppuccin/nvim"
},
"nvim-treesitter": {
"rev": "b033ab33",
"src": "https://github.com/nvim-treesitter/nvim-treesitter",
"version": "'main'"
},
"nvim-treesitter-textobjects": {
"rev": "28a3494",
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
"version": "'main'"
},
"nvim-web-devicons": {
"rev": "6788013",
"src": "https://github.com/nvim-tree/nvim-web-devicons"
},
"plenary.nvim": {
"rev": "b9fd522",
"src": "https://github.com/nvim-lua/plenary.nvim"
},
"ripgrep": {
"rev": "0a88ccc",
"src": "https://github.com/BurntSushi/ripgrep"
},
"telescope-fzf-native.nvim": {
"rev": "6fea601",
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
},
"telescope.nvim": {
"rev": "3333a52",
"src": "https://github.com/nvim-telescope/telescope.nvim"
},
"which-key.nvim": {
"rev": "3aab214",
"src": "https://github.com/folke/which-key.nvim"
}
}
}