From 4a698f6e1fafcbb31bd08f07d7b2617740984458 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pankowski?= Date: Sun, 23 Nov 2025 08:59:27 +0100 Subject: [PATCH] nvim: migrate to paq package manager --- nvim/.config/nvim/init.lua | 55 ++- nvim/.config/nvim/lua/config/colorscheme.lua | 13 +- nvim/.config/nvim/lua/plugins/arrow.lua | 1 - nvim/.config/nvim/lua/plugins/colorscheme.lua | 23 +- nvim/.config/nvim/lua/plugins/conform.lua | 1 - nvim/.config/nvim/lua/plugins/flash.lua | 60 +-- nvim/.config/nvim/lua/plugins/multicursor.lua | 7 +- nvim/.config/nvim/lua/plugins/oil.lua | 9 +- nvim/.config/nvim/lua/plugins/snacks.lua | 373 +++++++----------- nvim/.config/nvim/lua/plugins/treesitter.lua | 7 - 10 files changed, 228 insertions(+), 321 deletions(-) diff --git a/nvim/.config/nvim/init.lua b/nvim/.config/nvim/init.lua index 40defdb..287e1a8 100644 --- a/nvim/.config/nvim/init.lua +++ b/nvim/.config/nvim/init.lua @@ -1,4 +1,57 @@ require("config.options") require("config.remap") -require("config.lazy") require("config.lsp") + +local ok, paq = pcall(require, "paq") +if ok then + paq({ + "EdenEast/nightfox.nvim", + "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") diff --git a/nvim/.config/nvim/lua/config/colorscheme.lua b/nvim/.config/nvim/lua/config/colorscheme.lua index 4e7d559..a48327d 100644 --- a/nvim/.config/nvim/lua/config/colorscheme.lua +++ b/nvim/.config/nvim/lua/config/colorscheme.lua @@ -17,10 +17,13 @@ function M.terminalbg() end end -function M.update_colorscheme() - vim.o.background = M.terminalbg() - if colorschemes then - vim.cmd.colorscheme(colorschemes[vim.o.background]) +function M.update_colorscheme(only_if_changed) + local next = M.terminalbg() + if not only_if_changed or next ~= vim.o.background then + vim.o.background = next + if colorschemes then + vim.cmd.colorscheme(colorschemes[next]) + end end end @@ -42,7 +45,7 @@ local function watch(fname) fname, {}, vim.schedule_wrap(function(...) - M.update_colorscheme() + M.update_colorscheme(true) w:stop() watch(fname) end) diff --git a/nvim/.config/nvim/lua/plugins/arrow.lua b/nvim/.config/nvim/lua/plugins/arrow.lua index f2fc69f..979c676 100644 --- a/nvim/.config/nvim/lua/plugins/arrow.lua +++ b/nvim/.config/nvim/lua/plugins/arrow.lua @@ -1,5 +1,4 @@ return { - "otavioschwanck/arrow.nvim", opts = { show_icons = false, leader_key = "_", diff --git a/nvim/.config/nvim/lua/plugins/colorscheme.lua b/nvim/.config/nvim/lua/plugins/colorscheme.lua index 9236fa5..3488c9c 100644 --- a/nvim/.config/nvim/lua/plugins/colorscheme.lua +++ b/nvim/.config/nvim/lua/plugins/colorscheme.lua @@ -1,19 +1,16 @@ return { - { - "EdenEast/nightfox.nvim", - opts = { - specs = { - all = { - syntax = { - operator = "#bf8040", - }, + opts = { + specs = { + all = { + syntax = { + operator = "#bf8040", }, }, }, - init = function() - local cs = require("config.colorscheme") - cs.set_colorschemes("nightfox", "dayfox") - cs.update_colorscheme() - end, }, + init = function() + local cs = require("config.colorscheme") + cs.set_colorschemes("nightfox", "dayfox") + cs.update_colorscheme() + end, } diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index d2bfee5..5eb7ff1 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -1,5 +1,4 @@ return { - "stevearc/conform.nvim", opts = { formatters_by_ft = { lua = { "stylua" }, diff --git a/nvim/.config/nvim/lua/plugins/flash.lua b/nvim/.config/nvim/lua/plugins/flash.lua index b62701f..382dc89 100644 --- a/nvim/.config/nvim/lua/plugins/flash.lua +++ b/nvim/.config/nvim/lua/plugins/flash.lua @@ -1,7 +1,4 @@ return { - "folke/flash.nvim", - event = "VeryLazy", - ---@type Flash.Config opts = { modes = { char = { @@ -9,46 +6,19 @@ return { }, }, }, - keys = { - { - "\\", - mode = { "n", "x", "o" }, - function() - require("flash").jump() - end, - desc = "Flash", - }, - { - "=", - mode = { "n", "x", "o" }, - function() - require("flash").treesitter() - end, - desc = "Flash Treesitter", - }, - { - " r", - mode = "o", - function() - require("flash").remote() - end, - desc = "Remote Flash", - }, - { - " R", - mode = { "o", "x" }, - function() - require("flash").treesitter_search() - end, - desc = "Treesitter Search", - }, - { - "", - mode = { "c" }, - function() - require("flash").toggle() - end, - desc = "Toggle Flash Search", - }, - }, + 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, } diff --git a/nvim/.config/nvim/lua/plugins/multicursor.lua b/nvim/.config/nvim/lua/plugins/multicursor.lua index 4735709..cefefee 100644 --- a/nvim/.config/nvim/lua/plugins/multicursor.lua +++ b/nvim/.config/nvim/lua/plugins/multicursor.lua @@ -1,10 +1,5 @@ return { - "jake-stewart/multicursor.nvim", - branch = "1.0", - config = function() - local mc = require("multicursor-nvim") - mc.setup() - + init = function(mc) local set = vim.keymap.set -- Add or skip cursor above/below the main cursor. diff --git a/nvim/.config/nvim/lua/plugins/oil.lua b/nvim/.config/nvim/lua/plugins/oil.lua index 45a9bb5..177d203 100644 --- a/nvim/.config/nvim/lua/plugins/oil.lua +++ b/nvim/.config/nvim/lua/plugins/oil.lua @@ -1,8 +1,5 @@ return { - "stevearc/oil.nvim", - opts = {}, - lazy = false, - keys = { - { "-", "Oil", desc = "Oil file manager" }, - }, + init = function() + vim.keymap.set("n", "-", "Oil", { desc = "Oil file manager" }) + end, } diff --git a/nvim/.config/nvim/lua/plugins/snacks.lua b/nvim/.config/nvim/lua/plugins/snacks.lua index 8ef4e94..5c09ff3 100644 --- a/nvim/.config/nvim/lua/plugins/snacks.lua +++ b/nvim/.config/nvim/lua/plugins/snacks.lua @@ -1,241 +1,142 @@ return { - "folke/snacks.nvim", - priority = 1000, - lazy = false, - keys = { - { - "", - function() - Snacks.picker.smart() - end, - desc = "Smart Find Files", - }, - { - "a", - function() - Snacks.picker.buffers() - end, - desc = "Buffers", - }, - { - "r", - function() - Snacks.picker.recent() - end, - desc = "Recent files", - }, - { - "R", - function() - Snacks.picker.resume() - end, - desc = "Resume", - }, - { - "b", - function() - Snacks.picker.lines() - end, - desc = "Buffer lines", - }, - { - "B", - function() - Snacks.picker.grep_buffers() - end, - desc = "Grep Open Buffers", - }, - { - "f", - function() - Snacks.picker.files() - end, - desc = "Find Files", - }, - { - "s", - function() - Snacks.picker.grep() - end, - desc = "Grep", - }, - { - "S", - function() - Snacks.picker.git_status() - end, - desc = "Git Status", - }, - { - "g", - function() - Snacks.picker.git_files() - end, - desc = "Find Git Files", - }, - { - "G", - function() - Snacks.picker.git_grep() - end, - desc = "Git Grep", - }, - { - "l", - function() - Snacks.lazygit() - end, - desc = "Lazygit", - }, - { - "L", - function() - Snacks.lazygit.log_file() - end, - desc = "Lazygit log file", - }, - { - "n", - function() - Snacks.notifier.show_history() - end, - desc = "Notification History", - }, - { - "N", - function() - Snacks.picker.notifications() - end, - desc = "Notifications", - }, - { - "C", - function() - Snacks.picker.commands() - end, - desc = "Commands", - }, - { - "h", - function() - Snacks.picker.keymaps() - end, - desc = "Keymaps", - }, - { - ":", - function() - Snacks.picker.command_history() - end, - desc = "Command History", - }, - { - '"', - function() - Snacks.picker.registers() - end, - desc = "Registers", - }, - { - "$", - function() - Snacks.rename.rename_file() - end, - desc = "Rename File", - }, - { - "z", - function() - Snacks.zen.zoom() - end, - desc = "Toggle Zoom", - }, - -- LSP - { - "gd", - function() - Snacks.picker.lsp_definitions() - end, - desc = "Goto Definition", - }, - { - "gD", - function() - Snacks.picker.lsp_declarations() - end, - desc = "Goto Declaration", - }, - { - "gr", - function() - Snacks.picker.lsp_references() - end, - nowait = true, - desc = "References", - }, - { - "gI", - function() - Snacks.picker.lsp_implementations() - end, - desc = "Goto Implementation", - }, - { - "gy", - function() - Snacks.picker.lsp_type_definitions() - end, - desc = "Goto T[y]pe Definition", - }, - { - "w", - function() - Snacks.picker.lsp_symbols() - end, - desc = "LSP Symbols", - }, - { - "d", - function() - Snacks.picker.diagnostics_buffer() - end, - desc = "Buffer Diagnostics", - }, - { - "D", - function() - Snacks.picker.diagnostics() - end, - desc = "Diagnostics", - }, - { - "W", - function() - Snacks.picker.lsp_workspace_symbols() - end, - desc = "LSP Workspace Symbols", - }, - -- Terminal - { - "", - function() - Snacks.terminal() - end, - mode = { "n", "t" }, - desc = "Toggle Terminal", - }, - { - "", - function() - Snacks.terminal() - end, - mode = { "n", "t" }, - desc = "which_key_ignore", - }, - }, init = function() - vim.api.nvim_create_autocmd("User", { - pattern = "VeryLazy", + local set = vim.keymap.set + + set("n", "", function() + Snacks.picker.smart() + end, { desc = "Smart Find Files" }) + + set("n", "", function() + Snacks.picker.smart() + end, { desc = "Smart Find Files" }) + + set("n", "a", function() + Snacks.picker.buffers() + end, { desc = "Buffers" }) + + set("n", "r", function() + Snacks.picker.recent() + end, { desc = "Recent files" }) + + set("n", "R", function() + Snacks.picker.resume() + end, { desc = "Resume" }) + + set("n", "b", function() + Snacks.picker.lines() + end, { desc = "Buffer lines" }) + + set("n", "B", 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", "S", function() + Snacks.picker.git_status() + end, { desc = "Git Status" }) + + set("n", "g", function() + Snacks.picker.git_files() + end, { desc = "Find Git Files" }) + + set("n", "G", function() + Snacks.picker.git_grep() + end, { desc = "Git Grep" }) + + set("n", "l", function() + Snacks.lazygit() + end, { desc = "Lazygit" }) + + set("n", "L", function() + Snacks.lazygit.log_file() + end, { desc = "Lazygit log file" }) + + set("n", "n", function() + Snacks.notifier.show_history() + end, { desc = "Notification History" }) + + set("n", "N", function() + Snacks.picker.notifications() + end, { desc = "Notifications" }) + + set("n", "C", function() + Snacks.picker.commands() + end, { desc = "Commands" }) + + set("n", "h", function() + Snacks.picker.keymaps() + end, { desc = "Keymaps" }) + + set("n", ":", 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" }) + -- 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", "gr", 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(...) diff --git a/nvim/.config/nvim/lua/plugins/treesitter.lua b/nvim/.config/nvim/lua/plugins/treesitter.lua index ac8f500..9c8a43f 100644 --- a/nvim/.config/nvim/lua/plugins/treesitter.lua +++ b/nvim/.config/nvim/lua/plugins/treesitter.lua @@ -1,12 +1,5 @@ return { - "nvim-treesitter/nvim-treesitter", - branch = "master", - lazy = false, - build = ":TSUpdate", main = "nvim-treesitter.configs", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, opts = { highlight = { enable = true,