From b96a12e1ffd0ca15abe50032bb1f1832daa80971 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Dec 2024 00:46:28 +0100 Subject: [PATCH] Lazy load stuff --- nvim/default.nix | 44 ++++++++++--------- nvim/init.lua | 5 +++ nvim/lua/lsp.lua | 75 --------------------------------- nvim/lua/plugins/auto-save.lua | 10 ++--- nvim/lua/plugins/blink.lua | 3 +- nvim/lua/plugins/conform.lua | 2 - nvim/lua/plugins/git.lua | 7 +-- nvim/lua/plugins/line.lua | 4 -- nvim/lua/plugins/lint.lua | 2 - nvim/lua/plugins/lsp.lua | 67 +++++++++++++++++++++++++++++ nvim/lua/plugins/mini.lua | 6 --- nvim/lua/plugins/motions.lua | 12 +----- nvim/lua/plugins/noice.lua | 10 ++--- nvim/lua/plugins/oil.lua | 1 - nvim/lua/plugins/statuscol.lua | 2 - nvim/lua/plugins/telescope.lua | 1 + nvim/lua/plugins/treesitter.lua | 10 ++--- nvim/lua/plugins/ui.lua | 12 ------ nvim/lua/settings.lua | 31 ++++++++++++-- 19 files changed, 141 insertions(+), 163 deletions(-) delete mode 100644 nvim/lua/lsp.lua create mode 100644 nvim/lua/plugins/lsp.lua diff --git a/nvim/default.nix b/nvim/default.nix index a67b5f0..a4dfcda 100644 --- a/nvim/default.nix +++ b/nvim/default.nix @@ -57,32 +57,45 @@ in with pkgs.vimPlugins; { start = [ (mkPlugin lz-nvim "lz-n") + catppuccin-nvim + (mkPlugin vim-lumen "vim-lumen") + nvim-treesitter.withAllGrammars - nvim-treesitter-textobjects - vim-illuminate + ts-comments-nvim + nvim-lspconfig + blink-cmp + SchemaStore-nvim + nvim-lint + (conform-nvim.overrideAttrs { + # clashes with oil + postPatch = "rm doc/recipes.md"; + }) + oil-nvim - nvim-surround telescope-fzf-native-nvim - vim-sleuth - auto-save-nvim + harpoon2 gitsigns-nvim git-conflict-nvim - mini-icons + nvim-surround mini-operators mini-splitjoin vim-wordmotion increment-activator - leap-nvim flit-nvim + vim-helm + vim-sleuth + auto-save-nvim + undotree + noice-nvim statuscol-nvim - + mini-icons which-key-nvim nvim-colorizer-lua nvim-pqf @@ -90,22 +103,11 @@ in nvim-navic virt-column-nvim indent-blankline-nvim - - SchemaStore-nvim - blink-cmp - ts-comments-nvim - undotree - nvim-lint - (conform-nvim.overrideAttrs { - # clashes with oil - postPatch = "rm doc/recipes.md"; - }) - vim-helm - (mkPlugin vim-lumen "vim-lumen") ]; opt = [ telescope-nvim - harpoon2 + vim-illuminate + nvim-treesitter-textobjects ]; }; diff --git a/nvim/init.lua b/nvim/init.lua index dd37f86..e8a7538 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -1,4 +1,9 @@ -- rtp & loader settings are set by nix +-- only use lz.n as a "require" sorter +vim.g.lz_n = { + load = function() end, +} + require("./settings") require("lz.n").load("plugins") diff --git a/nvim/lua/lsp.lua b/nvim/lua/lsp.lua deleted file mode 100644 index 935846b..0000000 --- a/nvim/lua/lsp.lua +++ /dev/null @@ -1,75 +0,0 @@ -if vim.g.have_nerd_font then - vim.diagnostic.config({ - signs = { - text = { - [vim.diagnostic.severity.ERROR] = "󰅚", - [vim.diagnostic.severity.WARN] = "", - [vim.diagnostic.severity.HINT] = "󰌶", - [vim.diagnostic.severity.INFO] = "", - }, - }, - }) -end -vim.diagnostic.config({ - virtual_text = false, - update_in_insert = true, -}) - --- see https://github.com/neovim/nvim-lspconfig/issues/3494 -require("lspconfig").lua_ls.setup({}) -require("lspconfig").hls.setup({}) -require("lspconfig").rust_analyzer.setup({}) -require("lspconfig").clangd.setup({}) -require("lspconfig").omnisharp.setup({}) -require("lspconfig").pyright.setup({}) -require("lspconfig").nil_ls.setup({}) -require("lspconfig").ts_ls.setup({}) -require("lspconfig").yamlls.setup({}) -require("lspconfig").marksman.setup({}) -require("lspconfig").ltex.setup({}) -require("lspconfig").texlab.setup({}) -require("lspconfig").html.setup({}) -require("lspconfig").helm_ls.setup({}) -require("lspconfig").zls.setup({}) - -require("lspconfig").jsonls.setup({ - on_new_config = function(new_config) - new_config.settings.json.schemas = new_config.settings.json.schemas or {} - vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas()) - end, - settings = { - json = { - format = { - enable = true, - }, - validate = { enable = true }, - }, - }, -}) - -require("lspconfig").gopls.setup({ - settings = { - -- https://go.googlesource.com/vscode-go/+/HEAD/docs/settings.md#settings-for - gopls = { - analyses = { - nilness = true, - unusedparams = true, - unusedwrite = true, - useany = true - }, - experimentalPostfixCompletions = true, - gofumpt = true, - staticcheck = true, - usePlaceholders = true, - hints = { - assignVariableTypes = true, - compositeLiteralFields = true, - compositeLiteralTypes = true, - constantValues = true, - functionTypeParameters = true, - parameterNames = true, - rangeVariableTypes = true - } - } - } -}) diff --git a/nvim/lua/plugins/auto-save.lua b/nvim/lua/plugins/auto-save.lua index c411a80..05557a5 100644 --- a/nvim/lua/plugins/auto-save.lua +++ b/nvim/lua/plugins/auto-save.lua @@ -1,8 +1,7 @@ return { { "auto-save.nvim", - lazy = false, - load = function() end, + event = { "InsertLeave", "TextChanged", }, keys = { { "w", @@ -12,7 +11,6 @@ return { desc = "Toggle autosave" }, }, - event = { "InsertLeave", "TextChanged", }, opts = { write_all_buffers = true, condition = function(buf) @@ -23,9 +21,11 @@ return { return ft ~= "oil" and ft ~= "harpoon" end, }, - after = function(plug) + beforeAll = function() vim.g.auto_save_state = true - require("auto-save").setup(plug.opt) + end, + after = function(plug) + require("auto-save").setup(plug.opts) end, }, } diff --git a/nvim/lua/plugins/blink.lua b/nvim/lua/plugins/blink.lua index 634373c..4de4aa2 100644 --- a/nvim/lua/plugins/blink.lua +++ b/nvim/lua/plugins/blink.lua @@ -1,8 +1,7 @@ return { { "blink-cmp", - lazy = false, - load = function() end, + event = "InsertEnter", opts = { keymap = { preset = "default", diff --git a/nvim/lua/plugins/conform.lua b/nvim/lua/plugins/conform.lua index 5336628..1e4e56d 100644 --- a/nvim/lua/plugins/conform.lua +++ b/nvim/lua/plugins/conform.lua @@ -1,8 +1,6 @@ return { { "conform.nvim", - lazy = false, - load = function() end, cmd = "ConformInfo", keys = { { diff --git a/nvim/lua/plugins/git.lua b/nvim/lua/plugins/git.lua index a4cf0cc..b0ee311 100644 --- a/nvim/lua/plugins/git.lua +++ b/nvim/lua/plugins/git.lua @@ -1,8 +1,6 @@ return { { "gitsigns.nvim", - lazy = false, - load = function() end, event = { "BufReadPost", "BufWritePost", "BufNewFile" }, opts = { signs = { @@ -23,8 +21,8 @@ return { vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc }) end - map("n", "]h", gs.next_hunk, "Next Hunk") - map("n", "[h", gs.prev_hunk, "Prev Hunk") + map('n', ']h', function() gs.nav_hunk('next') end, "Next Hunk") + map('n', '[h', function() gs.nav_hunk('prev') end, "Prev Hunk") map({ "n", "v" }, "ga", ":Gitsigns stage_hunk", "Add Hunk") map({ "n", "v" }, "gr", ":Gitsigns reset_hunk", "Reset Hunk") map("n", "gu", gs.undo_stage_hunk, "Unstage Hunk") @@ -43,7 +41,6 @@ return { { "git-conflict.nvim", lazy = false, - load = function() end, keys = { { "gxo", "(git-conflict-ours)", desc = "Accept ours" }, { "gxt", "(git-conflict-theirs)", desc = "Accept theirs" }, diff --git a/nvim/lua/plugins/line.lua b/nvim/lua/plugins/line.lua index 9a079ad..6f85c92 100644 --- a/nvim/lua/plugins/line.lua +++ b/nvim/lua/plugins/line.lua @@ -1,8 +1,6 @@ return { { "nvim-navic", - lazy = false, - load = function() end, opts = { highlight = true, lsp = { @@ -16,8 +14,6 @@ return { { "lualine.nvim", - lazy = false, - load = function() end, opts = { options = { theme = "auto", diff --git a/nvim/lua/plugins/lint.lua b/nvim/lua/plugins/lint.lua index d9023d3..470c528 100644 --- a/nvim/lua/plugins/lint.lua +++ b/nvim/lua/plugins/lint.lua @@ -1,8 +1,6 @@ return { { "nvim-lint", - lazy = false, - load = function() end, event = { "BufReadPost", "BufWritePost", "BufNewFile" }, opts = { javascript = { "biomejs", "eslint_d" }, diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua new file mode 100644 index 0000000..01875af --- /dev/null +++ b/nvim/lua/plugins/lsp.lua @@ -0,0 +1,67 @@ +return { + { + "lsp", + event = { "BufReadPost", "BufWritePost", "BufNewFile" }, + load = function() end, + after = function() + -- see https://github.com/neovim/nvim-lspconfig/issues/3494 + require("lspconfig").lua_ls.setup({}) + require("lspconfig").hls.setup({}) + require("lspconfig").rust_analyzer.setup({}) + require("lspconfig").clangd.setup({}) + require("lspconfig").omnisharp.setup({}) + require("lspconfig").pyright.setup({}) + require("lspconfig").nil_ls.setup({}) + require("lspconfig").ts_ls.setup({}) + require("lspconfig").yamlls.setup({}) + require("lspconfig").marksman.setup({}) + require("lspconfig").ltex.setup({}) + require("lspconfig").texlab.setup({}) + require("lspconfig").html.setup({}) + require("lspconfig").helm_ls.setup({}) + require("lspconfig").zls.setup({}) + + require("lspconfig").jsonls.setup({ + on_new_config = function(new_config) + new_config.settings.json.schemas = new_config.settings.json.schemas or {} + vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas()) + end, + settings = { + json = { + format = { + enable = true, + }, + validate = { enable = true }, + }, + }, + }) + + require("lspconfig").gopls.setup({ + settings = { + -- https://go.googlesource.com/vscode-go/+/HEAD/docs/settings.md#settings-for + gopls = { + analyses = { + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true + }, + experimentalPostfixCompletions = true, + gofumpt = true, + staticcheck = true, + usePlaceholders = true, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true + } + } + } + }) + end, + }, +} diff --git a/nvim/lua/plugins/mini.lua b/nvim/lua/plugins/mini.lua index 1d0fd00..aed3fbf 100644 --- a/nvim/lua/plugins/mini.lua +++ b/nvim/lua/plugins/mini.lua @@ -1,8 +1,6 @@ return { { "mini.icons", - lazy = false, - load = function() end, after = function() require("mini.icons").setup(); MiniIcons.mock_nvim_web_devicons() @@ -11,8 +9,6 @@ return { { "mini.operators", - lazy = false, - load = function() end, opts = { replace = { prefix = "cr", @@ -31,8 +27,6 @@ return { { "mini.splitjoin", - lazy = false, - load = function() end, keys = { { "gS", desc = "Split arguments" }, { "gJ", desc = "Join arguments" }, diff --git a/nvim/lua/plugins/motions.lua b/nvim/lua/plugins/motions.lua index 6de80c4..f57873a 100644 --- a/nvim/lua/plugins/motions.lua +++ b/nvim/lua/plugins/motions.lua @@ -1,8 +1,6 @@ return { { "nvim-surround", - lazy = false, - load = function() end, after = function() require("nvim-surround").setup({}) end, @@ -10,8 +8,6 @@ return { { "vim-wordmotion", - lazy = false, - load = function() end, keys = { -- This overrides the default ge & gw but i never used them. { "gw", "WordMotion_w", desc = "Next small world", mode = { "n", "x", "o" } }, @@ -20,15 +16,13 @@ return { { "igw", "WordMotion_iw", desc = "inner small word", mode = { "x", "o" } }, { "agw", "WordMotion_aw", desc = "a small word (with white-space)", mode = { "x", "o" } }, }, - after = function() + before = function() vim.g.wordmotion_nomap = true end, }, { "increment-activator", - lazy = false, - load = function() end, keys = { { "", desc = "Increment" }, { "", desc = "Decrement" }, @@ -37,8 +31,6 @@ return { { "leap.nvim", - load = function() end, - lazy = false, keys = { { "s", "(leap-forward-till)", mode = { "n", "x", }, desc = "Leap forward to" }, { "S", "(leap-backward)", mode = { "n", "x", }, desc = "Leap backward to" }, @@ -49,8 +41,6 @@ return { { "flit.nvim", - load = function() end, - lazy = false, keys = { "f", "F", "t", "T" }, after = function() require("flit").setup() diff --git a/nvim/lua/plugins/noice.lua b/nvim/lua/plugins/noice.lua index c95a41c..94d4e32 100644 --- a/nvim/lua/plugins/noice.lua +++ b/nvim/lua/plugins/noice.lua @@ -1,16 +1,16 @@ return { { "noice.nvim", - lazy = false, - load = function() end, opts = { presets = { command_palette = true, inc_rename = true, }, - signature = { - auto_open = { - enabled = false, + lsp = { + signature = { + auto_open = { + enabled = false, + }, }, }, views = { diff --git a/nvim/lua/plugins/oil.lua b/nvim/lua/plugins/oil.lua index 3104f6a..e1cf684 100644 --- a/nvim/lua/plugins/oil.lua +++ b/nvim/lua/plugins/oil.lua @@ -2,7 +2,6 @@ return { { "oil.nvim", lazy = false, - load = function() end, keys = { { "-", "Oil", desc = "Open parent directory" }, { "", "Oil", desc = "Open parent directory" }, diff --git a/nvim/lua/plugins/statuscol.lua b/nvim/lua/plugins/statuscol.lua index 8955adc..a5038d9 100644 --- a/nvim/lua/plugins/statuscol.lua +++ b/nvim/lua/plugins/statuscol.lua @@ -1,8 +1,6 @@ return { { "statuscol.nvim", - lazy = false, - load = function() end, after = function() local builtin = require("statuscol.builtin") require("statuscol").setup({ diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index b84c660..0a11aa9 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -1,6 +1,7 @@ return { { "telescope.nvim", + load = vim.cmd.packadd, cmd = "Telescope", keys = { { "f", "Telescope find_files", desc = "Find Files" }, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index 887a831..1b75706 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -1,8 +1,9 @@ return { { "nvim-treesitter", - lazy = false, - load = function() end, + load = function() + vim.cmd.packadd("nvim-treesitter-textobjects") + end, event = { "BufReadPost", "BufWritePost", "BufNewFile" }, opts = { highlight = { @@ -36,8 +37,6 @@ return { { "ts-comments.nvim", - lazy = false, - load = function() end, after = function() require("ts-comments").setup({}) end, @@ -45,8 +44,7 @@ return { { "vim-illuminate", - lazy = false, - load = function() end, + load = vim.cmd.packadd, event = { "BufReadPost", "BufWritePost", "BufNewFile" }, opts = { providers = { diff --git a/nvim/lua/plugins/ui.lua b/nvim/lua/plugins/ui.lua index d2e6c7c..2a66808 100644 --- a/nvim/lua/plugins/ui.lua +++ b/nvim/lua/plugins/ui.lua @@ -1,8 +1,6 @@ return { { "undotree", - load = function() end, - lazy = false, keys = { { "u", vim.cmd.UndotreeToggle, desc = "Show undotree" }, }, @@ -10,8 +8,6 @@ return { { "which-key.nvim", - load = function() end, - lazy = false, opts = { plugins = { spelling = true }, }, @@ -23,8 +19,6 @@ return { { "nvim-colorizer.lua", - load = function() end, - lazy = false, event = "BufReadPre", opts = { filetypes = { @@ -51,8 +45,6 @@ return { { "nvim-pqf", - load = function() end, - lazy = false, ft = "qf", after = function() require("pqf").setup() @@ -61,8 +53,6 @@ return { { "virt-column.nvim", - lazy = false, - load = function() end, opts = { char = "▕", }, @@ -73,8 +63,6 @@ return { { "indent-blankline.nvim", - lazy = false, - load = function() end, event = { "BufReadPost", "BufWritePost", "BufNewFile" }, opts = { indent = { diff --git a/nvim/lua/settings.lua b/nvim/lua/settings.lua index 2e04703..e5b8e6d 100644 --- a/nvim/lua/settings.lua +++ b/nvim/lua/settings.lua @@ -94,15 +94,38 @@ end) vim.api.nvim_create_autocmd("TextYankPost", { - desc = 'Highlight when yanking (copying) text', - group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }), + desc = "Highlight when yanking (copying) text", + group = vim.api.nvim_create_augroup("highlight-yank", { clear = true }), callback = function() vim.highlight.on_yank({ - higroup = 'Visual', + higroup = "Visual", }) end, }) +vim.api.nvim_create_autocmd("BufEnter", { + desc = "Disable comment continuation (enter or o/O)", + group = vim.api.nvim_create_augroup("comment-ro", { clear = true }), + callback = function() + vim.opt.formatoptions:remove("ro") + end, +}) + vim.cmd.colorscheme("catppuccin") -require("./lsp") +if vim.g.have_nerd_font then + vim.diagnostic.config({ + signs = { + text = { + [vim.diagnostic.severity.ERROR] = "󰅚", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.HINT] = "󰌶", + [vim.diagnostic.severity.INFO] = "", + }, + }, + }) +end +vim.diagnostic.config({ + virtual_text = false, + update_in_insert = true, +})