From 292de198a6f8a75a794ec28f09d1cad66b2d403a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Sat, 20 Dec 2025 10:30:27 +0100 Subject: [PATCH] nvim: use vim.pack --- nvim/.config/nvim/init.lua | 65 +--- nvim/.config/nvim/lua/config/remap.lua | 8 +- nvim/.config/nvim/lua/config/remap/snacks.lua | 204 ------------- nvim/.config/nvim/lua/plugins/arrow.lua | 13 +- .../.config/nvim/lua/plugins/auto-session.lua | 15 +- nvim/.config/nvim/lua/plugins/colorscheme.lua | 21 +- nvim/.config/nvim/lua/plugins/conform.lua | 13 +- nvim/.config/nvim/lua/plugins/flash.lua | 44 +-- nvim/.config/nvim/lua/plugins/multicursor.lua | 139 +++++---- nvim/.config/nvim/lua/plugins/oil.lua | 15 +- nvim/.config/nvim/lua/plugins/snacks.lua | 287 +++++++++++++++--- nvim/.config/nvim/lua/plugins/treesitter.lua | 32 +- nvim/.config/nvim/nvim-pack-lock.json | 47 +++ 13 files changed, 475 insertions(+), 428 deletions(-) delete mode 100644 nvim/.config/nvim/lua/config/remap/snacks.lua create mode 100644 nvim/.config/nvim/nvim-pack-lock.json diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index eb88b6d..9fef9cc 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -2,59 +2,12 @@ require("config.options") require("config.remap") require("config.lsp") -local ok, paq = pcall(require, "paq") -if ok then - paq({ - "EdenEast/nightfox.nvim", - "ellisonleao/gruvbox.nvim", - "rmagatti/auto-session", - "stevearc/conform.nvim", - "otavioschwanck/arrow.nvim", - "folke/flash.nvim", - "folke/snacks.nvim", - "stevearc/oil.nvim", - { - "jake-stewart/multicursor.nvim", - branch = "1.0", - }, - { - "nvim-treesitter/nvim-treesitter-textobjects", - branch = "master", - }, - { - "nvim-treesitter/nvim-treesitter", - branch = "master", - build = ":TSUpdate", - }, - }) -else - print("plugin paq missing") -end - -local function load_plugin(name, setup) - local cfg = require(setup) - name = cfg.main or name - local ok, plugin = pcall(require, name) - if ok then - if cfg.config then - cfg.config(cfg.opts) - else - plugin.setup(cfg.opts) - end - if cfg.init then - cfg.init(plugin) - end - else - print("plugin " .. name .. " missing") - end -end - -load_plugin("arrow", "plugins.arrow") -load_plugin("nightfox", "plugins.colorscheme") -load_plugin("conform", "plugins.conform") -load_plugin("flash", "plugins.flash") -load_plugin("multicursor-nvim", "plugins.multicursor") -load_plugin("oil", "plugins.oil") -load_plugin("snacks", "plugins.snacks") -load_plugin("treesitter", "plugins.treesitter") -load_plugin("auto-session", "plugins.auto-session") +require("plugins.arrow") +require("plugins.auto-session") +require("plugins.colorscheme") +require("plugins.conform") +require("plugins.flash") +require("plugins.multicursor") +require("plugins.oil") +require("plugins.snacks") +require("plugins.treesitter") diff --git a/nvim/.config/nvim/lua/config/remap.lua b/nvim/.config/nvim/lua/config/remap.lua index a354018..3db4f1a 100644 --- a/nvim/.config/nvim/lua/config/remap.lua +++ b/nvim/.config/nvim/lua/config/remap.lua @@ -6,11 +6,7 @@ set("n", "", "j") set("n", "", "l") set("n", "", "nohlsearch") -set("n", "k", "cp") -set("n", "j", "cn") +set("n", "K", "cp") +set("n", "J", "cn") set("n", "x", "copen") set("n", "X", "cclose") - -set("n", "a", "AutoSession search") - -require("config.remap.snacks") diff --git a/nvim/.config/nvim/lua/config/remap/snacks.lua b/nvim/.config/nvim/lua/config/remap/snacks.lua deleted file mode 100644 index c5deb18..0000000 --- a/nvim/.config/nvim/lua/config/remap/snacks.lua +++ /dev/null @@ -1,204 +0,0 @@ -local set = vim.keymap.set - -set("n", "", function() - Snacks.picker.smart() -end, { desc = "Smart Find Files" }) - -set("n", "b", function() - Snacks.picker.buffers() -end, { desc = "Buffers" }) - -set("n", "e", function() - Snacks.explorer() -end, { desc = "File Explorer" }) - -set("n", "r", function() - Snacks.picker.recent() -end, { desc = "Recent files" }) - -set("n", "R", function() - Snacks.picker.resume() -end, { desc = "Resume" }) - -set("n", "p", function() - Snacks.picker.projects() -end, { desc = "Projects" }) - -set("n", "l", function() - Snacks.picker.lines() -end, { desc = "Buffer lines" }) - -set("n", "L", function() - Snacks.picker.grep_buffers() -end, { desc = "Grep Open Buffers" }) - -set("n", "F", function() - Snacks.picker.files() -end, { desc = "Find Files" }) - -set("n", "S", function() - Snacks.picker.grep() -end, { desc = "Grep" }) - -set("n", "B", function() - Snacks.picker.git_branches() -end, { desc = "Git Branches" }) - -set({ "n", "v" }, "xB", function() - Snacks.gitbrowse() -end, { desc = "Git Browse" }) - -set("n", "i", function() - Snacks.picker.git_log_line() -end, { desc = "Git Log Line" }) - -set("n", "I", function() - Snacks.picker.git_log() -end, { desc = "Git Log" }) - -set("n", "t", function() - Snacks.picker.git_status() -end, { desc = "Git Status" }) - -set("n", "H", function() - Snacks.picker.git_diff() -end, { desc = "Git Diff (Hunks)" }) - -set("n", "xS", function() - Snacks.picker.git_stash() -end, { desc = "Git Stash" }) - -set("n", "f", function() - Snacks.picker.git_files() -end, { desc = "Find Git Files" }) - -set("n", "s", function() - Snacks.picker.git_grep() -end, { desc = "Git Grep" }) - -set({ "n", "v" }, "o", function() - Snacks.picker.grep_word() -end, { desc = "Grep Visual Selection or Word" }) - -set("n", "g", function() - Snacks.lazygit() -end, { desc = "Lazygit" }) - -set("n", "G", function() - Snacks.lazygit.log_file() -end, { desc = "Git Log File" }) - -set("n", "m", function() - Snacks.picker.marks() -end, { desc = "Marks" }) - -set("n", "M", function() - Snacks.picker.man() -end, { desc = "Man pages" }) - -set("n", "U", function() - Snacks.picker.undo() -end, { desc = "Undo History" }) - -set("n", "q", function() - Snacks.picker.qflist() -end, { desc = "Quickfix list" }) - -set("n", "Q", function() - Snacks.picker.loclist() -end, { desc = "Location List" }) - -set("n", "xs", function() - Snacks.picker.colorschemes() -end, { desc = "Colorschemes" }) - -set("n", "n", function() - Snacks.notifier.show_history() -end, { desc = "Notification History" }) - -set("n", "N", function() - Snacks.picker.notifications() -end, { desc = "Notifications" }) - -set("n", "xC", function() - Snacks.picker.commands() -end, { desc = "Commands" }) - -set("n", "h", function() - Snacks.picker.keymaps() -end, { desc = "Keymaps" }) - -set("n", "xh", function() - Snacks.picker.highlights() -end, { desc = "Hightlights" }) - -set("n", "xc", function() - Snacks.picker.command_history() -end, { desc = "Command History" }) - -set("n", '"', function() - Snacks.picker.registers() -end, { desc = "Registers" }) - -set("n", "$", function() - Snacks.rename.rename_file() -end, { desc = "Rename File" }) - -set("n", "z", function() - Snacks.zen.zoom() -end, { desc = "Toggle Zoom" }) - -set("n", ".", function() - Snacks.scratch() -end, { desc = "Toggle Scratch Buffer" }) - -set("n", "x.", function() - Snacks.scratch.select() -end, { desc = "Select Scratch Buffer" }) - --- LSP - -set("n", "gd", function() - Snacks.picker.lsp_definitions() -end, { desc = "Goto Definition" }) - -set("n", "gD", function() - Snacks.picker.lsp_declarations() -end, { desc = "Goto Declaration" }) - -set("n", "grr", function() - Snacks.picker.lsp_references() -end, { desc = "References" }) - -set("n", "gI", function() - Snacks.picker.lsp_implementations() -end, { desc = "Goto Implementation" }) - -set("n", "gy", function() - Snacks.picker.lsp_type_definitions() -end, { desc = "Goto T[y]pe Definition" }) - -set("n", "w", function() - Snacks.picker.lsp_symbols() -end, { desc = "LSP Symbols" }) - -set("n", "d", function() - Snacks.picker.diagnostics_buffer() -end, { desc = "Buffer Diagnostics" }) - -set("n", "D", function() - Snacks.picker.diagnostics() -end, { desc = "Diagnostics" }) - -set("n", "W", function() - Snacks.picker.lsp_workspace_symbols() -end, { desc = "LSP Workspace Symbols" }) --- Terminal - -set({ "n", "t" }, "", function() - Snacks.terminal() -end, { desc = "Toggle Terminal" }) - -set({ "n", "t" }, "", function() - Snacks.terminal() -end, { desc = "which_key_ignore" }) diff --git a/nvim/.config/nvim/lua/plugins/arrow.lua b/nvim/.config/nvim/lua/plugins/arrow.lua index 979c676..26fd645 100644 --- a/nvim/.config/nvim/lua/plugins/arrow.lua +++ b/nvim/.config/nvim/lua/plugins/arrow.lua @@ -1,7 +1,12 @@ -return { - opts = { +vim.pack.add({ "https://github.com/otavioschwanck/arrow.nvim" }) + +local ok, arrow = pcall(require, "arrow") +if ok then + arrow.setup({ show_icons = false, leader_key = "_", buffer_leader_key = " m", - }, -} + }) +else + print("plugin arrow missing") +end diff --git a/nvim/.config/nvim/lua/plugins/auto-session.lua b/nvim/.config/nvim/lua/plugins/auto-session.lua index 2c56b14..efe2aa2 100644 --- a/nvim/.config/nvim/lua/plugins/auto-session.lua +++ b/nvim/.config/nvim/lua/plugins/auto-session.lua @@ -1,5 +1,12 @@ -return { - opts = { +vim.pack.add({ "https://github.com/rmagatti/auto-session" }) + +vim.keymap.set("n", "a", "AutoSession search") + +local ok, sess = pcall(require, "auto-session") +if ok then + sess.setup({ suppressed_dirs = { "~/", "~/src", "~/Downloads", "/" }, - }, -} + }) +else + print("plugin auto-session missing") +end diff --git a/nvim/.config/nvim/lua/plugins/colorscheme.lua b/nvim/.config/nvim/lua/plugins/colorscheme.lua index 40111cc..908f302 100644 --- a/nvim/.config/nvim/lua/plugins/colorscheme.lua +++ b/nvim/.config/nvim/lua/plugins/colorscheme.lua @@ -1,16 +1,5 @@ -return { - opts = { - specs = { - all = { - syntax = { - operator = "#bf8040", - }, - }, - }, - }, - init = function() - local cs = require("config.colorscheme") - cs.set_colorschemes("gruvbox", "gruvbox") - cs.update_colorscheme() - end, -} +vim.pack.add({ "https://github.com/ellisonleao/gruvbox.nvim" }) + +local cs = require("config.colorscheme") +cs.set_colorschemes("gruvbox", "gruvbox") +cs.update_colorscheme() diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index 5eb7ff1..966b6c8 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -1,5 +1,8 @@ -return { - opts = { +vim.pack.add({ "https://github.com/stevearc/conform.nvim" }) + +local ok, conform = pcall(require, "conform") +if ok then + conform.setup({ formatters_by_ft = { lua = { "stylua" }, }, @@ -7,5 +10,7 @@ return { timeout_ms = 500, lsp_format = "fallback", }, - }, -} + }) +else + print("plugin conform missing") +end diff --git a/nvim/.config/nvim/lua/plugins/flash.lua b/nvim/.config/nvim/lua/plugins/flash.lua index 382dc89..878cf75 100644 --- a/nvim/.config/nvim/lua/plugins/flash.lua +++ b/nvim/.config/nvim/lua/plugins/flash.lua @@ -1,24 +1,30 @@ -return { - opts = { +vim.pack.add({ "https://github.com/folke/flash.nvim" }) + +local ok, flash = pcall(require, "flash") + +if ok then + flash.setup({ modes = { char = { enabled = false, }, }, - }, - init = function() - local set = vim.keymap.set - set({ "n", "x", "o" }, "\\", function() - require("flash").jump() - end, { desc = "Flash" }) - set({ "n", "x", "o" }, "=", function() - require("flash").treesitter() - end, { desc = "Flash Treesitter" }) - set({ "o" }, "r", function() - require("flash").remote() - end, { desc = "Remote Flash" }) - set({ "n", "x", "o" }, " t", function() - require("flash").treesitter_search() - end, { desc = "Treesitter Search" }) - end, -} + }) + + local set = vim.keymap.set + + set({ "n", "x", "o" }, "\\", function() + require("flash").jump() + end, { desc = "Flash" }) + set({ "n", "x", "o" }, "=", function() + require("flash").treesitter() + end, { desc = "Flash Treesitter" }) + set({ "o" }, "r", function() + require("flash").remote() + end, { desc = "Remote Flash" }) + set({ "n", "x", "o" }, " t", function() + require("flash").treesitter_search() + end, { desc = "Treesitter Search" }) +else + print("plugin flash missing") +end diff --git a/nvim/.config/nvim/lua/plugins/multicursor.lua b/nvim/.config/nvim/lua/plugins/multicursor.lua index cefefee..75b005c 100644 --- a/nvim/.config/nvim/lua/plugins/multicursor.lua +++ b/nvim/.config/nvim/lua/plugins/multicursor.lua @@ -1,71 +1,76 @@ -return { - init = function(mc) - local set = vim.keymap.set +vim.pack.add({ { src = "https://github.com/jake-stewart/multicursor.nvim", version = "1.0" } }) - -- Add or skip cursor above/below the main cursor. - set({ "n", "x" }, "", function() - mc.lineAddCursor(-1) - end) - set({ "n", "x" }, "", function() - mc.lineAddCursor(1) - end) - set({ "n", "x" }, "", function() - mc.lineSkipCursor(-1) - end) - set({ "n", "x" }, "", function() - mc.lineSkipCursor(1) - end) +local ok, mc = pcall(require, "multicursor-nvim") +if ok then + mc.setup() - -- Add or skip adding a new cursor by matching word/selection - set({ "n", "x" }, "", function() - mc.matchAddCursor(1) - end) - set({ "n", "x" }, "", function() - mc.matchSkipCursor(1) - end) - set({ "n", "x" }, "", function() - mc.matchAddCursor(-1) - end) - set({ "n", "x" }, "", function() - mc.matchSkipCursor(-1) + local set = vim.keymap.set + + -- Add or skip cursor above/below the main cursor. + set({ "n", "x" }, "", function() + mc.lineAddCursor(-1) + end) + set({ "n", "x" }, "", function() + mc.lineAddCursor(1) + end) + set({ "n", "x" }, "", function() + mc.lineSkipCursor(-1) + end) + set({ "n", "x" }, "", function() + mc.lineSkipCursor(1) + end) + + -- Add or skip adding a new cursor by matching word/selection + set({ "n", "x" }, "", function() + mc.matchAddCursor(1) + end) + set({ "n", "x" }, "", function() + mc.matchSkipCursor(1) + end) + set({ "n", "x" }, "", function() + mc.matchAddCursor(-1) + end) + set({ "n", "x" }, "", function() + mc.matchSkipCursor(-1) + end) + + -- Add and remove cursors with control + left click. + set("n", "", mc.handleMouse) + set("n", "", mc.handleMouseDrag) + set("n", "", mc.handleMouseRelease) + + -- Disable and enable cursors. + set({ "n", "x" }, "", mc.toggleCursor) + + -- Mappings defined in a keymap layer only apply when there are + -- multiple cursors. This lets you have overlapping mappings. + mc.addKeymapLayer(function(layerSet) + -- Select a different cursor as the main one. + layerSet({ "n", "x" }, "", mc.prevCursor) + layerSet({ "n", "x" }, "", mc.nextCursor) + + -- Delete the main cursor. + layerSet({ "n", "x" }, "x", mc.deleteCursor) + + -- Enable and clear cursors using escape. + layerSet("n", "", function() + if not mc.cursorsEnabled() then + mc.enableCursors() + else + mc.clearCursors() + end end) + end) - -- Add and remove cursors with control + left click. - set("n", "", mc.handleMouse) - set("n", "", mc.handleMouseDrag) - set("n", "", mc.handleMouseRelease) - - -- Disable and enable cursors. - set({ "n", "x" }, "", mc.toggleCursor) - - -- Mappings defined in a keymap layer only apply when there are - -- multiple cursors. This lets you have overlapping mappings. - mc.addKeymapLayer(function(layerSet) - -- Select a different cursor as the main one. - layerSet({ "n", "x" }, "", mc.prevCursor) - layerSet({ "n", "x" }, "", mc.nextCursor) - - -- Delete the main cursor. - layerSet({ "n", "x" }, "x", mc.deleteCursor) - - -- Enable and clear cursors using escape. - layerSet("n", "", function() - if not mc.cursorsEnabled() then - mc.enableCursors() - else - mc.clearCursors() - end - end) - end) - - -- Customize how cursors look. - local hl = vim.api.nvim_set_hl - hl(0, "MultiCursorCursor", { reverse = true }) - hl(0, "MultiCursorVisual", { link = "Visual" }) - hl(0, "MultiCursorSign", { link = "SignColumn" }) - hl(0, "MultiCursorMatchPreview", { link = "Search" }) - hl(0, "MultiCursorDisabledCursor", { reverse = true }) - hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) - hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) - end, -} + -- Customize how cursors look. + local hl = vim.api.nvim_set_hl + hl(0, "MultiCursorCursor", { reverse = true }) + hl(0, "MultiCursorVisual", { link = "Visual" }) + hl(0, "MultiCursorSign", { link = "SignColumn" }) + hl(0, "MultiCursorMatchPreview", { link = "Search" }) + hl(0, "MultiCursorDisabledCursor", { reverse = true }) + hl(0, "MultiCursorDisabledVisual", { link = "Visual" }) + hl(0, "MultiCursorDisabledSign", { link = "SignColumn" }) +else + print("plugin multicursor-nvim missing") +end diff --git a/nvim/.config/nvim/lua/plugins/oil.lua b/nvim/.config/nvim/lua/plugins/oil.lua index 177d203..8156942 100644 --- a/nvim/.config/nvim/lua/plugins/oil.lua +++ b/nvim/.config/nvim/lua/plugins/oil.lua @@ -1,5 +1,10 @@ -return { - init = function() - vim.keymap.set("n", "-", "Oil", { desc = "Oil file manager" }) - end, -} +vim.pack.add({ "https://github.com/stevearc/oil.nvim" }) + +local ok, oil = pcall(require, "oil") +if ok then + oil.setup() +else + print("plugin oil missing") +end + +vim.keymap.set("n", "-", "Oil", { desc = "Oil file manager" }) diff --git a/nvim/.config/nvim/lua/plugins/snacks.lua b/nvim/.config/nvim/lua/plugins/snacks.lua index c4f3196..19db346 100644 --- a/nvim/.config/nvim/lua/plugins/snacks.lua +++ b/nvim/.config/nvim/lua/plugins/snacks.lua @@ -1,41 +1,252 @@ -return { - init = function() - vim.api.nvim_create_autocmd("VimEnter", { - callback = function() - -- Setup some globals for debugging (lazy-loaded) - _G.dd = function(...) - Snacks.debug.inspect(...) - end - _G.bt = function() - Snacks.debug.backtrace() - end +vim.pack.add({ "https://github.com/folke/snacks.nvim" }) - -- Override print to use snacks for `:=` command - if vim.fn.has("nvim-0.11") == 1 then - vim._print = function(_, ...) - dd(...) - end - else - vim.print = _G.dd - end +local ok, snacks = pcall(require, "snacks") +if ok then + snacks.setup({ + picker = { enabled = true }, + }) +else + print("plugin snacks missing") +end - -- Create some toggle mappings - Snacks.toggle.option("spell", { name = "Spelling" }):map("us") - Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") - Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") - Snacks.toggle.diagnostics():map("ud") - Snacks.toggle.line_number():map("ul") - Snacks.toggle - .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) - :map("uc") - Snacks.toggle.treesitter():map("uT") - Snacks.toggle - .option("background", { off = "light", on = "dark", name = "Dark Background" }) - :map("ub") - Snacks.toggle.inlay_hints():map("uh") - Snacks.toggle.indent():map("ug") - Snacks.toggle.dim():map("uD") - end, - }) +local set = vim.keymap.set + +set("n", "", function() + Snacks.picker.smart() +end, { desc = "Smart Find Files" }) + +set("n", "b", function() + Snacks.picker.buffers() +end, { desc = "Buffers" }) + +set("n", "e", function() + Snacks.explorer() +end, { desc = "File Explorer" }) + +set("n", "r", function() + Snacks.picker.recent() +end, { desc = "Recent files" }) + +set("n", "R", function() + Snacks.picker.resume() +end, { desc = "Resume" }) + +set("n", "p", function() + Snacks.picker.projects() +end, { desc = "Projects" }) + +set("n", "l", function() + Snacks.picker.lines() +end, { desc = "Buffer lines" }) + +set("n", "L", function() + Snacks.picker.grep_buffers() +end, { desc = "Grep Open Buffers" }) + +set("n", "F", function() + Snacks.picker.files() +end, { desc = "Find Files" }) + +set("n", "S", function() + Snacks.picker.grep() +end, { desc = "Grep" }) + +set("n", "B", function() + Snacks.picker.git_branches() +end, { desc = "Git Branches" }) + +set({ "n", "v" }, "xB", function() + Snacks.gitbrowse() +end, { desc = "Git Browse" }) + +set("n", "i", function() + Snacks.picker.git_log_line() +end, { desc = "Git Log Line" }) + +set("n", "I", function() + Snacks.picker.git_log() +end, { desc = "Git Log" }) + +set("n", "t", function() + Snacks.picker.git_status() +end, { desc = "Git Status" }) + +set("n", "H", function() + Snacks.picker.git_diff() +end, { desc = "Git Diff (Hunks)" }) + +set("n", "xS", function() + Snacks.picker.git_stash() +end, { desc = "Git Stash" }) + +set("n", "f", function() + Snacks.picker.git_files() +end, { desc = "Find Git Files" }) + +set("n", "s", function() + Snacks.picker.git_grep() +end, { desc = "Git Grep" }) + +set({ "n", "v" }, "o", function() + Snacks.picker.grep_word() +end, { desc = "Grep Visual Selection or Word" }) + +set("n", "g", function() + Snacks.lazygit() +end, { desc = "Lazygit" }) + +set("n", "G", function() + Snacks.lazygit.log_file() +end, { desc = "Git Log File" }) + +set("n", "m", function() + Snacks.picker.marks() +end, { desc = "Marks" }) + +set("n", "M", function() + Snacks.picker.man() +end, { desc = "Man pages" }) + +set("n", "U", function() + Snacks.picker.undo() +end, { desc = "Undo History" }) + +set("n", "q", function() + Snacks.picker.qflist() +end, { desc = "Quickfix list" }) + +set("n", "Q", function() + Snacks.picker.loclist() +end, { desc = "Location List" }) + +set("n", "xs", function() + Snacks.picker.colorschemes() +end, { desc = "Colorschemes" }) + +set("n", "n", function() + Snacks.notifier.show_history() +end, { desc = "Notification History" }) + +set("n", "N", function() + Snacks.picker.notifications() +end, { desc = "Notifications" }) + +set("n", "xC", function() + Snacks.picker.commands() +end, { desc = "Commands" }) + +set("n", "h", function() + Snacks.picker.keymaps() +end, { desc = "Keymaps" }) + +set("n", "xh", function() + Snacks.picker.highlights() +end, { desc = "Hightlights" }) + +set("n", "xc", function() + Snacks.picker.command_history() +end, { desc = "Command History" }) + +set("n", '"', function() + Snacks.picker.registers() +end, { desc = "Registers" }) + +set("n", "$", function() + Snacks.rename.rename_file() +end, { desc = "Rename File" }) + +set("n", "z", function() + Snacks.zen.zoom() +end, { desc = "Toggle Zoom" }) + +set("n", ".", function() + Snacks.scratch() +end, { desc = "Toggle Scratch Buffer" }) + +set("n", "x.", function() + Snacks.scratch.select() +end, { desc = "Select Scratch Buffer" }) + +-- LSP + +set("n", "gd", function() + Snacks.picker.lsp_definitions() +end, { desc = "Goto Definition" }) + +set("n", "gD", function() + Snacks.picker.lsp_declarations() +end, { desc = "Goto Declaration" }) + +set("n", "grr", function() + Snacks.picker.lsp_references() +end, { desc = "References" }) + +set("n", "gI", function() + Snacks.picker.lsp_implementations() +end, { desc = "Goto Implementation" }) + +set("n", "gy", function() + Snacks.picker.lsp_type_definitions() +end, { desc = "Goto T[y]pe Definition" }) + +set("n", "w", function() + Snacks.picker.lsp_symbols() +end, { desc = "LSP Symbols" }) + +set("n", "d", function() + Snacks.picker.diagnostics_buffer() +end, { desc = "Buffer Diagnostics" }) + +set("n", "D", function() + Snacks.picker.diagnostics() +end, { desc = "Diagnostics" }) + +set("n", "W", function() + Snacks.picker.lsp_workspace_symbols() +end, { desc = "LSP Workspace Symbols" }) + +-- Terminal + +set({ "n", "t" }, "", function() + Snacks.terminal() +end, { desc = "Toggle Terminal" }) + +set({ "n", "t" }, "", function() + Snacks.terminal() +end, { desc = "which_key_ignore" }) + +vim.api.nvim_create_autocmd("VimEnter", { + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + + -- Override print to use snacks for `:=` command + if vim.fn.has("nvim-0.11") == 1 then + vim._print = function(_, ...) + dd(...) + end + else + vim.print = _G.dd + end + + -- Create some toggle mappings + Snacks.toggle.option("spell", { name = "Spelling" }):map("us") + Snacks.toggle.option("wrap", { name = "Wrap" }):map("uw") + Snacks.toggle.option("relativenumber", { name = "Relative Number" }):map("uL") + Snacks.toggle.diagnostics():map("ud") + Snacks.toggle.line_number():map("ul") + Snacks.toggle + .option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }) + :map("uc") + Snacks.toggle.treesitter():map("uT") + Snacks.toggle.option("background", { off = "light", on = "dark", name = "Dark Background" }):map("ub") + Snacks.toggle.inlay_hints():map("uh") + Snacks.toggle.indent():map("ug") + Snacks.toggle.dim():map("uD") end, -} +}) diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua index 9c8a43f..ff49a3d 100644 --- a/nvim/.config/nvim/lua/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -1,6 +1,26 @@ -return { - main = "nvim-treesitter.configs", - opts = { +-- run ":TSUpdate" after plugin update +-- If hooks need to run on install, run this before `vim.pack.add()` +vim.api.nvim_create_autocmd("PackChanged", { + group = vim.api.nvim_create_augroup("nvim-treesitter-update", { clear = true }), + callback = function(ev) + local name, kind = ev.data.spec.name, ev.data.kind + if name == "nvim-treesitter" and kind == "update" then + if not ev.data.active then + vim.cmd.packadd("nvim-treesitter") + end + vim.cmd("TSUpdate") + print("TSUpdate done.") + end + end, +}) + +vim.pack.add({ + { src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", version = "master" }, + { src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "master" }, +}) +local ok, configs = pcall(require, "nvim-treesitter.configs") +if ok then + configs.setup({ highlight = { enable = true, }, @@ -58,5 +78,7 @@ return { }, }, }, - }, -} + }) +else + print("plugin nvim-treesitter.configs missing") +end diff --git a/nvim/.config/nvim/nvim-pack-lock.json b/nvim/.config/nvim/nvim-pack-lock.json new file mode 100644 index 0000000..df87679 --- /dev/null +++ b/nvim/.config/nvim/nvim-pack-lock.json @@ -0,0 +1,47 @@ +{ + "plugins": { + "arrow.nvim": { + "rev": "6e0f726f55f99332dd726a53effd6813786b6d49", + "src": "https://github.com/otavioschwanck/arrow.nvim" + }, + "auto-session": { + "rev": "292492ab7af4bd8b9e37e28508bc8ce995722fd5", + "src": "https://github.com/rmagatti/auto-session" + }, + "conform.nvim": { + "rev": "328c2f1dda56f933d3337a1316e1020ba30ba6aa", + "src": "https://github.com/stevearc/conform.nvim" + }, + "flash.nvim": { + "rev": "fcea7ff883235d9024dc41e638f164a450c14ca2", + "src": "https://github.com/folke/flash.nvim" + }, + "gruvbox.nvim": { + "rev": "5e0a460d8e0f7f669c158dedd5f9ae2bcac31437", + "src": "https://github.com/ellisonleao/gruvbox.nvim" + }, + "multicursor.nvim": { + "rev": "a0ea3303a6c4b233cf3272fb1e358d4c842e5260", + "src": "https://github.com/jake-stewart/multicursor.nvim", + "version": "'1.0'" + }, + "nvim-treesitter": { + "rev": "42fc28ba918343ebfd5565147a42a26580579482", + "src": "https://github.com/nvim-treesitter/nvim-treesitter", + "version": "'master'" + }, + "nvim-treesitter-textobjects": { + "rev": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", + "version": "'master'" + }, + "oil.nvim": { + "rev": "cbcb3f997f6f261c577b943ec94e4ef55108dd95", + "src": "https://github.com/stevearc/oil.nvim" + }, + "snacks.nvim": { + "rev": "fe7cfe9800a182274d0f868a74b7263b8c0c020b", + "src": "https://github.com/folke/snacks.nvim" + } + } +} \ No newline at end of file