From 8b603b8c665f8b140563ac2f1de349090976062a Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 2 Oct 2023 19:18:29 +0200 Subject: [PATCH] nvim: Improve lazy-loading of select plugins Aerial (on command), test-runners (on python only) and other plugins are now only loaded when actually required. --- nvim/.config/nvim/lua/core/mappings.lua | 22 +++++------------- nvim/.config/nvim/lua/plugins/core.lua | 7 +++++- .../nvim/lua/plugins/data_analysis.lua | 23 +++++++++++++++++++ nvim/.config/nvim/lua/plugins/editing.lua | 2 +- nvim/.config/nvim/lua/plugins/ide.lua | 23 +++++++++++++++---- nvim/.config/nvim/lua/plugins/ui.lua | 12 +++++++++- nvim/.config/nvim/spell/en.utf-8.add | 4 ++++ 7 files changed, 70 insertions(+), 23 deletions(-) diff --git a/nvim/.config/nvim/lua/core/mappings.lua b/nvim/.config/nvim/lua/core/mappings.lua index feff72b..0d655b9 100644 --- a/nvim/.config/nvim/lua/core/mappings.lua +++ b/nvim/.config/nvim/lua/core/mappings.lua @@ -180,8 +180,6 @@ map("n", "q", "gqap", { silent = true, desc = "Format current parag map("x", "q", "gq", { silent = true, desc = "Format {motion}" }) map("n", "Q", "vapJgqap", { silent = true, desc = "Unformat then format paragraph" }) -map("n", "mp", "MarkdownPreviewToggle", { desc = "Toggle md preview" }) - -- FORMAT code with -- PLUGIN: formatter.nvim map("n", "f", ":FormatLock") @@ -205,6 +203,7 @@ map("n", "ss", ":lua MiniStarter.open()", { desc = "show startpage" -- PLUGIN: symbols-outline.nvim map("n", "so", "AerialToggle", { silent = true, desc = "toggle symbol outline" }) +map("n", "sn", "AerialNavToggle", { silent = true, desc = "toggle symbol navigator" }) -- PLUGIN: nvim-tree map("n", "se", "NvimTreeToggle", { silent = true, desc = "toggle filetree" }) @@ -255,13 +254,11 @@ map("v", "nf", ":ZkMatch", { desc = "find note from selection" -- PLUGIN: toggleterm.nvim -- create a lazygit or python window, set up in toggleterm settings -- TODO create ability to go into python environment when in poetry venv and/or euporie/jupyter notebook -if is_available("nvim-toggleterm.lua") then - map("n", "G", ":Lazygit") - map("n", "tg", ":Lazygit") - map("n", "tG", ":Lazygit!") - map("n", "tp", ":Pythonterm") - map("n", "tP", ":Pythonterm!") -end +prefix({ ["t"] = { name = "+term" } }) +map("n", "tg", ":Lazygit") +map("n", "tG", ":Lazygit!") +map("n", "tp", ":Pythonterm") +map("n", "tP", ":Pythonterm!") prefix({ ["s"] = { name = "+set" } }) -- PLUGIN: wrapping.nvim @@ -281,10 +278,3 @@ map( ) map("n", "sa", "FormatOnSave", { silent = true, desc = "toggle format on save" }) - --- PLUGIN: undotree -if is_available("undotree") then - map("n", "su", function() - require("undotree").toggle() - end, { silent = true, desc = "toggle undotree" }) -end diff --git a/nvim/.config/nvim/lua/plugins/core.lua b/nvim/.config/nvim/lua/plugins/core.lua index 4aed166..fb76d5a 100644 --- a/nvim/.config/nvim/lua/plugins/core.lua +++ b/nvim/.config/nvim/lua/plugins/core.lua @@ -33,7 +33,6 @@ return { config = function() require("plugins.config.toggleterm") end, - lazy = false, cmd = { "ToggleTerm", "TermExec", "Lazygit", "Pythonterm" }, }, -- colorschemes @@ -43,4 +42,10 @@ return { priority = 1000, dependencies = { "rktjmp/fwatch.nvim" }, }, + -- try to avoid putting files in util buffers, e.g. filetree, aerial, undotree, .. + { + 'stevearc/stickybuf.nvim', + config = true, + } + } diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 5a5f07e..0aac996 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -55,4 +55,27 @@ return { ft = { "quarto", "python" }, lazy = false, }, + + -- MARKDOWN ONLY + -- Evaluate markdown code blocks + { + "jubnzv/mdeval.nvim", + cmd = { + "MdEval", + }, + ft = { "markdown" }, + opts = { + require_confirmation = false, + eval_options = {}, + }, + lazy = false, + }, + { + "AckslD/nvim-FeMaco.lua", + cmd = { + "FeMaco" + }, + ft = { "markdown" }, + config = true + } } diff --git a/nvim/.config/nvim/lua/plugins/editing.lua b/nvim/.config/nvim/lua/plugins/editing.lua index 0a02199..4730382 100644 --- a/nvim/.config/nvim/lua/plugins/editing.lua +++ b/nvim/.config/nvim/lua/plugins/editing.lua @@ -47,6 +47,6 @@ return { }, }) end, - event = "VeryLazy", + event = "InsertEnter", }, } diff --git a/nvim/.config/nvim/lua/plugins/ide.lua b/nvim/.config/nvim/lua/plugins/ide.lua index 0af92e3..e80a4a4 100644 --- a/nvim/.config/nvim/lua/plugins/ide.lua +++ b/nvim/.config/nvim/lua/plugins/ide.lua @@ -8,7 +8,20 @@ return { "nvim-treesitter/nvim-treesitter", "nvim-tree/nvim-web-devicons", }, - event = "VeryLazy", + cmd = { + "AerialToggle", + "AerialOpen", + "AerialOpenAll", + "AerialClose", + "AerialCloseAll", + "AerialNext", + "AerialPrev", + "AerialGo", + "AerialInfo", + "AerialNavToggle", + "AerialNavOpen", + "AerialNavClose", + }, opts = { backends = { "treesitter", "lsp", "markdown", "man" }, }, @@ -103,7 +116,7 @@ return { require("neotest").setup({ adapters = { require("neotest-python")({ - -- with coverage requires coverage.py and pytest-cov installed + -- with coverage requires coverage.py and pytest-cov installed args = { "--cov" }, }), }, @@ -113,6 +126,7 @@ return { wk.register({ ["t"] = { name = "+test" } }) end end, + ft = { "python" }, keys = { { "st", @@ -179,9 +193,10 @@ return { }, config = function() require("coverage").setup({ - lang = { python = { coverage_command = "poetry run coverage json -q -o -" } } , + lang = { python = { coverage_command = "poetry run coverage json -q -o -" } }, }) end, + ft = { "python" }, cmd = { "Coverage", "CoverageLoad", @@ -211,6 +226,6 @@ return { desc = "show coverage summary", silent = true, }, - } + }, }, } diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index bb0e19e..d408847 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -55,6 +55,16 @@ return { dependencies = { "nvim-lua/plenary.nvim", }, - config = true, event = "VeryLazy", + config = true, + keys = { + { + "su", + function() + require("undotree").toggle() + end, + desc = "toggle undotree", + silent = true, + }, + }, }, } diff --git a/nvim/.config/nvim/spell/en.utf-8.add b/nvim/.config/nvim/spell/en.utf-8.add index f5605bc..a30a8f1 100644 --- a/nvim/.config/nvim/spell/en.utf-8.add +++ b/nvim/.config/nvim/spell/en.utf-8.add @@ -186,3 +186,7 @@ Gitea caramelization Maillard individualities +vaccilation +SSCM +GSCM +multicriteria