From a5218cdea718d274e8e9f83e28276485cc0f6c48 Mon Sep 17 00:00:00 2001 From: js0ny Date: Sun, 26 Jan 2025 18:49:49 +0000 Subject: [PATCH] feat(nvim): Add multiple edit plugins --- tools/nvim/lazy-lock.json | 4 ++ tools/nvim/lua/keymaps/init.lua | 1 + tools/nvim/lua/keymaps/leaders.lua | 3 +- tools/nvim/lua/keymaps/visual-multi.lua | 18 ++++++ tools/nvim/lua/plugins/edit.lua | 59 +++++++++++++++++++ tools/nvim/lua/plugins/lazy-nvim.lua | 2 +- tools/nvim/lua/plugins/lsp.lua | 14 +++++ tools/nvim/lua/plugins/misc.lua | 14 ----- .../mod/{lualine.lua => lualine/init.lua} | 2 - tools/nvim/lua/plugins/mod/nvim-cmp.lua | 1 + tools/nvim/lua/plugins/mod/trouble-nvim.lua | 37 ++++++++++++ tools/nvim/lua/plugins/syntax.lua | 20 ------- tools/nvim/playground.txt | 4 -- 13 files changed, 137 insertions(+), 42 deletions(-) create mode 100644 tools/nvim/lua/keymaps/visual-multi.lua create mode 100644 tools/nvim/lua/plugins/edit.lua rename tools/nvim/lua/plugins/mod/{lualine.lua => lualine/init.lua} (99%) create mode 100644 tools/nvim/lua/plugins/mod/trouble-nvim.lua delete mode 100644 tools/nvim/lua/plugins/syntax.lua delete mode 100644 tools/nvim/playground.txt diff --git a/tools/nvim/lazy-lock.json b/tools/nvim/lazy-lock.json index 39f7b93..9f460ff 100644 --- a/tools/nvim/lazy-lock.json +++ b/tools/nvim/lazy-lock.json @@ -16,9 +16,11 @@ "flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" }, "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, "gitsigns.nvim": { "branch": "main", "commit": "d8918f06624dd53b9a82bd0e29c31bcfd541b40d" }, + "grug-far.nvim": { "branch": "main", "commit": "635e69adf3a714621bd0a289314bc23c5848babb" }, "hover.nvim": { "branch": "main", "commit": "140c4d0ae9397b76baa46b87c574f5377de09309" }, "kanagawa.nvim": { "branch": "master", "commit": "988082eb00b845e4afbcaa4fd8e903da8a3ab3b9" }, "lazy.nvim": { "branch": "main", "commit": "d8f26efd456190241afd1b0f5235fe6fdba13d4a" }, + "lazydev.nvim": { "branch": "main", "commit": "a1b78b2ac6f978c72e76ea90ae92a94edf380cfc" }, "lazygit.nvim": { "branch": "main", "commit": "77a0d42943d8265271e6e6beaed72da54eeb17e7" }, "lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" }, "luasnip-latex-snippets.nvim": { "branch": "main", "commit": "cab134611eb755abe9ba95f5d86969f5cece448d" }, @@ -40,9 +42,11 @@ "render-markdown.nvim": { "branch": "main", "commit": "ad055861d17afe058bd835e82292e14a64b51b1d" }, "telescope.nvim": { "branch": "master", "commit": "415af52339215926d705cccc08145f3782c4d132" }, "todo-comments.nvim": { "branch": "main", "commit": "304a8d204ee787d2544d8bc23cd38d2f929e7cc5" }, + "trouble.nvim": { "branch": "main", "commit": "50481f414bd3c1a40122c1d759d7e424d5fafe84" }, "vim-floaterm": { "branch": "master", "commit": "4e28c8dd0271e10a5f55142fb6fe9b1599ee6160" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-just": { "branch": "main", "commit": "d07978c23c967c54c04a4dff9b25bcd6de5e91e0" }, + "vim-visual-multi-colemak-hnei": { "branch": "master", "commit": "2cc37d77590d6569d991ebd8d96ab5867eb5a47a" }, "vim-wakatime": { "branch": "master", "commit": "e46d7c4f98ee0f40782008dd60cb2a79c377fb1d" }, "vimtex": { "branch": "master", "commit": "b4eb43603dccf33b7d8597fbe1403c6430a24886" }, "which-key.nvim": { "branch": "main", "commit": "6cebd86917df559a88de0f806b2989799c6e6423" }, diff --git a/tools/nvim/lua/keymaps/init.lua b/tools/nvim/lua/keymaps/init.lua index d6546bb..7db8106 100644 --- a/tools/nvim/lua/keymaps/init.lua +++ b/tools/nvim/lua/keymaps/init.lua @@ -44,5 +44,6 @@ end -- which-key.nvim require("keymaps.which") +require("keymaps.visual-multi") return M diff --git a/tools/nvim/lua/keymaps/leaders.lua b/tools/nvim/lua/keymaps/leaders.lua index edc603a..320cf88 100644 --- a/tools/nvim/lua/keymaps/leaders.lua +++ b/tools/nvim/lua/keymaps/leaders.lua @@ -55,6 +55,7 @@ local leader_mappings = { { keys = "", cmd = "b#", opts = { desc = "Switch to last buffer" } }, { keys = "!", cmd = ":FloatermToggle", opts = { desc = "Toggle Terminal" } }, { keys = '"', cmd = ":!wezterm-gui &", pots = { desc = "Open External Terminal(wezterm)" } }, + { keys = ";", cmd = ":Telescope", pots = { desc = "Show Telescope Commands" } }, }, b = { -- +buffer { keys = "0", cmd = "b#", opts = { desc = "Switch to last buffer" } }, @@ -96,7 +97,7 @@ local leader_mappings = { }, f = { -- +file/find { keys = "f", cmd = ":Telescope fd", opts = { desc = "Find Files" } }, - { keys = "F", cmd = ":Telescope live_grep", opts = { desc = "Grep Files" } }, + { keys = "F", cmd = ":GrugFar", opts = { desc = "Search & Replace" } }, { keys = "l", cmd = ":set filetype=", opts = { desc = "Set Filetype to ..." } }, { keys = "n", cmd = ":new", opts = { desc = "New File" } }, { keys = "s", cmd = ":write", opts = { desc = "Save File" } }, diff --git a/tools/nvim/lua/keymaps/visual-multi.lua b/tools/nvim/lua/keymaps/visual-multi.lua new file mode 100644 index 0000000..a4600c1 --- /dev/null +++ b/tools/nvim/lua/keymaps/visual-multi.lua @@ -0,0 +1,18 @@ +vim.g.VM_mouse_mappings = 1 +vim.g.VM_default_mappings = 0 +vim.g.VM_custom_motions = { + -- https://github.com/mg979/vim-visual-multi/issues/93 + h = "h", + n = "j", + e = "k", + i = "l", + j = "e", +} + +vim.g.VM_maps = { + ["Add Cursor Down"] = "", + ["Add Cursor Up"] = "", + ["i"] = "l", + ["I"] = "L", + ["n"] = "n", +} diff --git a/tools/nvim/lua/plugins/edit.lua b/tools/nvim/lua/plugins/edit.lua new file mode 100644 index 0000000..1293d48 --- /dev/null +++ b/tools/nvim/lua/plugins/edit.lua @@ -0,0 +1,59 @@ +return { + { + "folke/flash.nvim", + event = "VeryLazy", + ---@type Flash.Config + opts = {}, + -- stylua: ignore + keys = { + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", 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" }, + }, + }, + { + "js0ny/vim-visual-multi-colemak-hnei", + -- "mg979/vim-visual-multi", + }, + { + "echasnovski/mini.pairs", + version = false, + config = function() + require("mini.pairs").setup() + end, + }, + { + "kylechui/nvim-surround", + version = "*", -- Use for stability; omit to use `main` branch for the latest features + event = "VeryLazy", + config = function() + require("nvim-surround").setup({ + -- Configuration here, or leave empty to use defaults + }) + end, + }, + { + "MagicDuck/grug-far.nvim", + opts = { headerMaxWidth = 80 }, + cmd = "GrugFar", + keys = { + { + "fF", + function() + local grug = require("grug-far") + local ext = vim.bo.buftype == "" and vim.fn.expand("%:e") + grug.open({ + transient = true, + prefills = { + filesFilter = ext and ext ~= "" and "*." .. ext or nil, + }, + }) + end, + mode = { "n", "v" }, + desc = "Search and Replace", + }, + }, + }, +} diff --git a/tools/nvim/lua/plugins/lazy-nvim.lua b/tools/nvim/lua/plugins/lazy-nvim.lua index 8dacc43..85493ef 100644 --- a/tools/nvim/lua/plugins/lazy-nvim.lua +++ b/tools/nvim/lua/plugins/lazy-nvim.lua @@ -29,7 +29,7 @@ require("lazy").setup({ { import = "plugins.completion" }, { import = "plugins.fileutils" }, { import = "plugins.lsp" }, - { import = "plugins.syntax" }, + { import = "plugins.edit" }, { import = "plugins.misc" }, }, -- Configure any other settings here. See the documentation for more details. diff --git a/tools/nvim/lua/plugins/lsp.lua b/tools/nvim/lua/plugins/lsp.lua index 983cadf..a5638ff 100644 --- a/tools/nvim/lua/plugins/lsp.lua +++ b/tools/nvim/lua/plugins/lsp.lua @@ -66,4 +66,18 @@ return { "NoahTheDuke/vim-just", ft = { "just" }, }, + { import = "plugins.mod.trouble-nvim" }, + + { import = "plugins.mod.nvim-treesitter" }, + { + "folke/lazydev.nvim", + ft = "lua", -- only load on lua files + opts = { + library = { + -- See the configuration section for more details + -- Load luvit types when the `vim.uv` word is found + { path = "${3rd}/luv/library", words = { "vim%.uv" } }, + }, + }, + }, } diff --git a/tools/nvim/lua/plugins/misc.lua b/tools/nvim/lua/plugins/misc.lua index 1ee5a99..9a7bd8f 100644 --- a/tools/nvim/lua/plugins/misc.lua +++ b/tools/nvim/lua/plugins/misc.lua @@ -12,18 +12,4 @@ return { "github/copilot.vim", lazy = false, }, - { - "folke/flash.nvim", - event = "VeryLazy", - ---@type Flash.Config - opts = {}, - -- stylua: ignore - keys = { - { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, - { "S", 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" }, - }, - }, } diff --git a/tools/nvim/lua/plugins/mod/lualine.lua b/tools/nvim/lua/plugins/mod/lualine/init.lua similarity index 99% rename from tools/nvim/lua/plugins/mod/lualine.lua rename to tools/nvim/lua/plugins/mod/lualine/init.lua index 56af922..4e5cd4d 100644 --- a/tools/nvim/lua/plugins/mod/lualine.lua +++ b/tools/nvim/lua/plugins/mod/lualine/init.lua @@ -1,5 +1,3 @@ --- Author: shadmansaleh --- Credit: glepnir local lualine = require("lualine") -- Color table for highlights diff --git a/tools/nvim/lua/plugins/mod/nvim-cmp.lua b/tools/nvim/lua/plugins/mod/nvim-cmp.lua index 165da17..b8a7140 100644 --- a/tools/nvim/lua/plugins/mod/nvim-cmp.lua +++ b/tools/nvim/lua/plugins/mod/nvim-cmp.lua @@ -43,6 +43,7 @@ return { { name = "nvim_lsp" }, { name = "luasnip" }, { name = "copilot" }, + { name = "lazydev", group_index = 0 }, }, { { name = "buffer" }, { name = "path" }, diff --git a/tools/nvim/lua/plugins/mod/trouble-nvim.lua b/tools/nvim/lua/plugins/mod/trouble-nvim.lua new file mode 100644 index 0000000..a49f503 --- /dev/null +++ b/tools/nvim/lua/plugins/mod/trouble-nvim.lua @@ -0,0 +1,37 @@ +return { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "eE", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "ee", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "es", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "el", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "eL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "ef", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, +} diff --git a/tools/nvim/lua/plugins/syntax.lua b/tools/nvim/lua/plugins/syntax.lua deleted file mode 100644 index e9052dd..0000000 --- a/tools/nvim/lua/plugins/syntax.lua +++ /dev/null @@ -1,20 +0,0 @@ -return { - { import = "plugins.mod.nvim-treesitter" }, - { - "echasnovski/mini.pairs", - version = false, - config = function() - require("mini.pairs").setup() - end, - }, - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - event = "VeryLazy", - config = function() - require("nvim-surround").setup({ - -- Configuration here, or leave empty to use defaults - }) - end, - }, -} diff --git a/tools/nvim/playground.txt b/tools/nvim/playground.txt deleted file mode 100644 index c855ece..0000000 --- a/tools/nvim/playground.txt +++ /dev/null @@ -1,4 +0,0 @@ -((( -This is a playground file. -{(1 + 2) * 3} -)))