From 22a1fcb0b57db3611ea1d708a4a9d16dd37cee24 Mon Sep 17 00:00:00 2001 From: pmcc Date: Sun, 2 Aug 2026 12:00:14 -0400 Subject: [PATCH] Migrate to vim.pack --- dot_config/nvim/AGENTS.md | 74 +++ dot_config/nvim/init.lua | 17 +- dot_config/nvim/lua/plugins/blink.lua | 39 +- dot_config/nvim/lua/plugins/conform.lua | 119 ++-- dot_config/nvim/lua/plugins/git.lua | 566 +++++++++--------- dot_config/nvim/lua/plugins/init.lua | 28 + dot_config/nvim/lua/plugins/log-highlight.lua | 6 +- dot_config/nvim/lua/plugins/lualine.lua | 103 ++-- dot_config/nvim/lua/plugins/markdown.lua | 12 +- dot_config/nvim/lua/plugins/neotree.lua | 15 +- dot_config/nvim/lua/plugins/telescope.lua | 30 +- dot_config/nvim/lua/plugins/theme.lua | 13 +- dot_config/nvim/lua/plugins/treesitter.lua | 164 +++-- dot_config/nvim/lua/plugins/whichkey.lua | 190 +++--- dot_config/nvim/lua/plugins/zig.lua | 3 + dot_config/nvim/nvim-pack-lock.json | 79 +++ 16 files changed, 795 insertions(+), 663 deletions(-) create mode 100644 dot_config/nvim/AGENTS.md create mode 100644 dot_config/nvim/lua/plugins/init.lua create mode 100644 dot_config/nvim/lua/plugins/zig.lua create mode 100644 dot_config/nvim/nvim-pack-lock.json diff --git a/dot_config/nvim/AGENTS.md b/dot_config/nvim/AGENTS.md new file mode 100644 index 0000000..0cebfcc --- /dev/null +++ b/dot_config/nvim/AGENTS.md @@ -0,0 +1,74 @@ +# Neovim Config + +Plugin management uses Neovim's native `vim.pack` (0.12+). No lazy.nvim. + +## Layout + +- `init.lua` — entry point: `require("config")` then `require("plugins")` +- `lua/config/*.lua` — core settings (options, keymaps, LSP, autocmds) +- `lua/plugins/init.lua` — loads every plugin module in order, hosts `PackChanged` build hooks +- `lua/plugins/.lua` — one self-contained module per plugin +- `nvim-pack-lock.json` — lock file, auto-updated by `vim.pack`, commit it + +## Plugin module structure + +Each `lua/plugins/.lua` is self-contained: it declares its own `vim.pack.add` specs (including shared deps like `nvim-lua/plenary.nvim`, `nvim-tree/nvim-web-devicons`, `MunifTanjim/nui.nvim` — repeated adds are idempotent), then runs setup/config code directly. All plugins load eagerly at startup; there is no lazy loading. + +Example: + +```lua +vim.pack.add({ + { src = "https://github.com/owner/repo.nvim" }, +}) + +require("repo").setup({ ... }) +``` + +## Adding a new plugin + +1. Create `lua/plugins/.lua` with a `vim.pack.add` spec and its config +2. Add `require("plugins.")` to `lua/plugins/init.lua` (theme first if it affects colorscheme/highlights) +3. Restart nvim — the plugin is cloned automatically on first startup + +## Spec conventions + +- `version` — pin to a semver release: `version = vim.version.range("^1")`; use a branch name string (e.g. `version = "main"`) only when the plugin requires it (nvim-treesitter and its textobjects do) +- `name` — set only when the repo name is undesirable (e.g. `catppuccin/nvim` is installed as `catppuccin`) +- Shared deps listed explicitly in every module that needs them + +## Build steps + +There is no `build` field. Post-install/update steps run from the `PackChanged` autocmd in `lua/plugins/init.lua`, keyed by plugin name. It must stay registered before the first `vim.pack.add` call, so keep new hooks in that file: + +```lua +-- in the PackChanged callback in lua/plugins/init.lua +if name == "my-plugin" and (kind == "install" or kind == "update") then + vim.system({ "make" }, { cwd = path }) +end +``` + +Current hooks: `make` for telescope-fzf-native, parser `update` for nvim-treesitter. + +## Useful commands + +`vim.pack` has no `:Pack*` user commands — everything goes through `:lua`. Plugin names are the installed directory names (e.g. `telescope-fzf-native.nvim`). + +- `:lua vim.pack.update()` — fetch and update all plugins to their pinned version (or latest branch), updating `nvim-pack-lock.json` +- `:lua vim.pack.update({ "gitsigns.nvim" })` — update a single plugin +- `:lua vim.pack.update(nil, { offline = true })` — update using cached refs, no network fetch +- `:lua vim.pack.update(nil, { target = "lockfile" })` — restore all plugins to the revisions in `nvim-pack-lock.json` (rollback) +- `:lua vim.pack.get()` — list all installed plugins with spec, path, revision, active status +- `:lua vim.pack.add({ { src = "https://github.com/owner/repo.nvim" } })` — install/register a plugin on the fly (restart required to persist in config) +- `:lua vim.pack.del("name")` — delete a plugin directory and its lock entry + +## Updating / removing + +- Update everything: `:lua vim.pack.update()` (see commands above for variants) +- Remove a plugin: delete its entry from `vim.pack.add` calls and its `lua/plugins/.lua` + require in `lua/plugins/init.lua`, then run `:lua vim.pack.del("name")` to delete the directory and lock entry + +## Pitfalls + +- First startup installs missing plugins and asks for confirmation — expected behavior, not an error +- The first `vim.pack.add` call in a session triggers installs, so `PackChanged` hooks must be registered in `lua/plugins/init.lua` before the requires +- Only install actual Neovim plugins via `vim.pack` — CLI tools (e.g. `fd`, `ripgrep`) must not be added +- Plugins already on disk are not re-checked against their spec on startup; run `vim.pack.update()` to sync revisions diff --git a/dot_config/nvim/init.lua b/dot_config/nvim/init.lua index a712baf..d0a5154 100644 --- a/dot_config/nvim/init.lua +++ b/dot_config/nvim/init.lua @@ -2,19 +2,4 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " require("config") - --- 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 }, -}) +require("plugins") diff --git a/dot_config/nvim/lua/plugins/blink.lua b/dot_config/nvim/lua/plugins/blink.lua index 72cee23..79511db 100644 --- a/dot_config/nvim/lua/plugins/blink.lua +++ b/dot_config/nvim/lua/plugins/blink.lua @@ -1,21 +1,18 @@ -return { - "saghen/blink.cmp", - version = "^1", - event = "InsertEnter", -- Lazy's native equivalent of the manual InsertEnter augroup - config = function() - require("blink.cmp").setup({ - keymap = { preset = "super-tab" }, - appearance = { - nerd_font_variant = "mono", - use_nvim_cmp_as_default = true, - }, - completion = { - documentation = { auto_show = false }, - }, - sources = { - default = { "lsp", "path", "snippets", "buffer" }, - }, - fuzzy = { implementation = "prefer_rust_with_warning" }, - }) - end, -} +vim.pack.add({ + { src = "https://github.com/saghen/blink.cmp", version = vim.version.range("^1") }, +}) + +require("blink.cmp").setup({ + keymap = { preset = "super-tab" }, + appearance = { + nerd_font_variant = "mono", + use_nvim_cmp_as_default = true, + }, + completion = { + documentation = { auto_show = false }, + }, + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + }, + fuzzy = { implementation = "prefer_rust_with_warning" }, +}) diff --git a/dot_config/nvim/lua/plugins/conform.lua b/dot_config/nvim/lua/plugins/conform.lua index 066224c..f4c642a 100644 --- a/dot_config/nvim/lua/plugins/conform.lua +++ b/dot_config/nvim/lua/plugins/conform.lua @@ -1,67 +1,66 @@ -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", - }, - }) +vim.pack.add({ + { src = "https://github.com/stevearc/conform.nvim" }, +}) - 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 }) +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", + }, +}) - 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" }) +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 }) - local auto_format = 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" }) - vim.keymap.set("n", "uf", function() - auto_format = not auto_format - if auto_format then - vim.cmd("FormatEnable") - else - vim.cmd("FormatDisable") - end - end, { desc = "Toggle Autoformat" }) +local auto_format = true - vim.keymap.set({ "n", "v" }, "cn", "ConformInfo", { desc = "Conform Info" }) +vim.keymap.set("n", "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" }, "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" }, "cn", "ConformInfo", { desc = "Conform Info" }) - vim.keymap.set({ "n", "v" }, "cF", function() - require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 }) - end, { desc = "Format Injected Langs" }) - end, -} +vim.keymap.set({ "n", "v" }, "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" }, "cF", function() + require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 }) +end, { desc = "Format Injected Langs" }) diff --git a/dot_config/nvim/lua/plugins/git.lua b/dot_config/nvim/lua/plugins/git.lua index 9e6a9e2..b2607b6 100644 --- a/dot_config/nvim/lua/plugins/git.lua +++ b/dot_config/nvim/lua/plugins/git.lua @@ -1,289 +1,283 @@ -return { - { - "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 = ", - ", - 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") +vim.pack.add({ + { src = "https://github.com/lewis6991/gitsigns.nvim" }, + { src = "https://github.com/sindrets/diffview.nvim" }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, +}) - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - vim.keymap.set(mode, l, r, opts) - end - - -- Navigation - map("n", "]c", function() - if vim.wo.diff then vim.cmd.normal({ "]c", bang = true }) - else gitsigns.nav_hunk("next") end - end) - map("n", "[c", function() - if vim.wo.diff then vim.cmd.normal({ "[c", bang = true }) - else gitsigns.nav_hunk("prev") end - end) - - -- Actions - map("n", "hs", gitsigns.stage_hunk) - map("n", "hr", gitsigns.reset_hunk) - map("v", "hs", function() gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) - map("v", "hr", function() gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) - map("n", "hS", gitsigns.stage_buffer) - map("n", "hR", gitsigns.reset_buffer) - map("n", "hp", gitsigns.preview_hunk) - map("n", "hi", gitsigns.preview_hunk_inline) - map("n", "hb", function() gitsigns.blame_line({ full = true }) end) - map("n", "hd", gitsigns.diffthis) - map("n", "hD", function() gitsigns.diffthis("~") end) - map("n", "hQ", function() gitsigns.setqflist("all") end) - map("n", "hq", gitsigns.setqflist) - - -- Toggles - map("n", "tb", gitsigns.toggle_current_line_blame) - map("n", "tw", gitsigns.toggle_word_diff) - - -- Text object - map({ "o", "x" }, "ih", gitsigns.select_hunk) - end, - }) - end, +require("gitsigns").setup({ + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "_" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "┆" }, }, - { - "sindrets/diffview.nvim", - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local actions = require("diffview.actions") - - require("diffview").setup({ - diff_binaries = false, - enhanced_diff_hl = false, - git_cmd = { "git" }, - hg_cmd = { "hg" }, - use_icons = true, - show_help_hints = true, - watch_index = true, - icons = { - folder_closed = "", - folder_open = "", - }, - signs = { - fold_closed = "", - fold_open = "", - done = "✓", - }, - view = { - default = { - layout = "diff2_horizontal", - disable_diagnostics = false, - winbar_info = false, - }, - merge_tool = { - layout = "diff3_horizontal", - disable_diagnostics = true, - winbar_info = true, - }, - file_history = { - layout = "diff2_horizontal", - disable_diagnostics = false, - winbar_info = false, - }, - }, - file_panel = { - listing_style = "tree", - tree_options = { - flatten_dirs = true, - folder_statuses = "only_folded", - }, - win_config = { - position = "left", - width = 35, - win_opts = {}, - }, - }, - file_history_panel = { - log_options = { - git = { - single_file = { diff_merges = "combined" }, - multi_file = { diff_merges = "first-parent" }, - }, - hg = { - single_file = {}, - multi_file = {}, - }, - }, - win_config = { - position = "bottom", - height = 16, - win_opts = {}, - }, - }, - commit_log_panel = { - win_config = {}, - }, - default_args = { - DiffviewOpen = {}, - DiffviewFileHistory = {}, - }, - hooks = {}, - keymaps = { - disable_defaults = false, - view = { - { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, - { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, - { "n", "gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, - { "n", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, - { "n", "b", actions.toggle_files, { desc = "Toggle the file panel." } }, - { "n", "g", actions.cycle_layout, { desc = "Cycle through available layouts." } }, - { "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", "co", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } }, - { "n", "ct", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } }, - { "n", "cb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } }, - { "n", "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", "cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } }, - { "n", "cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } }, - { "n", "cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } }, - { "n", "cA", actions.conflict_choose_all("all"), { desc = "Choose all versions for the whole file" } }, - { "n", "g?", actions.help("view"), { desc = "Open the help panel" } }, - }, - file_panel = { - { "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } }, - { "n", "", 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", "", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } }, - { "n", "", 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", "", actions.scroll_view(-0.25), { desc = "Scroll the view up" } }, - { "n", "", actions.scroll_view(0.25), { desc = "Scroll the view down" } }, - { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, - { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, - { "n", "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", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, - { "n", "b", actions.toggle_files, { desc = "Toggle the file panel" } }, - { "n", "g", 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", "cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } }, - { "n", "cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } }, - { "n", "cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } }, - { "n", "cA", actions.conflict_choose_all("all"), { desc = "Choose all versions 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", "", 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", "", 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", "", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } }, - { "n", "", 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.scroll_view(-0.25), { desc = "Scroll the view up" } }, - { "n", "", actions.scroll_view(0.25), { desc = "Scroll the view down" } }, - { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, - { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, - { "n", "gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, - { "n", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, - { "n", "b", actions.toggle_files, { desc = "Toggle the file panel" } }, - { "n", "g", actions.cycle_layout, { desc = "Cycle available layouts" } }, - { "n", "g?", actions.help("file_history_panel"), { desc = "Open the help panel" } }, - }, - option_panel = { - { "n", "", 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", "", actions.close, { desc = "Close help menu" } }, - }, - }, - }) - end, + 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 = ", - ", + 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") + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map("n", "]c", function() + if vim.wo.diff then vim.cmd.normal({ "]c", bang = true }) + else gitsigns.nav_hunk("next") end + end) + map("n", "[c", function() + if vim.wo.diff then vim.cmd.normal({ "[c", bang = true }) + else gitsigns.nav_hunk("prev") end + end) + + -- Actions + map("n", "hs", gitsigns.stage_hunk) + map("n", "hr", gitsigns.reset_hunk) + map("v", "hs", function() gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) + map("v", "hr", function() gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) end) + map("n", "hS", gitsigns.stage_buffer) + map("n", "hR", gitsigns.reset_buffer) + map("n", "hp", gitsigns.preview_hunk) + map("n", "hi", gitsigns.preview_hunk_inline) + map("n", "hb", function() gitsigns.blame_line({ full = true }) end) + map("n", "hd", gitsigns.diffthis) + map("n", "hD", function() gitsigns.diffthis("~") end) + map("n", "hQ", function() gitsigns.setqflist("all") end) + map("n", "hq", gitsigns.setqflist) + + -- Toggles + map("n", "tb", gitsigns.toggle_current_line_blame) + map("n", "tw", gitsigns.toggle_word_diff) + + -- Text object + map({ "o", "x" }, "ih", gitsigns.select_hunk) + end, +}) + +local actions = require("diffview.actions") + +require("diffview").setup({ + diff_binaries = false, + enhanced_diff_hl = false, + git_cmd = { "git" }, + hg_cmd = { "hg" }, + use_icons = true, + show_help_hints = true, + watch_index = true, + icons = { + folder_closed = "", + folder_open = "", + }, + signs = { + fold_closed = "", + fold_open = "", + done = "✓", + }, + view = { + default = { + layout = "diff2_horizontal", + disable_diagnostics = false, + winbar_info = false, + }, + merge_tool = { + layout = "diff3_horizontal", + disable_diagnostics = true, + winbar_info = true, + }, + file_history = { + layout = "diff2_horizontal", + disable_diagnostics = false, + winbar_info = false, + }, + }, + file_panel = { + listing_style = "tree", + tree_options = { + flatten_dirs = true, + folder_statuses = "only_folded", + }, + win_config = { + position = "left", + width = 35, + win_opts = {}, + }, + }, + file_history_panel = { + log_options = { + git = { + single_file = { diff_merges = "combined" }, + multi_file = { diff_merges = "first-parent" }, + }, + hg = { + single_file = {}, + multi_file = {}, + }, + }, + win_config = { + position = "bottom", + height = 16, + win_opts = {}, + }, + }, + commit_log_panel = { + win_config = {}, + }, + default_args = { + DiffviewOpen = {}, + DiffviewFileHistory = {}, + }, + hooks = {}, + keymaps = { + disable_defaults = false, + view = { + { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, + { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, + { "n", "gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, + { "n", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, + { "n", "b", actions.toggle_files, { desc = "Toggle the file panel." } }, + { "n", "g", actions.cycle_layout, { desc = "Cycle through available layouts." } }, + { "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", "co", actions.conflict_choose("ours"), { desc = "Choose the OURS version of a conflict" } }, + { "n", "ct", actions.conflict_choose("theirs"), { desc = "Choose the THEIRS version of a conflict" } }, + { "n", "cb", actions.conflict_choose("base"), { desc = "Choose the BASE version of a conflict" } }, + { "n", "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", "cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } }, + { "n", "cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } }, + { "n", "cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } }, + { "n", "cA", actions.conflict_choose_all("all"), { desc = "Choose all versions for the whole file" } }, + { "n", "g?", actions.help("view"), { desc = "Open the help panel" } }, + }, + file_panel = { + { "n", "j", actions.next_entry, { desc = "Bring the cursor to the next file entry" } }, + { "n", "", 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", "", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } }, + { "n", "", 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", "", actions.scroll_view(-0.25), { desc = "Scroll the view up" } }, + { "n", "", actions.scroll_view(0.25), { desc = "Scroll the view down" } }, + { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, + { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, + { "n", "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", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, + { "n", "b", actions.toggle_files, { desc = "Toggle the file panel" } }, + { "n", "g", 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", "cO", actions.conflict_choose_all("ours"), { desc = "Choose OURS for the whole file" } }, + { "n", "cT", actions.conflict_choose_all("theirs"), { desc = "Choose THEIRS for the whole file" } }, + { "n", "cB", actions.conflict_choose_all("base"), { desc = "Choose BASE for the whole file" } }, + { "n", "cA", actions.conflict_choose_all("all"), { desc = "Choose all versions 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", "", 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", "", 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", "", actions.prev_entry, { desc = "Bring the cursor to the previous file entry" } }, + { "n", "", 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.scroll_view(-0.25), { desc = "Scroll the view up" } }, + { "n", "", actions.scroll_view(0.25), { desc = "Scroll the view down" } }, + { "n", "", actions.select_next_entry, { desc = "Open the diff for the next file" } }, + { "n", "", 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", "", actions.goto_file_split, { desc = "Open the file in a new split" } }, + { "n", "gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } }, + { "n", "e", actions.focus_files, { desc = "Bring focus to the file panel" } }, + { "n", "b", actions.toggle_files, { desc = "Toggle the file panel" } }, + { "n", "g", actions.cycle_layout, { desc = "Cycle available layouts" } }, + { "n", "g?", actions.help("file_history_panel"), { desc = "Open the help panel" } }, + }, + option_panel = { + { "n", "", 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", "", actions.close, { desc = "Close help menu" } }, + }, + }, +}) diff --git a/dot_config/nvim/lua/plugins/init.lua b/dot_config/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..37d9853 --- /dev/null +++ b/dot_config/nvim/lua/plugins/init.lua @@ -0,0 +1,28 @@ +-- PackChanged hooks must be registered before the first vim.pack.add() call, +-- otherwise installs triggered during the initial startup would miss them. +vim.api.nvim_create_autocmd("PackChanged", { + callback = function(ev) + local name, kind, path = ev.data.spec.name, ev.data.kind, ev.data.path + if name == "telescope-fzf-native.nvim" and (kind == "install" or kind == "update") then + vim.system({ "make" }, { cwd = path }) + elseif name == "nvim-treesitter" and (kind == "install" or kind == "update") then + if not ev.data.active then + vim.cmd.packadd("nvim-treesitter") + end + pcall(require("nvim-treesitter").update) + end + end, +}) + +require("plugins.theme") +require("plugins.treesitter") +require("plugins.blink") +require("plugins.whichkey") +require("plugins.lualine") +require("plugins.telescope") +require("plugins.neotree") +require("plugins.conform") +require("plugins.git") +require("plugins.markdown") +require("plugins.log-highlight") +require("plugins.zig") diff --git a/dot_config/nvim/lua/plugins/log-highlight.lua b/dot_config/nvim/lua/plugins/log-highlight.lua index 5ca8dc2..f7d42b3 100644 --- a/dot_config/nvim/lua/plugins/log-highlight.lua +++ b/dot_config/nvim/lua/plugins/log-highlight.lua @@ -1,3 +1,3 @@ -return { - "fei6409/log-highlight.nvim", -} +vim.pack.add({ + { src = "https://github.com/fei6409/log-highlight.nvim" }, +}) diff --git a/dot_config/nvim/lua/plugins/lualine.lua b/dot_config/nvim/lua/plugins/lualine.lua index 5a8cca1..40de117 100644 --- a/dot_config/nvim/lua/plugins/lualine.lua +++ b/dot_config/nvim/lua/plugins/lualine.lua @@ -1,53 +1,52 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("lualine").setup({ - options = { - icons_enabled = true, - theme = "auto", - component_separators = { left = "", right = "" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - always_show_tabline = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - refresh_time = 16, - events = { - "WinEnter", "BufEnter", "BufWritePost", "SessionLoadPost", - "FileChangedShellPost", "VimResized", "Filetype", - "CursorMoved", "CursorMovedI", "ModeChanged", - }, - }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename" }, - lualine_x = { "encoding", "fileformat", "filetype" }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "filename" }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, +vim.pack.add({ + { src = "https://github.com/nvim-lualine/lualine.nvim" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, +}) + +require("lualine").setup({ + options = { + icons_enabled = true, + theme = "auto", + component_separators = { left = "", right = "" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, winbar = {}, - inactive_winbar = {}, - extensions = {}, - }) - end, -} + }, + ignore_focus = {}, + always_divide_middle = true, + always_show_tabline = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + refresh_time = 16, + events = { + "WinEnter", "BufEnter", "BufWritePost", "SessionLoadPost", + "FileChangedShellPost", "VimResized", "Filetype", + "CursorMoved", "CursorMovedI", "ModeChanged", + }, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, +}) diff --git a/dot_config/nvim/lua/plugins/markdown.lua b/dot_config/nvim/lua/plugins/markdown.lua index 01af41d..57fd760 100644 --- a/dot_config/nvim/lua/plugins/markdown.lua +++ b/dot_config/nvim/lua/plugins/markdown.lua @@ -1,7 +1,5 @@ -return { - "MeanderingProgrammer/render-markdown.nvim", - dependencies = { - "nvim-treesitter/nvim-treesitter", - "nvim-tree/nvim-web-devicons", - }, -} +vim.pack.add({ + { src = "https://github.com/MeanderingProgrammer/render-markdown.nvim" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, +}) diff --git a/dot_config/nvim/lua/plugins/neotree.lua b/dot_config/nvim/lua/plugins/neotree.lua index 233e913..559c82a 100644 --- a/dot_config/nvim/lua/plugins/neotree.lua +++ b/dot_config/nvim/lua/plugins/neotree.lua @@ -1,9 +1,6 @@ -return { - "nvim-neo-tree/neo-tree.nvim", - version = "3.*", - dependencies = { - "nvim-lua/plenary.nvim", - "MunifTanjim/nui.nvim", - "nvim-tree/nvim-web-devicons", - }, -} +vim.pack.add({ + { src = "https://github.com/nvim-neo-tree/neo-tree.nvim", version = vim.version.range("3.*") }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, + { src = "https://github.com/MunifTanjim/nui.nvim" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, +}) diff --git a/dot_config/nvim/lua/plugins/telescope.lua b/dot_config/nvim/lua/plugins/telescope.lua index 7420176..64e2186 100644 --- a/dot_config/nvim/lua/plugins/telescope.lua +++ b/dot_config/nvim/lua/plugins/telescope.lua @@ -1,18 +1,12 @@ -return { - "nvim-telescope/telescope.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - { - "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - }, - }, - config = function() - local builtin = require("telescope.builtin") - vim.keymap.set("n", "ff", builtin.find_files, { desc = "Telescope find files" }) - vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Telescope live grep" }) - vim.keymap.set("n", "fb", builtin.buffers, { desc = "Telescope buffers" }) - vim.keymap.set("n", "fh", builtin.help_tags, { desc = "Telescope help tags" }) - end, -} +vim.pack.add({ + { src = "https://github.com/nvim-telescope/telescope.nvim" }, + { src = "https://github.com/nvim-lua/plenary.nvim" }, + { src = "https://github.com/nvim-tree/nvim-web-devicons" }, + { src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" }, +}) + +local builtin = require("telescope.builtin") +vim.keymap.set("n", "ff", builtin.find_files, { desc = "Telescope find files" }) +vim.keymap.set("n", "fg", builtin.live_grep, { desc = "Telescope live grep" }) +vim.keymap.set("n", "fb", builtin.buffers, { desc = "Telescope buffers" }) +vim.keymap.set("n", "fh", builtin.help_tags, { desc = "Telescope help tags" }) diff --git a/dot_config/nvim/lua/plugins/theme.lua b/dot_config/nvim/lua/plugins/theme.lua index 9e94983..b50f787 100644 --- a/dot_config/nvim/lua/plugins/theme.lua +++ b/dot_config/nvim/lua/plugins/theme.lua @@ -1,8 +1,5 @@ -return { - "catppuccin/nvim", - name = "catppuccin", - priority = 1000, -- Load before other plugins so colorscheme is set first - config = function() - vim.cmd("colorscheme catppuccin") - end, -} +vim.pack.add({ + { src = "https://github.com/catppuccin/nvim", name = "catppuccin" }, +}) + +vim.cmd("colorscheme catppuccin") diff --git a/dot_config/nvim/lua/plugins/treesitter.lua b/dot_config/nvim/lua/plugins/treesitter.lua index dac2d33..eeb3d6b 100644 --- a/dot_config/nvim/lua/plugins/treesitter.lua +++ b/dot_config/nvim/lua/plugins/treesitter.lua @@ -1,91 +1,81 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - 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.pack.add({ + { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", version = "main" }, +}) - vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" - vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" +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.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, +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, +}) + +require("nvim-treesitter-textobjects").setup({ + select = { + enable = true, + lookahead = true, + selection_modes = { + ["@parameter.outer"] = "v", + ["@function.outer"] = "V", + ["@class.outer"] = "", + }, + include_surrounding_whitespace = false, }, - { - "nvim-treesitter/nvim-treesitter-textobjects", - 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"] = "", - }, - 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] - 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, + 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] + 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 diff --git a/dot_config/nvim/lua/plugins/whichkey.lua b/dot_config/nvim/lua/plugins/whichkey.lua index ed0d037..21d54d1 100644 --- a/dot_config/nvim/lua/plugins/whichkey.lua +++ b/dot_config/nvim/lua/plugins/whichkey.lua @@ -1,96 +1,94 @@ -return { - "folke/which-key.nvim", - event = "VeryLazy", - config = function() - local wk = require("which-key") - wk.setup({ - preset = "helix", - }) - wk.add({ - { "", group = "tabs" }, - { "c", group = "code" }, - { "d", group = "debug" }, - { "D", group = "Diffview", icon = { icon = "", color = "orange" } }, - { "p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } }, - { "dp", group = "profiler" }, - { "f", group = "file/find" }, - { "g", group = "git" }, - { "gh", group = "hunks" }, - { "q", group = "quit/session" }, - { "s", group = "search" }, - { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, - { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, - { "[", group = "prev" }, - { "]", group = "next" }, - { "g", group = "goto" }, - { "gs", group = "surround" }, - { "z", group = "fold" }, - { - "b", - group = "buffer", - expand = function() - return require("which-key.extras").expand.buf() - end, - }, - { - "w", - group = "windows", - proxy = "", - expand = function() - return require("which-key.extras").expand.win() - end, - }, - { "gx", desc = "Open with system app" }, - { - "fC", - group = "Copy Path", - { - "fCf", - function() - vim.fn.setreg("+", vim.fn.expand("%:p")) - vim.notify("Copied full file path: " .. vim.fn.expand("%:p")) - end, - desc = "Copy full file path", - }, - { - "fCn", - function() - vim.fn.setreg("+", vim.fn.expand("%:t")) - vim.notify("Copied file name: " .. vim.fn.expand("%:t")) - end, - desc = "Copy file name", - }, - { - "fCr", - function() - local cwd = vim.fn.getcwd() - local full_path = vim.fn.expand("%:p") - local rel_path = full_path:sub(#cwd + 2) - vim.fn.setreg("+", rel_path) - vim.notify("Copied relative file path: " .. rel_path) - end, - desc = "Copy relative file path", - }, - { - "?", - function() - require("which-key").show({ global = false }) - end, - desc = "Buffer Keymaps (which-key)", - }, - { - "", - function() - require("which-key").show({ keys = "", loop = true }) - end, - desc = "Window Hydra Mode (which-key)", - }, - }, - { - mode = { "n", "v" }, - { "q", "q", desc = "Quit" }, - { "w", "w", desc = "Write" }, - }, - }) - end, -} +vim.pack.add({ + { src = "https://github.com/folke/which-key.nvim" }, +}) + +local wk = require("which-key") +wk.setup({ + preset = "helix", +}) +wk.add({ + { "", group = "tabs" }, + { "c", group = "code" }, + { "d", group = "debug" }, + { "D", group = "Diffview", icon = { icon = "", color = "orange" } }, + { "p", group = "Yanky", icon = { icon = "󰃮 ", color = "yellow" } }, + { "dp", group = "profiler" }, + { "f", group = "file/find" }, + { "g", group = "git" }, + { "gh", group = "hunks" }, + { "q", group = "quit/session" }, + { "s", group = "search" }, + { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" } }, + { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" } }, + { "[", group = "prev" }, + { "]", group = "next" }, + { "g", group = "goto" }, + { "gs", group = "surround" }, + { "z", group = "fold" }, + { + "b", + group = "buffer", + expand = function() + return require("which-key.extras").expand.buf() + end, + }, + { + "w", + group = "windows", + proxy = "", + expand = function() + return require("which-key.extras").expand.win() + end, + }, + { "gx", desc = "Open with system app" }, + { + "fC", + group = "Copy Path", + { + "fCf", + function() + vim.fn.setreg("+", vim.fn.expand("%:p")) + vim.notify("Copied full file path: " .. vim.fn.expand("%:p")) + end, + desc = "Copy full file path", + }, + { + "fCn", + function() + vim.fn.setreg("+", vim.fn.expand("%:t")) + vim.notify("Copied file name: " .. vim.fn.expand("%:t")) + end, + desc = "Copy file name", + }, + { + "fCr", + function() + local cwd = vim.fn.getcwd() + local full_path = vim.fn.expand("%:p") + local rel_path = full_path:sub(#cwd + 2) + vim.fn.setreg("+", rel_path) + vim.notify("Copied relative file path: " .. rel_path) + end, + desc = "Copy relative file path", + }, + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Keymaps (which-key)", + }, + { + "", + function() + require("which-key").show({ keys = "", loop = true }) + end, + desc = "Window Hydra Mode (which-key)", + }, + }, + { + mode = { "n", "v" }, + { "q", "q", desc = "Quit" }, + { "w", "w", desc = "Write" }, + }, +}) diff --git a/dot_config/nvim/lua/plugins/zig.lua b/dot_config/nvim/lua/plugins/zig.lua new file mode 100644 index 0000000..10ce947 --- /dev/null +++ b/dot_config/nvim/lua/plugins/zig.lua @@ -0,0 +1,3 @@ +vim.pack.add({ + { src = "https://codeberg.org/ziglang/zig.vim" }, +}) diff --git a/dot_config/nvim/nvim-pack-lock.json b/dot_config/nvim/nvim-pack-lock.json new file mode 100644 index 0000000..9cc6cc4 --- /dev/null +++ b/dot_config/nvim/nvim-pack-lock.json @@ -0,0 +1,79 @@ +{ + "plugins": { + "blink.cmp": { + "rev": "78336bc89ee5365633bcf754d93df01678b5c08f", + "src": "https://github.com/saghen/blink.cmp", + "version": "1.0.0 - 2.0.0" + }, + "catppuccin": { + "rev": "79e2049a0fdf7ec840f8463fe1d962c94493196b", + "src": "https://github.com/catppuccin/nvim" + }, + "conform.nvim": { + "rev": "619363c30309d29ffa631e67c8183f2a72caa373", + "src": "https://github.com/stevearc/conform.nvim" + }, + "diffview.nvim": { + "rev": "4516612fe98ff56ae0415a259ff6361a89419b0a", + "src": "https://github.com/sindrets/diffview.nvim" + }, + "gitsigns.nvim": { + "rev": "31d6fb2d618bca1482b9f274751ead5f03461408", + "src": "https://github.com/lewis6991/gitsigns.nvim" + }, + "log-highlight.nvim": { + "rev": "b2e00cfd41ca94338265a595f3f3f423d9f9322e", + "src": "https://github.com/fei6409/log-highlight.nvim" + }, + "lualine.nvim": { + "rev": "221ce6b2d999187044529f49da6554a92f740a96", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, + "neo-tree.nvim": { + "rev": "83e7a2982fd12b9c3d35bc39dd5877cd91a02a61", + "src": "https://github.com/nvim-neo-tree/neo-tree.nvim", + "version": "3.0.0 - 4.0.0" + }, + "nui.nvim": { + "rev": "de740991c12411b663994b2860f1a4fd0937c130", + "src": "https://github.com/MunifTanjim/nui.nvim" + }, + "nvim-treesitter": { + "rev": "7b6cc8949f9999c5ed91436cbe24aa5f99c42025", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-treesitter-textobjects": { + "rev": "898ee307df58f854d11cd7edd06472574d48014e", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", + "version": "'main'" + }, + "nvim-web-devicons": { + "rev": "2ae6958df7ced50baac5035cec0c15799eedfbf7", + "src": "https://github.com/nvim-tree/nvim-web-devicons" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "render-markdown.nvim": { + "rev": "f422cb5c6855f150e2ddcfaf44e7157b98b34f6a", + "src": "https://github.com/MeanderingProgrammer/render-markdown.nvim" + }, + "telescope-fzf-native.nvim": { + "rev": "b25b749b9db64d375d782094e2b9dce53ad53a40", + "src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim" + }, + "telescope.nvim": { + "rev": "427b576c16792edad01a92b89721d923c19ad60f", + "src": "https://github.com/nvim-telescope/telescope.nvim" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + }, + "zig.vim": { + "rev": "61109e5166f2bdb7578493a0220a92c43627fc82", + "src": "https://codeberg.org/ziglang/zig.vim" + } + } +}