diff --git a/nvim/lua/keybinds.lua b/nvim/lua/keybinds.lua index c67cf51..a0a742a 100755 --- a/nvim/lua/keybinds.lua +++ b/nvim/lua/keybinds.lua @@ -42,9 +42,6 @@ keymap.set("n", "lc", ":VimtexCompile", opts("Compile latex document keymap.set("n", "lv", ":VimtexView", opts("View compiled latex pdf")) -- View compiled PDF keymap.set("n", "lq", ":VimtexStop", opts("Stop Compiling document")) -- Stop compilation --- Markdown-Preview -keymap.set("n", "m", ":MarkdownPreview", opts("Preview Markdown document in browser")) -- Stop compilation - -- window navigation keymap.set("n", "", "h", opts()) keymap.set("n", "", "j", opts()) diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua index 4175a2d..b2dc54b 100755 --- a/nvim/lua/options.lua +++ b/nvim/lua/options.lua @@ -2,6 +2,7 @@ vim.g.mapleader = " " vim.g.maplocalleader = " " vim.opt.backspace = "2" +vim.opt.termguicolors = true -- title vim.opt.title = true diff --git a/nvim/lua/plugins/lsp/actions-preview.lua b/nvim/lua/plugins/lsp/actions-preview.lua index 0a043e9..e2241a6 100755 --- a/nvim/lua/plugins/lsp/actions-preview.lua +++ b/nvim/lua/plugins/lsp/actions-preview.lua @@ -1,19 +1,15 @@ return { "aznhe21/actions-preview.nvim", - config = function() - -- Configure actions-preview.nvim - require("actions-preview").setup({ - -- Floating window configuration (optional) - max_width = 80, -- Max width of the preview window - max_height = 12, -- Max height of the preview window - min_width = 20, -- Minimum width for the preview window - min_height = 4, -- Minimum height for the preview window + opts = { + -- Floating window configuration (optional) + max_width = 80, -- Max width of the preview window + max_height = 12, -- Max height of the preview window + min_width = 20, -- Minimum width for the preview window + min_height = 4, -- Minimum height for the preview window - -- Keymaps (optional) - keymaps = { - -- Trigger code action preview with a keybinding (example using a) - { "n", "ca", vim.lsp.buf.code_action }, - }, - }) - end, + -- Keymaps (optional) + }, + keys = { + { "ca", vim.lsp.buf.code_action, desc = "View code actions" }, + }, } diff --git a/nvim/lua/plugins/lsp/none-ls.lua b/nvim/lua/plugins/lsp/none-ls.lua index 7609849..d04398e 100755 --- a/nvim/lua/plugins/lsp/none-ls.lua +++ b/nvim/lua/plugins/lsp/none-ls.lua @@ -6,6 +6,7 @@ return { dependencies = { "nvimtools/none-ls-extras.nvim", }, + event = { "BufReadPre", "BufNewFile" }, config = function() local null_ls = require("null-ls") diff --git a/nvim/lua/plugins/lsp/vimtex.lua b/nvim/lua/plugins/lsp/vimtex.lua index 8b336f0..1fbc744 100755 --- a/nvim/lua/plugins/lsp/vimtex.lua +++ b/nvim/lua/plugins/lsp/vimtex.lua @@ -1,5 +1,6 @@ return { "lervag/vimtex", + event = "BufNew", config = function() -- vimtex settings -- vim.g.vimtex_view_method = 'zathura' -- PDF viewer (example: zathura, or use 'skim' for macOS) diff --git a/nvim/lua/plugins/nav/bufferline.lua b/nvim/lua/plugins/nav/bufferline.lua index c6dbcbb..c6a3961 100755 --- a/nvim/lua/plugins/nav/bufferline.lua +++ b/nvim/lua/plugins/nav/bufferline.lua @@ -3,6 +3,7 @@ return { "akinsho/bufferline.nvim", version = "*", dependencies = "nvim-tree/nvim-web-devicons", + event = "BufRead", config = function() local bufferline = require("bufferline") bufferline.setup({ diff --git a/nvim/lua/plugins/nav/lastplace.lua b/nvim/lua/plugins/nav/lastplace.lua index e4cff04..7c0c3df 100755 --- a/nvim/lua/plugins/nav/lastplace.lua +++ b/nvim/lua/plugins/nav/lastplace.lua @@ -1,6 +1,7 @@ return { -- open file at previous position "ethanholz/nvim-lastplace", + event = { "BufReadPre", "BufNewFile" }, config = function() require("nvim-lastplace").setup({}) end, diff --git a/nvim/lua/plugins/nav/navbuddy.lua b/nvim/lua/plugins/nav/navbuddy.lua index 230b4a5..1321810 100755 --- a/nvim/lua/plugins/nav/navbuddy.lua +++ b/nvim/lua/plugins/nav/navbuddy.lua @@ -5,6 +5,9 @@ return { "MunifTanjim/nui.nvim", }, opts = { lsp = { auto_attach = true } }, + keys = { + { "n", ":Navbuddy", desc = "open navbuddy menu" } + }, config = function() local actions = require("nvim-navbuddy.actions") require("nvim-navbuddy").setup({ @@ -140,7 +143,5 @@ return { }, custom_hl_group = nil, -- "Visual" or any other hl group to use instead of inverted colors }) - - vim.keymap.set("n", "n", ":Navbuddy", { silent = true, desc = "open navbuddy menu" }) end, } diff --git a/nvim/lua/plugins/nav/telescope.lua b/nvim/lua/plugins/nav/telescope.lua index f10e68d..6597699 100755 --- a/nvim/lua/plugins/nav/telescope.lua +++ b/nvim/lua/plugins/nav/telescope.lua @@ -11,12 +11,53 @@ return { }, }, keys = { + { "ff", require("telescope.builtin").find_files, desc = "Telescope find files" }, + { "flg", require("telescope.builtin").live_grep, desc = "Telescope live grep" }, + + { "fg", function () + require( 'telescope' ).extensions.live_grep_args.live_grep_args() + end, desc = "Telescope live grep args" }, + + { "fb", require("telescope.builtin").buffers, desc = "Telescope buffers" }, + + { "fh", require("telescope.builtin").help_tags, desc = "Telescope nvim functions" }, + + { "ft", ":TodoTelescope", desc = "Telescope TODOs" }, + + -- Git + { "fld", require("telescope.builtin").git_status, desc = "Telescope git diff" }, + + { "flc", require("telescope.builtin").git_commits, desc = "Telescope git commits" }, + + { "flf", require("telescope.builtin").git_files, desc = "Telescope git files" }, + + -- Recent Commands + { "foc", ":Telescope command_history", desc = "Telescope recent commands" }, + + -- Recent Searches + { "fos", ":Telescope search_history", desc = "Telescope recent searches" }, + + -- Old Files + { "fr", require("telescope.builtin").oldfiles, desc = "Telescope recent files" }, + + -- Quickfix Items + { "fq", ":Telescope quickfix", desc = "Telescope quickfix items" }, + + -- Spell Suggestions + { "fs", ":Telescope spell_suggest", desc = "Telescope spellsuggestions" }, + + -- Diagnostics + { "fd", ":Telescope diagnostics", desc = "Telescope Diagnostics" }, + + -- Notifications + { "fn", ":Telescope notify", desc = "Telescope Notifications" }, + + -- Implementations + { "fi", ":Telescope lsp_implementations", desc = "Telescope lsp implementations" }, }, config = function() - local builtin = require("telescope.builtin") local actions = require("telescope.actions") - local opts = { silent = true } local telescope = require("telescope") local lga_actions = require("telescope-live-grep-args.actions") @@ -42,72 +83,5 @@ return { }) telescope.load_extension("live_grep_args") - - opts.desc = "telescope find files" - vim.keymap.set("n", "ff", builtin.find_files, opts) - - opts.desc = "telescope live grep" - vim.keymap.set("n", "flg", builtin.live_grep, opts) - - opts.desc = "telescope live grep args" - local function start_live_grep_args() - telescope.extensions.live_grep_args.live_grep_args() - end - vim.keymap.set("n", "fg", start_live_grep_args, opts) - - opts.desc = "telescope buffers" - vim.keymap.set("n", "fb", builtin.buffers, opts) - - opts.desc = "Show nvim functions" - vim.keymap.set("n", "fh", builtin.help_tags, opts) - - opts.desc = "Telescope TODOs" - vim.keymap.set("n", "ft", ":TodoTelescope", opts) - - -- Git - opts.desc = "Show git diff" - vim.keymap.set("n", "fld", builtin.git_status, opts) - - opts.desc = "Show git commits" - vim.keymap.set("n", "flc", builtin.git_commits, opts) - - opts.desc = "Show git files" - vim.keymap.set("n", "flf", builtin.git_files, opts) - - -- Recent Commands - opts.desc = "Show recent commands" - vim.keymap.set("n", "foc", ":Telescope command_history", opts) - - -- Recent Searches - opts.desc = "Show recent searches" - vim.keymap.set("n", "fos", ":Telescope search_history", opts) - - -- Old Files - opts.desc = "Show recent files" - vim.keymap.set("n", "fr", builtin.oldfiles, opts) - - -- Quickfix Items - opts.desc = "Show quickfix items" - vim.keymap.set("n", "fq", ":Telescope quickfix", opts) - - -- Spell Suggestions - opts.desc = "Show spell suggestions" - vim.keymap.set("n", "fs", ":Telescope spell_suggest", opts) - - -- Diagnostics - opts.desc = "Show diagnostics" - vim.keymap.set("n", "fd", ":Telescope diagnostics", opts) - - -- Notifications - opts.desc = "Show notifications" - vim.keymap.set("n", "fn", ":Telescope notify", opts) - - -- Implementations - opts.desc = "Show implementations" - vim.keymap.set("n", "fi", ":Telescope lsp_implementations", opts) - - -- quickfix - opts.desc = "Show quickfix list" - vim.keymap.set("n", "fq", ":Telescope quickfix", opts) end, } diff --git a/nvim/lua/plugins/testing/neotest.lua b/nvim/lua/plugins/testing/neotest.lua index d7b15b6..9a2774e 100755 --- a/nvim/lua/plugins/testing/neotest.lua +++ b/nvim/lua/plugins/testing/neotest.lua @@ -9,10 +9,36 @@ return { "orjangj/neotest-ctest", "rouge8/neotest-rust", }, - keys = {}, + keys = { + -- Run nearest test + { "tr", 'lua require("neotest").run.run()', desc = "Run nearest test" }, + + -- Run all tests in the current file + { + "tf", + 'lua require("neotest").run.run(vim.fn.expand("%"))', + desc = "Run all tests in current file", + }, + + -- Stop running tests + { "ts", 'lua require("neotest").run.stop()', desc = "Stop tests" }, + + { "ta", 'lua require("neotest").run.attach()', desc = "Attach to nearest test" }, + + { "tn", "Neotest jump next", desc = "Jump to next test" }, + + { "tp", "Neotest jump prev", desc = "Jump to previous test" }, + + -- Show test summary + { "tv", "Neotest summary", desc = "Show neotest test summary" }, + + -- Toggle the Neotest panel + { "to", "Neotest output", desc = "Show neotest output" }, + + { "tn", "Neotest output-panel", desc = "Show neotest output as panel" }, + }, config = function() local neotest = require("neotest") - local keymap = vim.keymap.set -- General setup for neotest neotest.setup({ @@ -31,38 +57,5 @@ return { }) -- Keybinding Setup - local opts = { noremap = true, silent = true } - - -- Run nearest test - opts.desc = "Run nearest test" - keymap("n", "tr", 'lua require("neotest").run.run()', opts) - - -- Run all tests in the current file - opts.desc = "Run all tests in current file" - keymap("n", "tf", 'lua require("neotest").run.run(vim.fn.expand("%"))', opts) - - -- Stop running tests - opts.desc = "Stop tests" - keymap("n", "ts", 'lua require("neotest").run.stop()', opts) - - opts.desc = "Attach to nearest test" - keymap("n", "ta", 'lua require("neotest").run.attach()', opts) - - opts.desc = "Jump to next test" - keymap("n", "tn", "Neotest jump next", opts) - - opts.desc = "Jump to previous test" - keymap("n", "tp", "Neotest jump prev", opts) - - -- Show test summary - opts.desc = "Show neotest test summary" - keymap("n", "tv", "Neotest summary", opts) - - -- Toggle the Neotest panel - opts.desc = "Show neotest output" - keymap("n", "to", "Neotest output", opts) - - opts.desc = "Show neotest output as panel" - keymap("n", "tn", "Neotest output-panel", opts) end, } diff --git a/nvim/lua/plugins/util/colour-picker.lua b/nvim/lua/plugins/util/colour-picker.lua index ce92960..b2b755e 100644 --- a/nvim/lua/plugins/util/colour-picker.lua +++ b/nvim/lua/plugins/util/colour-picker.lua @@ -1,21 +1,16 @@ return { "uga-rosa/ccc.nvim", - config = function() - local ccc = require("ccc") - vim.opt.termguicolors = true - ccc.setup({ - highlighter = { - auto_enable = false, - lsp = true, - }, - }) - - local keymap = vim.keymap - keymap.set( - "n", + opts = { + highlighter = { + auto_enable = false, + lsp = true, + }, + }, + keys = { + { "cp", "CccPick", - { noremap = true, silent = true, desc = "Toggle colour picker" } - ) - end, + desc = "Toggle colour picker", + }, + }, } diff --git a/nvim/lua/plugins/util/markdown-preview.lua b/nvim/lua/plugins/util/markdown-preview.lua index de9f855..f912c87 100755 --- a/nvim/lua/plugins/util/markdown-preview.lua +++ b/nvim/lua/plugins/util/markdown-preview.lua @@ -3,6 +3,9 @@ return { "iamcco/markdown-preview.nvim", cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, ft = { "markdown" }, + keys = { + { "m", ":MarkdownPreview", desc = "Preview Markdown document in browser" }, + }, build = function(plugin) if vim.fn.executable("npx") then vim.cmd("!cd " .. plugin.dir .. " && cd app && npx --yes yarn install") diff --git a/nvim/lua/plugins/util/move.lua b/nvim/lua/plugins/util/move.lua index 133c745..3ecf90a 100755 --- a/nvim/lua/plugins/util/move.lua +++ b/nvim/lua/plugins/util/move.lua @@ -1,22 +1,17 @@ return { "fedepujol/move.nvim", - config = function() - local opts = require("utils").opts - require("move").setup({}) - local keymap = vim.keymap - - -- Move lines up and down - keymap.set("n", "", ":MoveLine(-1)", opts("Move line up")) - keymap.set("n", "", ":MoveLine(1)", opts("Move line down")) - keymap.set("n", "mk", ":MoveLine(-1)", opts("Move line up")) - keymap.set("n", "mj", ":MoveLine(1)", opts("Move line down")) + keys = { + { "", ":MoveLine(-1)", desc = "Move line up" }, + { "", ":MoveLine(1)", desc = "Move line down" }, + { "mk", ":MoveLine(-1)", desc = "Move line up" }, + { "mj", ":MoveLine(1)", desc = "Move line down" }, -- Move blocks in visual mode - keymap.set("v", "", ":MoveBlock(-1)", opts("Move line up")) - keymap.set("v", "", ":MoveBlock(1)", opts("Move line down")) + { "", ":MoveBlock(-1)", desc = "Move line up" }, + { "", ":MoveBlock(1)", desc = "Move line down" }, -- Move lines in insert mode - keymap.set("i", "", ":MoveLine(-1)", opts("Move line up")) - keymap.set("i", "", ":MoveLine(1)", opts("Move line down")) - end, + { "", ":MoveLine(-1)", desc = "Move line up" }, + { "", ":MoveLine(1)", desc = "Move line down" }, + }, } diff --git a/nvim/lua/plugins/util/multicursors.lua b/nvim/lua/plugins/util/multicursors.lua index efc6f26..d72f8a2 100755 --- a/nvim/lua/plugins/util/multicursors.lua +++ b/nvim/lua/plugins/util/multicursors.lua @@ -1,6 +1,5 @@ return { "smoka7/multicursors.nvim", - event = "VeryLazy", dependencies = { "nvimtools/hydra.nvim", }, diff --git a/nvim/lua/plugins/util/neogen.lua b/nvim/lua/plugins/util/neogen.lua index ad98297..4819a2b 100755 --- a/nvim/lua/plugins/util/neogen.lua +++ b/nvim/lua/plugins/util/neogen.lua @@ -1,19 +1,15 @@ return { "danymat/neogen", - config = function() - local opts = { noremap = true, silent = true, desc = "Generate docs" } - vim.keymap.set("n", "gd", ":lua require('neogen').generate()", opts) + opts = { + snippet_engine = "luasnip", + }, + keys = { + { "gd", ":lua require('neogen').generate()", desc = "Autogenerate docs" }, - opts.desc = "Generate function docs" - vim.keymap.set("n", "gg", ":lua require('neogen').generate( { type = 'func' } )", opts) + { "gg", ":lua require('neogen').generate( { type = 'func' } )", desc = "Generate function docs" }, - opts.desc = "Generate type docs" - vim.keymap.set("n", "gt", ":lua require('neogen').generate( { type = 'type' } )", opts) + { "gt", ":lua require('neogen').generate( { type = 'type' } )", desc = "Generate type docs" }, - opts.desc = "Generate class docs" - vim.keymap.set("n", "gc", ":lua require('neogen').generate( { type = 'class' } )", opts) - require("neogen").setup({ - snippet_engine = "luasnip", - }) - end, + { "gc", ":lua require('neogen').generate( { type = 'class' } )", desc = "Generate class docs" }, + }, } diff --git a/nvim/lua/plugins/util/surround.lua b/nvim/lua/plugins/util/surround.lua index 9cc7d6a..2397f97 100755 --- a/nvim/lua/plugins/util/surround.lua +++ b/nvim/lua/plugins/util/surround.lua @@ -1,7 +1,7 @@ return { "kylechui/nvim-surround", version = "*", - event = "VeryLazy", + event = "InsertEnter", config = function() require("nvim-surround").setup() end, diff --git a/nvim/lua/plugins/util/zen-mode.lua b/nvim/lua/plugins/util/zen-mode.lua index 6f6be9e..2804b7b 100755 --- a/nvim/lua/plugins/util/zen-mode.lua +++ b/nvim/lua/plugins/util/zen-mode.lua @@ -1,14 +1,13 @@ return { -- view buffer w/o distractions "folke/zen-mode.nvim", - config = function() - require("zen-mode").setup({ - window = { - width = 1, - height = 1, - }, - }) - - vim.keymap.set("n", "z", ":ZenMode", { silent = true, desc = "open current buffer in zen mode" }) - end, + opts = { + window = { + width = 1, + height = 1, + }, + }, + keys = { + { "z", ":ZenMode", desc = "open current buffer in zen mode" }, + }, }