From 957ec52ca8894ba6bb61bbf59e041696e58d9b19 Mon Sep 17 00:00:00 2001 From: Bartek Stalewski Date: Sat, 28 Jun 2025 01:11:53 +0200 Subject: [PATCH] (neovim) make plugins setup modular, huge changes to keymaps --- config/common/nvim/lua/config/keymaps.lua | 32 ++-- config/common/nvim/lua/plugins/disabled.lua | 11 ++ config/common/nvim/lua/plugins/init.lua | 178 ------------------ config/common/nvim/lua/plugins/lsp.lua | 10 + config/common/nvim/lua/plugins/lualine.lua | 40 ++++ config/common/nvim/lua/plugins/monokai.lua | 15 ++ config/common/nvim/lua/plugins/snacks.lua | 28 +++ config/common/nvim/lua/plugins/treesitter.lua | 18 ++ config/common/nvim/lua/plugins/which-key.lua | 35 ++++ 9 files changed, 168 insertions(+), 199 deletions(-) create mode 100644 config/common/nvim/lua/plugins/disabled.lua delete mode 100644 config/common/nvim/lua/plugins/init.lua create mode 100644 config/common/nvim/lua/plugins/lsp.lua create mode 100644 config/common/nvim/lua/plugins/lualine.lua create mode 100644 config/common/nvim/lua/plugins/monokai.lua create mode 100644 config/common/nvim/lua/plugins/snacks.lua create mode 100644 config/common/nvim/lua/plugins/treesitter.lua create mode 100644 config/common/nvim/lua/plugins/which-key.lua diff --git a/config/common/nvim/lua/config/keymaps.lua b/config/common/nvim/lua/config/keymaps.lua index 2ba9c96..5cda86d 100644 --- a/config/common/nvim/lua/config/keymaps.lua +++ b/config/common/nvim/lua/config/keymaps.lua @@ -8,7 +8,6 @@ local nomap = vim.keymap.del nomap("n", "") nomap("n", ",") nomap("n", ".") -nomap("n", ":") nomap("n", "?") nomap("n", "K") nomap("n", "l") @@ -17,32 +16,21 @@ nomap("n", "S") nomap("n", "`") nomap("n", "bb") -nomap("n", "bd") nomap("n", "bD") nomap("n", "bo") nomap("n", "E") -nomap("n", "fb") nomap("n", "fB") -nomap("n", "fc") nomap("n", "fe") nomap("n", "fE") -nomap("n", "ff") -nomap("n", "fF") -nomap("n", "fg") nomap("n", "fn") nomap("n", "fp") -nomap("n", "fr") nomap("n", "fR") nomap("n", "ft") nomap("n", "fT") -nomap("n", "gb") -nomap("n", "gB") -nomap("n", "gs") nomap("n", "gY") -nomap("n", "gd") nomap("n", "gS") nomap("n", "qq") @@ -55,17 +43,16 @@ map("i", "", "A") map("n", "", "wq!", { desc = "Save and Exit", remap = true }) map("n", "", "w", { desc = "Switch Pane", remap = true }) + map("n", "-", "s", { desc = "Split Horizontally", remap = true }) -map("n", "|", "v", { desc = "Split Vertically", remap = true }) map("n", "/", "gcc", { desc = "Toggle Comments", remap = true }) - +map("n", "|", "v", { desc = "Split Vertically", remap = true }) +map("n", "bl", function() + Snacks.picker.buffers() +end, { desc = "Buffer List", remap = true }) +map("n", "b[", "bprevious", { desc = "Previous Buffer", remap = true }) +map("n", "b]", "bnext", { desc = "Next Buffer", remap = true }) map("n", "bn", "enew", { desc = "New Buffer", remap = true }) -map("n", "bl", "bnext", { desc = "Next Buffer", remap = true }) -map("n", "bh", "bprevious", { desc = "Previous Buffer", remap = true }) -map("n", "bq", function() - Snacks.bufdelete() -end, { desc = "Delete Buffer" }) - map("n", "h", "set hlsearch!", { desc = "Toggle hlsearch", remap = true }) map( "n", @@ -73,5 +60,8 @@ map( 'execute "set colorcolumn=" . (&colorcolumn == "" ? "80,120" : "")', { desc = "Toggle Columns", remap = true } ) --- n (toggle decorations) moved to configuration of snacks.nvim in plugins/init.lua +map("n", "T", function() + Snacks.terminal() +end, { desc = "Terminal", remap = true }) + map("v", "/", "gc", { desc = "Toggle Comments", remap = true }) diff --git a/config/common/nvim/lua/plugins/disabled.lua b/config/common/nvim/lua/plugins/disabled.lua new file mode 100644 index 0000000..e2fa062 --- /dev/null +++ b/config/common/nvim/lua/plugins/disabled.lua @@ -0,0 +1,11 @@ +return { + { "akinsho/bufferline.nvim", enabled = false }, + { "catppuccin/nvim", enabled = false }, + { "folke/persistence.nvim", enabled = false }, + { "folke/tokyonight.nvim", enabled = false }, + { "folke/trouble.nvim", enabled = false }, + { "MagickDuck/grug-far.nvim", enabled = false }, + { "nvim-neo-tree/neo-tree.nvim", enabled = false }, + { "todo-comments.nvim", enabled = false }, + { "windwp/nvim-ts-autotag", enabled = false }, +} diff --git a/config/common/nvim/lua/plugins/init.lua b/config/common/nvim/lua/plugins/init.lua deleted file mode 100644 index 2257896..0000000 --- a/config/common/nvim/lua/plugins/init.lua +++ /dev/null @@ -1,178 +0,0 @@ -return { - { "akinsho/bufferline.nvim", enabled = false }, - { "catppuccin/nvim", enabled = false }, - { "folke/persistence.nvim", enabled = false }, - { "folke/todo-comments.nvim", enabled = false }, - { "folke/tokyonight.nvim", enabled = false }, - { "folke/trouble.nvim", enabled = false }, - { "MagickDuck/grug-far.nvim", enabled = false }, - { "nvim-neo-tree/neo-tree.nvim", enabled = false }, - { "windwp/nvim-ts-autotag", enabled = false }, - - { - "folke/snacks.nvim", - -- opts = { - -- dashboard = { enabled = false }, - -- }, - keys = { - { - "n", - function() - vim.cmd("set number!") - vim.cmd('execute "set signcolumn=" . (&signcolumn == "yes" ? "no" : "yes")') - if Snacks.indent.enabled then - Snacks.indent.disable() - else - Snacks.indent.enable() - end - end, - desc = "Toggle Decorations", - }, - { - "e", - function() - Snacks.explorer() - end, - desc = "File Explorer", - }, - }, - }, - - { - "folke/which-key.nvim", - event = "VeryLazy", - opts_extend = { "spec" }, - opts = { - preset = "helix", - defaults = {}, - spec = { - { - mode = { "n", "v" }, - { "", group = "tabs", hidden = true }, - { "c", group = "code", hidden = true }, - { "d", group = "debug", hidden = true }, - { "dp", group = "profiler", hidden = true }, - { "g", group = "git", hidden = true }, - { "gh", group = "hunks", hidden = true }, - { "q", group = "quit/session", hidden = true }, - { "s", group = "search", hidden = true }, - { "u", group = "ui", icon = { icon = "󰙵 ", color = "cyan" }, hidden = true }, - { "x", group = "diagnostics/quickfix", icon = { icon = "󱖫 ", color = "green" }, hidden = true }, - { - "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, - hidden = true, - }, - -- better descriptions - { "gx", desc = "Open with system app", hidden = true }, - }, - }, - }, - }, - - { - "iamcco/markdown-preview.nvim", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - build = "cd app && yarn install", - init = function() - vim.g.mkdp_filetypes = { "markdown" } - end, - ft = { "markdown" }, - }, - - { - "loctvl842/monokai-pro.nvim", - opts = { - filter = "classic", - }, - }, - - { - "LazyVim/LazyVim", - opts = { - colorscheme = "monokai-pro", - }, - }, - - { - "nvim-lualine/lualine.nvim", - opts = { - options = { - theme = "powerline", - section_separators = "", - component_separators = "", - globalstatus = false, - }, - sections = { - lualine_c = { - { - "diagnostics", - symbols = { - error = LazyVim.config.icons.diagnostics.Error, - warn = LazyVim.config.icons.diagnostics.Warn, - info = LazyVim.config.icons.diagnostics.Info, - hint = LazyVim.config.icons.diagnostics.Hint, - }, - }, - { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { "filename", file_status = true, path = 1 }, - }, - lualine_x = { - { - "diff", - symbols = { - added = LazyVim.config.icons.git.added, - modified = LazyVim.config.icons.git.modified, - removed = LazyVim.config.icons.git.removed, - }, - }, - }, - lualine_z = {}, - }, - tabline = { - lualine_a = { "buffers" }, - }, - }, - }, - - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - opts.ensure_installed = { - "bash", - "diff", - "gotmpl", - "helm", - "json", - "lua", - "markdown", - "markdown_inline", - "python", - "terraform", - "vim", - } - end, - }, - - { - "williamboman/mason.nvim", - opts = { - ensure_installed = { - "lua-language-server", - "terraform-ls", - "tflint", - }, - }, - }, -} diff --git a/config/common/nvim/lua/plugins/lsp.lua b/config/common/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..7ef12c3 --- /dev/null +++ b/config/common/nvim/lua/plugins/lsp.lua @@ -0,0 +1,10 @@ +return { + "williamboman/mason.nvim", + opts = { + ensure_installed = { + "lua-language-server", + "terraform-ls", + "tflint", + }, + }, +} diff --git a/config/common/nvim/lua/plugins/lualine.lua b/config/common/nvim/lua/plugins/lualine.lua new file mode 100644 index 0000000..4b6a4c0 --- /dev/null +++ b/config/common/nvim/lua/plugins/lualine.lua @@ -0,0 +1,40 @@ +return { + "nvim-lualine/lualine.nvim", + opts = { + options = { + theme = "powerline", + section_separators = "", + component_separators = "", + globalstatus = false, + }, + sections = { + lualine_c = { + { + "diagnostics", + symbols = { + error = LazyVim.config.icons.diagnostics.Error, + warn = LazyVim.config.icons.diagnostics.Warn, + info = LazyVim.config.icons.diagnostics.Info, + hint = LazyVim.config.icons.diagnostics.Hint, + }, + }, + { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, + { "filename", file_status = true, path = 1 }, + }, + lualine_x = { + { + "diff", + symbols = { + added = LazyVim.config.icons.git.added, + modified = LazyVim.config.icons.git.modified, + removed = LazyVim.config.icons.git.removed, + }, + }, + }, + lualine_z = {}, + }, + tabline = { + lualine_a = { "buffers" }, + }, + }, +} diff --git a/config/common/nvim/lua/plugins/monokai.lua b/config/common/nvim/lua/plugins/monokai.lua new file mode 100644 index 0000000..bd1de20 --- /dev/null +++ b/config/common/nvim/lua/plugins/monokai.lua @@ -0,0 +1,15 @@ +return { + { + "loctvl842/monokai-pro.nvim", + priority = 1000, + opts = { + filter = "classic", + }, + }, + { + "LazyVim/LazyVim", + opts = { + colorscheme = "monokai-pro", + }, + }, +} diff --git a/config/common/nvim/lua/plugins/snacks.lua b/config/common/nvim/lua/plugins/snacks.lua new file mode 100644 index 0000000..8c38215 --- /dev/null +++ b/config/common/nvim/lua/plugins/snacks.lua @@ -0,0 +1,28 @@ +return { + "folke/snacks.nvim", + opts = { + dashboard = { enabled = false }, + }, + keys = { + { + "n", + function() + vim.cmd("set number!") + vim.cmd('execute "set signcolumn=" . (&signcolumn == "yes" ? "no" : "yes")') + if Snacks.indent.enabled then + Snacks.indent.disable() + else + Snacks.indent.enable() + end + end, + desc = "Toggle Decorations", + }, + { + "e", + function() + Snacks.explorer() + end, + desc = "File Explorer", + }, + }, +} diff --git a/config/common/nvim/lua/plugins/treesitter.lua b/config/common/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..ac75221 --- /dev/null +++ b/config/common/nvim/lua/plugins/treesitter.lua @@ -0,0 +1,18 @@ +return { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "bash", + "diff", + "gotmpl", + "helm", + "json", + "lua", + "markdown", + "markdown_inline", + "python", + "terraform", + "vim", + }, + }, +} diff --git a/config/common/nvim/lua/plugins/which-key.lua b/config/common/nvim/lua/plugins/which-key.lua new file mode 100644 index 0000000..47460fe --- /dev/null +++ b/config/common/nvim/lua/plugins/which-key.lua @@ -0,0 +1,35 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + opts_extend = { "spec" }, + opts = { + preset = "helix", + icons = { + mappings = false, + }, + defaults = {}, + spec = { + { + mode = { "n", "v" }, + { + "b", + group = "buffer", + expand = function() + return require("which-key.extras").expand.buf() + end, + }, + { "", group = "tabs", hidden = true }, + { "d", group = "debug", hidden = true }, + { "dp", group = "profiler", hidden = true }, + { "gh", group = "hunks", hidden = true }, + { "q", group = "quit/session", hidden = true }, + { "s", group = "search", hidden = true }, + { "t", hidden = true }, + { "u", group = "ui", hidden = true }, + { "w", hidden = true }, + { "x", group = "diagnostics/quickfix", hidden = true }, + { "gx", desc = "Open with system app", hidden = true }, + }, + }, + }, +}