From b8d3a1c2cd0255a6c7d026f2b6481dc842d0f0f7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 10:13:00 +0200 Subject: [PATCH 001/362] Revert "fix(yanky): don't override c-p insert mode telescope mapping. Fixes #1007" This reverts commit 8b1e7976a004d7e0cbaec37546d2889ddab48bbb. --- lua/lazyvim/plugins/extras/coding/yanky.lua | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/lua/lazyvim/plugins/extras/coding/yanky.lua b/lua/lazyvim/plugins/extras/coding/yanky.lua index f0bd966b..00b675e9 100644 --- a/lua/lazyvim/plugins/extras/coding/yanky.lua +++ b/lua/lazyvim/plugins/extras/coding/yanky.lua @@ -3,21 +3,10 @@ return { { "gbprod/yanky.nvim", dependencies = { { "kkharji/sqlite.lua", enabled = not jit.os:find("Windows") } }, - opts = function() - local mapping = require("yanky.telescope.mapping") - local mappings = mapping.get_defaults() - mappings.i[""] = nil - return { - highlight = { timer = 200 }, - ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" }, - picker = { - telescope = { - use_default_mappings = false, - mappings = mappings, - }, - }, - } - end, + opts = { + highlight = { timer = 250 }, + ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" }, + }, keys = { -- stylua: ignore { "p", function() require("telescope").extensions.yank_history.yank_history({ }) end, desc = "Open Yank History" }, From a180c3097c7a0386f72d8303ab396707798d5d19 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 26 Sep 2023 08:14:33 +0000 Subject: [PATCH 002/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 613586da..6c1b7084 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 04 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 26 ============================================================================== Table of Contents *LazyVim-table-of-contents* From f892ba5cffe8fcac724ad6b801e0824b391fa037 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 10:57:41 +0200 Subject: [PATCH 003/362] fix: always lazy load keymaps. fixes #1485 --- lua/lazyvim/config/init.lua | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 5c5e70dd..9b61b32f 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -98,22 +98,23 @@ function M.setup(opts) error("Exiting") end - if vim.fn.argc(-1) == 0 then - -- autocmds and keymaps can wait to load - vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), - pattern = "VeryLazy", - callback = function() - M.load("autocmds") - M.load("keymaps") - end, - }) - else - -- load them now so they affect the opened buffers + -- autocmds can be loaded lazily when not opening a file + local lazy_autocmds = vim.fn.argc(-1) == 0 + if not lazy_autocmds then M.load("autocmds") - M.load("keymaps") end + vim.api.nvim_create_autocmd("User", { + group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), + pattern = "VeryLazy", + callback = function() + if lazy_autocmds then + M.load("autocmds") + end + M.load("keymaps") + end, + }) + require("lazy.core.util").try(function() if type(M.colorscheme) == "function" then M.colorscheme() From afdcec5b4adccd94ff64774340a3ffd33a9d4ecf Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 10:58:35 +0200 Subject: [PATCH 004/362] feat(extras): added simple csharp extra --- lua/lazyvim/plugins/extras/lang/omnisharp.lua | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/omnisharp.lua diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua new file mode 100644 index 00000000..5e17c0c9 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -0,0 +1,51 @@ +return { + { "Hoffs/omnisharp-extended-lsp.nvim", lazy = true }, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "c_sharp" }) + end + end, + }, + { + "jose-elias-alvarez/null-ls.nvim", + opts = function(_, opts) + local nls = require("null-ls") + table.insert(opts.sources, nls.builtins.formatting.csharpier) + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + table.insert(opts.ensure_installed, "csharpier") + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + omnisharp = { + handlers = { + ["textDocument/definition"] = function(...) + return require("omnisharp_extended").handler(...) + end, + }, + keys = { + { + "gd", + function() + require("omnisharp_extended").telescope_lsp_definitions() + end, + desc = "Goto Definition", + }, + }, + enable_roslyn_analyzers = true, + organize_imports_on_format = true, + enable_import_completion = true, + }, + }, + }, + }, +} From 0bff29c07a0d5fb4ef36ba4add2b9c4ee243f8a9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 13:24:03 +0200 Subject: [PATCH 005/362] fix: disable context commentstring autocmd --- lua/lazyvim/plugins/coding.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index cbf94e77..65891244 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -137,7 +137,13 @@ return { }, -- comments - { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + lazy = true, + opts = { + enable_autocmd = false, + }, + }, { "echasnovski/mini.comment", event = "VeryLazy", From e54d0dde623c206c4f7ed9a512785c9fc0de3a22 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 13:27:18 +0200 Subject: [PATCH 006/362] feat(autocmds): close InspectTree window with q --- lua/lazyvim/config/autocmds.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index c8a513f5..a3ba5c91 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -55,6 +55,7 @@ vim.api.nvim_create_autocmd("FileType", { "man", "notify", "qf", + "query", "spectre_panel", "startuptime", "tsplayground", From a7f971f30ec89473482db4ab820d2afb25fa6abf Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Tue, 26 Sep 2023 05:34:28 -0600 Subject: [PATCH 007/362] feat(mini-pairs): add toggle mini pairs keymap and function (#1456) --- lua/lazyvim/plugins/coding.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 65891244..87172e1d 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -97,6 +97,21 @@ return { "echasnovski/mini.pairs", event = "VeryLazy", opts = {}, + keys = { + { + "up", + function() + local Util = require("lazy.core.util") + vim.g.minipairs_disable = not vim.g.minipairs_disable + if vim.g.minipairs_disable then + Util.warn("Disabled auto pairs", { title = "Option" }) + else + Util.info("Enabled auto pairs", { title = "Option" }) + end + end, + desc = "Toggle auto pairs", + }, + }, }, -- Fast and feature-rich surround actions. For text that includes From ea930e35457df4a367b537c472af8d5c6e8ae7eb Mon Sep 17 00:00:00 2001 From: Hai Ninh Hoang <34930708+haininhhoang94@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:35:27 +0700 Subject: [PATCH 008/362] fix(python): use venv for DAP Python (#1457) dap_enabled = true, -- Ensure that the venv selector affect PythonPath in nvim-dap as well! (in venv-selector.nvim) --- lua/lazyvim/plugins/extras/lang/python.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index e64decd1..4530bd97 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -68,6 +68,7 @@ return { "env", ".env", }, + dap_enabled = true, -- Ensure that the venv selector affect PythonPath in nvim-dap as well! }, keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, }, From 5dc4ce3e4a452438838c271330df156fd3640c60 Mon Sep 17 00:00:00 2001 From: aqav <66734646+aqav@users.noreply.github.com> Date: Tue, 26 Sep 2023 19:36:22 +0800 Subject: [PATCH 009/362] feat(java): support vscode launch json in Java (#1422) * feat(java): support vscode launch json * feat(java): support vscode launch json --- lua/lazyvim/plugins/extras/lang/java.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 64808bee..11aa2a1c 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -199,6 +199,8 @@ return { -- custom init for Java debugger require("jdtls").setup_dap(opts.dap) require("jdtls.dap").setup_dap_main_class_configs() + -- setup dap config by VsCode launch.json file + require("dap.ext.vscode").load_launchjs() -- Java Test require Java debugger to work if opts.test and mason_registry.is_installed("java-test") then From f1af34e88525cc291b7bacc76d915b642aef192b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 13:38:48 +0200 Subject: [PATCH 010/362] fix(dap): move launchjs code from java to dap --- lua/lazyvim/plugins/extras/dap/core.lua | 2 ++ lua/lazyvim/plugins/extras/lang/java.lua | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index e228afac..d537e575 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -13,6 +13,8 @@ return { }, opts = {}, config = function(_, opts) + -- setup dap config by VsCode launch.json file + require("dap.ext.vscode").load_launchjs() local dap = require("dap") local dapui = require("dapui") dapui.setup(opts) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 11aa2a1c..64808bee 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -199,8 +199,6 @@ return { -- custom init for Java debugger require("jdtls").setup_dap(opts.dap) require("jdtls.dap").setup_dap_main_class_configs() - -- setup dap config by VsCode launch.json file - require("dap.ext.vscode").load_launchjs() -- Java Test require Java debugger to work if opts.test and mason_registry.is_installed("java-test") then From 7c79cfe07314245decd73ec67e7247bba22abaa9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 26 Sep 2023 14:16:22 +0200 Subject: [PATCH 011/362] fix(mini.comment): better lua pattern for tags. Fixes #1413 --- lua/lazyvim/plugins/coding.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 87172e1d..7250638d 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -191,6 +191,7 @@ return { }, {}), f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}), + t = { "<([%p%w]-)%f[^<%w][^<>]->.-", "^<.->().*()$" }, }, } end, From 50401d358b7be9b931b42fc3b537794920308bef Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Sep 2023 14:59:08 +0200 Subject: [PATCH 012/362] chore(main): release 6.4.0 (#1495) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b553d773..374f3ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [6.4.0](https://github.com/LazyVim/LazyVim/compare/v6.3.0...v6.4.0) (2023-09-26) + + +### Features + +* **autocmds:** close InspectTree window with q ([e54d0dd](https://github.com/LazyVim/LazyVim/commit/e54d0dde623c206c4f7ed9a512785c9fc0de3a22)) +* **extras:** added simple csharp extra ([afdcec5](https://github.com/LazyVim/LazyVim/commit/afdcec5b4adccd94ff64774340a3ffd33a9d4ecf)) +* **java:** support vscode launch json in Java ([#1422](https://github.com/LazyVim/LazyVim/issues/1422)) ([5dc4ce3](https://github.com/LazyVim/LazyVim/commit/5dc4ce3e4a452438838c271330df156fd3640c60)) +* **mini-pairs:** add toggle mini pairs keymap and function ([#1456](https://github.com/LazyVim/LazyVim/issues/1456)) ([a7f971f](https://github.com/LazyVim/LazyVim/commit/a7f971f30ec89473482db4ab820d2afb25fa6abf)) + + +### Bug Fixes + +* always lazy load keymaps. fixes [#1485](https://github.com/LazyVim/LazyVim/issues/1485) ([f892ba5](https://github.com/LazyVim/LazyVim/commit/f892ba5cffe8fcac724ad6b801e0824b391fa037)) +* **dap:** move launchjs code from java to dap ([f1af34e](https://github.com/LazyVim/LazyVim/commit/f1af34e88525cc291b7bacc76d915b642aef192b)) +* disable context commentstring autocmd ([0bff29c](https://github.com/LazyVim/LazyVim/commit/0bff29c07a0d5fb4ef36ba4add2b9c4ee243f8a9)) +* **mini.comment:** better lua pattern for tags. Fixes [#1413](https://github.com/LazyVim/LazyVim/issues/1413) ([7c79cfe](https://github.com/LazyVim/LazyVim/commit/7c79cfe07314245decd73ec67e7247bba22abaa9)) +* **python:** use venv for DAP Python ([#1457](https://github.com/LazyVim/LazyVim/issues/1457)) ([ea930e3](https://github.com/LazyVim/LazyVim/commit/ea930e35457df4a367b537c472af8d5c6e8ae7eb)) + ## [6.3.0](https://github.com/LazyVim/LazyVim/compare/v6.2.0...v6.3.0) (2023-09-04) From 36d6a7fe4f4e7d5c9ffceca0496655a889df2ebc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 27 Sep 2023 13:56:23 +0200 Subject: [PATCH 013/362] fix(dap): revert loading vscode launch files. Add it to your own config when needed. Fixes #1503 --- lua/lazyvim/plugins/extras/dap/core.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index d537e575..3b623df5 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -14,7 +14,7 @@ return { opts = {}, config = function(_, opts) -- setup dap config by VsCode launch.json file - require("dap.ext.vscode").load_launchjs() + -- require("dap.ext.vscode").load_launchjs() local dap = require("dap") local dapui = require("dapui") dapui.setup(opts) From b30ff44af5645aa28b3812866f6e9e5738c10d62 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 27 Sep 2023 11:57:42 +0000 Subject: [PATCH 014/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 6c1b7084..baad8467 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 26 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 27 ============================================================================== Table of Contents *LazyVim-table-of-contents* From a1ab7c6e32c67b66ed2f318b5e971ebaab3999b0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 27 Sep 2023 14:48:32 +0200 Subject: [PATCH 015/362] chore(main): release 6.4.1 (#1505) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 374f3ed5..69467336 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [6.4.1](https://github.com/LazyVim/LazyVim/compare/v6.4.0...v6.4.1) (2023-09-27) + + +### Bug Fixes + +* **dap:** revert loading vscode launch files. Add it to your own config when needed. Fixes [#1503](https://github.com/LazyVim/LazyVim/issues/1503) ([36d6a7f](https://github.com/LazyVim/LazyVim/commit/36d6a7fe4f4e7d5c9ffceca0496655a889df2ebc)) + ## [6.4.0](https://github.com/LazyVim/LazyVim/compare/v6.3.0...v6.4.0) (2023-09-26) From db86635e3276451f795da4f8af64eff94391fe48 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 07:40:58 +0200 Subject: [PATCH 016/362] fix(indent-blankline): upgrade ibl config to v3 --- lua/lazyvim/plugins/ui.lua | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 3976c974..3f698415 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -168,23 +168,27 @@ return { "lukas-reineke/indent-blankline.nvim", event = { "BufReadPost", "BufNewFile" }, opts = { - -- char = "▏", - char = "│", - filetype_exclude = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", + indent = { + char = "│", + highlight = "IndentBlanklineChar", + }, + scope = { enabled = false }, + exclude = { + filetypes = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, }, - show_trailing_blankline_indent = false, - show_current_context = false, }, + main = "ibl", }, -- Active indent guide and indent text objects. When you're browsing From ee068d8399cad2231d2195c31aee368a303a4d11 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 28 Sep 2023 05:41:46 +0000 Subject: [PATCH 017/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index baad8467..fbacd536 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 27 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 28 ============================================================================== Table of Contents *LazyVim-table-of-contents* From b25559d3977d51cfb444639d9999fd69a5ba40d1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 07:46:31 +0200 Subject: [PATCH 018/362] chore(main): release 6.4.2 (#1510) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 69467336..3238f9c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [6.4.2](https://github.com/LazyVim/LazyVim/compare/v6.4.1...v6.4.2) (2023-09-28) + + +### Bug Fixes + +* **indent-blankline:** upgrade ibl config to v3 ([db86635](https://github.com/LazyVim/LazyVim/commit/db86635e3276451f795da4f8af64eff94391fe48)) + ## [6.4.1](https://github.com/LazyVim/LazyVim/compare/v6.4.0...v6.4.1) (2023-09-27) From b220e541594a0ef556d1515649cd99d45fe94058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoine=20B=C3=BCsch?= Date: Thu, 28 Sep 2023 16:41:55 +1000 Subject: [PATCH 019/362] fix(telescope): add enums and consts to search symbols (#1512) --- lua/lazyvim/plugins/editor.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index d073dc58..e726768a 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -138,6 +138,8 @@ return { "Trait", "Field", "Property", + "Enum", + "Constant", }, }), desc = "Goto Symbol", @@ -156,6 +158,8 @@ return { "Trait", "Field", "Property", + "Enum", + "Constant", }, }), desc = "Goto Symbol (Workspace)", From 7f5051ef72cfe66eb50ddb7c973714aa8aea04ec Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 09:00:31 +0200 Subject: [PATCH 020/362] fix(yamlls): work-around for yaml formatting on Neovim < 0.10. Fixes #1435 --- lua/lazyvim/plugins/extras/lang/yaml.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index ca808bbf..0a174aa2 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -54,6 +54,18 @@ return { }, }, }, + setup = { + yamlls = function() + -- Neovim < 0.10 does not have dynamic registration for formatting + if vim.fn.has("nvim-0.10") == 0 then + require("lazyvim.util").on_attach(function(client, _) + if client.name == "yamlls" then + client.server_capabilities.documentFormattingProvider = true + end + end) + end + end, + }, }, }, } From 74786c21d743db0fabed61b90bf7ecaab16bbf14 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 10:54:30 +0200 Subject: [PATCH 021/362] fix(ibl): use default hl groups --- lua/lazyvim/plugins/ui.lua | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 3f698415..cdc38c0a 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -168,10 +168,7 @@ return { "lukas-reineke/indent-blankline.nvim", event = { "BufReadPost", "BufNewFile" }, opts = { - indent = { - char = "│", - highlight = "IndentBlanklineChar", - }, + indent = { char = "│" }, scope = { enabled = false }, exclude = { filetypes = { From 13bf7977a4bae39a38ef6a3fad6303366c8b4bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maria=20Jos=C3=A9=20Solano?= Date: Thu, 28 Sep 2023 02:08:43 -0700 Subject: [PATCH 022/362] fix(telescope): replace anonymous functions in mappings by named functions (#1294) --- lua/lazyvim/plugins/editor.lua | 79 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index e726768a..22b67c90 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -165,48 +165,47 @@ return { desc = "Goto Symbol (Workspace)", }, }, - opts = { - defaults = { - prompt_prefix = " ", - selection_caret = " ", - mappings = { - i = { - [""] = function(...) - return require("trouble.providers.telescope").open_with_trouble(...) - end, - [""] = function(...) - return require("trouble.providers.telescope").open_selected_with_trouble(...) - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { no_ignore = true, default_text = line })() - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { hidden = true, default_text = line })() - end, - [""] = function(...) - return require("telescope.actions").cycle_history_next(...) - end, - [""] = function(...) - return require("telescope.actions").cycle_history_prev(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_down(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_up(...) - end, - }, - n = { - ["q"] = function(...) - return require("telescope.actions").close(...) - end, + opts = function() + local actions = require("telescope.actions") + + local open_with_trouble = function(...) + return require("trouble.providers.telescope").open_with_trouble(...) + end + local open_selected_with_trouble = function(...) + return require("trouble.providers.telescope").open_selected_with_trouble(...) + end + local find_files_no_ignore = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { no_ignore = true, default_text = line })() + end + local find_files_with_hidden = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { hidden = true, default_text = line })() + end + + return { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + mappings = { + i = { + [""] = open_with_trouble, + [""] = open_selected_with_trouble, + [""] = find_files_no_ignore, + [""] = find_files_with_hidden, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + }, + n = { + ["q"] = actions.close, + }, }, }, - }, + } }, }, From 017582c05a2d87c73cfe794dd2e296cc0caf86cd Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 11:10:25 +0200 Subject: [PATCH 023/362] fix(telescope): typo --- lua/lazyvim/plugins/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 22b67c90..382626f2 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -206,7 +206,7 @@ return { }, }, } - }, + end, }, -- disable old installations of leap and flit. Optional so it doesn't appear under disabled plugins From d03f708cd3411d6e6dcb20b345b23a03222b0f35 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 11:22:19 +0200 Subject: [PATCH 024/362] chore: removed flash extra since this is now the default --- lua/lazyvim/plugins/extras/editor/flash.lua | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 lua/lazyvim/plugins/extras/editor/flash.lua diff --git a/lua/lazyvim/plugins/extras/editor/flash.lua b/lua/lazyvim/plugins/extras/editor/flash.lua deleted file mode 100644 index d60c2387..00000000 --- a/lua/lazyvim/plugins/extras/editor/flash.lua +++ /dev/null @@ -1,6 +0,0 @@ -require("lazy.core.util").warn( - "`flash.nvim` is now the default jump plugin for **LazyVim**.\nPlease remove the `lazyvim.plugins.extras.editor.flash` import from your **lazy** config.", - { title = "LazyVim" } -) - -return {} From d012a1acb8fe0a7d11868c39e0fae610e4b58e4e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 11:24:20 +0200 Subject: [PATCH 025/362] docs(telescope): documented Telescope find files. Fixes #1425 --- lua/lazyvim/plugins/editor.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 382626f2..1b4f7558 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -82,7 +82,10 @@ return { }, }, - -- fuzzy finder + -- Fuzzy finder. + -- The default key bindings to find files will use Telescope's + -- `find_files` or `git_files` depending on whether the + -- directory is a git repo. { "nvim-telescope/telescope.nvim", commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil, From fa6cbfc6020efcd2168ffe09a209037599b91442 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 11:33:45 +0200 Subject: [PATCH 026/362] fix(lsp): don't install jsonls by default. It's part of the json extra --- lua/lazyvim/plugins/lsp/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 8c5dc71a..08b9f4b3 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -54,7 +54,6 @@ return { -- LSP Server Settings ---@type lspconfig.options servers = { - jsonls = {}, lua_ls = { -- mason = false, -- set to false if you don't want this server to be installed with mason -- Use this to add any additional keymaps @@ -123,7 +122,7 @@ return { if opts.inlay_hints.enabled and inlay_hint then Util.on_attach(function(client, buffer) - if client.supports_method('textDocument/inlayHint') then + if client.supports_method("textDocument/inlayHint") then inlay_hint(buffer, true) end end) From a3011daf403e985498320b930872b06065f693a3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 28 Sep 2023 11:36:58 +0200 Subject: [PATCH 027/362] style: better plugin docs --- lua/lazyvim/plugins/ui.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index cdc38c0a..c66c5a4f 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -221,7 +221,7 @@ return { end, }, - -- noicer ui + -- Displays a popup with possible key bindings of the command you started typing { "folke/which-key.nvim", opts = function(_, opts) @@ -230,6 +230,8 @@ return { end end, }, + + -- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu. { "folke/noice.nvim", event = "VeryLazy", From 274649e92321d615888f889476c9329f8d831e8e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:04:36 +0200 Subject: [PATCH 028/362] chore(main): release 6.4.3 (#1514) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3238f9c1..392ba8fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [6.4.3](https://github.com/LazyVim/LazyVim/compare/v6.4.2...v6.4.3) (2023-09-28) + + +### Bug Fixes + +* **ibl:** use default hl groups ([74786c2](https://github.com/LazyVim/LazyVim/commit/74786c21d743db0fabed61b90bf7ecaab16bbf14)) +* **lsp:** don't install jsonls by default. It's part of the json extra ([fa6cbfc](https://github.com/LazyVim/LazyVim/commit/fa6cbfc6020efcd2168ffe09a209037599b91442)) +* **telescope:** add enums and consts to search symbols ([#1512](https://github.com/LazyVim/LazyVim/issues/1512)) ([b220e54](https://github.com/LazyVim/LazyVim/commit/b220e541594a0ef556d1515649cd99d45fe94058)) +* **telescope:** replace anonymous functions in mappings by named functions ([#1294](https://github.com/LazyVim/LazyVim/issues/1294)) ([13bf797](https://github.com/LazyVim/LazyVim/commit/13bf7977a4bae39a38ef6a3fad6303366c8b4bea)) +* **telescope:** typo ([017582c](https://github.com/LazyVim/LazyVim/commit/017582c05a2d87c73cfe794dd2e296cc0caf86cd)) +* **yamlls:** work-around for yaml formatting on Neovim < 0.10. Fixes [#1435](https://github.com/LazyVim/LazyVim/issues/1435) ([7f5051e](https://github.com/LazyVim/LazyVim/commit/7f5051ef72cfe66eb50ddb7c973714aa8aea04ec)) + ## [6.4.2](https://github.com/LazyVim/LazyVim/compare/v6.4.1...v6.4.2) (2023-09-28) From 7cac6f064c5b30f6b0ae4dffab62100aa6fe2568 Mon Sep 17 00:00:00 2001 From: Ahmed W Date: Fri, 29 Sep 2023 04:52:45 -0500 Subject: [PATCH 029/362] feat(null-ls)!: use none-ls instead of null-ls (#1517) * FEATURE: use none-ls instead of null-ls Fixes #1516 * fix(none-ls): automatically migrate null-ls to none-ls * feat(config): show warning if user config contains renamed references --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/config/init.lua | 10 ++++++++++ lua/lazyvim/plugins/extras/formatting/prettier.lua | 2 +- lua/lazyvim/plugins/extras/lang/cmake.lua | 2 +- lua/lazyvim/plugins/extras/lang/docker.lua | 2 +- lua/lazyvim/plugins/extras/lang/go.lua | 2 +- lua/lazyvim/plugins/extras/lang/omnisharp.lua | 2 +- lua/lazyvim/plugins/extras/lang/terraform.lua | 2 +- lua/lazyvim/plugins/extras/lang/typescript.lua | 2 +- lua/lazyvim/plugins/lsp/init.lua | 2 +- 9 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 9b61b32f..5e1d5bf2 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -79,6 +79,8 @@ local defaults = { M.renames = { ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", + ["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim", + ["null-ls.nvim"] = "none-ls.nvim", } ---@type LazyVimConfig @@ -181,6 +183,14 @@ function M.init() local add = Plugin.Spec.add Plugin.Spec.add = function(self, plugin, ...) if type(plugin) == "table" and M.renames[plugin[1]] then + require("lazy.core.util").warn( + ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( + plugin[1], + M.renames[plugin[1]], + self.importing or "LazyVim" + ), + { title = "LazyVim" } + ) plugin[1] = M.renames[plugin[1]] end return add(self, plugin, ...) diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index e16b9805..359de5a7 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -6,7 +6,7 @@ return { end, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.prettierd) diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index 9d82c71b..73569db6 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -8,7 +8,7 @@ return { end, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) local nls = require("null-ls") opts.sources = opts.sources or {} diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index 5cadf864..26a39ac9 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -8,7 +8,7 @@ return { end, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) local nls = require("null-ls") opts.sources = opts.sources or {} diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index a78a7434..252e2cca 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -83,7 +83,7 @@ return { }, -- Ensure Go tools are installed { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) if type(opts.sources) == "table" then local nls = require("null-ls") diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index 5e17c0c9..f0ab8317 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -9,7 +9,7 @@ return { end, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.csharpier) diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index 441887fa..79748567 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -25,7 +25,7 @@ return { }, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) if type(opts.sources) == "table" then local null_ls = require("null-ls") diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 32f4079e..9734749e 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -53,7 +53,7 @@ return { }, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", opts = function(_, opts) table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions")) end, diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 08b9f4b3..d69ec824 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -205,7 +205,7 @@ return { -- formatters { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", event = { "BufReadPre", "BufNewFile" }, dependencies = { "mason.nvim" }, opts = function() From 3c448a1be1d88711309026393f30da3a4de68235 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 29 Sep 2023 09:53:29 +0000 Subject: [PATCH 030/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index fbacd536..cc9daf2b 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 28 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 29 ============================================================================== Table of Contents *LazyVim-table-of-contents* From a7f68e5e378f1431fc334036f29826f601e861ac Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 11:59:05 +0200 Subject: [PATCH 031/362] refactor(none-ls): make all null-ls usages in extras optional --- lua/lazyvim/plugins/extras/formatting/prettier.lua | 1 + lua/lazyvim/plugins/extras/lang/cmake.lua | 1 + lua/lazyvim/plugins/extras/lang/docker.lua | 1 + lua/lazyvim/plugins/extras/lang/go.lua | 1 + lua/lazyvim/plugins/extras/lang/omnisharp.lua | 1 + lua/lazyvim/plugins/extras/lang/terraform.lua | 1 + lua/lazyvim/plugins/extras/lang/typescript.lua | 1 + 7 files changed, 7 insertions(+) diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 359de5a7..3e4d461f 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -7,6 +7,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.prettierd) diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index 73569db6..30d7718c 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -9,6 +9,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) local nls = require("null-ls") opts.sources = opts.sources or {} diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index 26a39ac9..6d85c8d7 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -9,6 +9,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) local nls = require("null-ls") opts.sources = opts.sources or {} diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index 252e2cca..c2946adb 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -84,6 +84,7 @@ return { -- Ensure Go tools are installed { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) if type(opts.sources) == "table" then local nls = require("null-ls") diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index f0ab8317..14f9e34d 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -10,6 +10,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) local nls = require("null-ls") table.insert(opts.sources, nls.builtins.formatting.csharpier) diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index 79748567..182c9f52 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -26,6 +26,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) if type(opts.sources) == "table" then local null_ls = require("null-ls") diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 9734749e..5e3171e4 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -54,6 +54,7 @@ return { }, { "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions")) end, From 6b05ed7dcd729322e2e5b6752655a9491cd17f86 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 12:00:45 +0200 Subject: [PATCH 032/362] fix: remove deprecated leap/flit code checks --- lua/lazyvim/plugins/editor.lua | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 1b4f7558..3059dc84 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -212,30 +212,6 @@ return { end, }, - -- disable old installations of leap and flit. Optional so it doesn't appear under disabled plugins - { - "ggandor/leap.nvim", - enabled = function() - vim.schedule(function() - local Config = require("lazy.core.config") - if Config.spec.disabled["leap.nvim"] or Config.spec.disabled["flit.nvim"] then - require("lazy.core.util").warn( - [[`flash.nvim` is now the default **LazyVim** jump plugin. -**leap.nvim** and **flit.nvim** have been disabled. -Please remove the plugins from your config. -If you rather use leap/flit instead, you can add the leap extra: -`lazyvim.plugins.extras.editor.leap` -]], - { title = "LazyVim" } - ) - end - end) - return false - end, - optional = true, - }, - { "ggandor/flit.nvim", enabled = false, optional = true }, - -- Flash enhances the built-in search functionality by showing labels -- at the end of each match, letting you quickly jump to a specific -- location. From f61a243d1aca582963aca3f2c2c7c2ae0be16b06 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 13:37:00 +0200 Subject: [PATCH 033/362] feat(extras): added `conform.nvim` extra you can use instead of null-ls/none-ls --- .../plugins/extras/formatting/conform.lua | 47 +++++++++++++++++++ .../plugins/extras/formatting/prettier.lua | 24 ++++++++++ lua/lazyvim/plugins/extras/lang/go.lua | 9 ++++ lua/lazyvim/plugins/extras/lang/omnisharp.lua | 15 ++++++ lua/lazyvim/plugins/extras/lang/terraform.lua | 11 +++++ lua/lazyvim/plugins/lsp/format.lua | 9 ++++ 6 files changed, 115 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/formatting/conform.lua diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua new file mode 100644 index 00000000..9858c08e --- /dev/null +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -0,0 +1,47 @@ +-- When `conform.nvim` is enabled, it will automatically be used as the +-- formatter for all files that it supports. +-- When no conform formatter is available for a filetype, LSP format +-- will be used instead. +-- +-- LazyVim adds a custom `formatter_opts` option to allow overriding the +-- default options for each formatter. +return { + { + "stevearc/conform.nvim", + dependencies = { "mason.nvim" }, + lazy = true, + cmd = "ConformInfo", + init = function() + -- Install the conform formatter on VeryLazy + require("lazyvim.util").on_very_lazy(function() + require("lazyvim.plugins.lsp.format").custom_format = function(buf) + return require("conform").format({ bufnr = buf }) + end + end) + end, + opts = { + formatters_by_ft = { + lua = { "stylua" }, + fish = { "fish_indent" }, + sh = { "shfmt" }, + }, + -- LazyVim extension to easily override formatter options + ---@type table + formatter_opts = { + -- -- Example of using dprint only when a dprint.json file is present + -- dprint = { + -- condition = function(ctx) + -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + }, + }, + config = function(_, opts) + opts.formatters = opts.formatters or {} + for f, o in pairs(opts.formatter_opts or {}) do + opts.formatters[f] = vim.tbl_deep_extend("force", require("conform.formatters." .. f), o) + end + require("conform").setup(opts) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 3e4d461f..81fc1939 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -13,4 +13,28 @@ return { table.insert(opts.sources, nls.builtins.formatting.prettierd) end, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + ["javascript"] = { { "prettierd", "prettier" } }, + ["javascriptreact"] = { { "prettierd", "prettier" } }, + ["typescript"] = { { "prettierd", "prettier" } }, + ["typescriptreact"] = { { "prettierd", "prettier" } }, + ["vue"] = { { "prettierd", "prettier" } }, + ["css"] = { { "prettierd", "prettier" } }, + ["scss"] = { { "prettierd", "prettier" } }, + ["less"] = { { "prettierd", "prettier" } }, + ["html"] = { { "prettierd", "prettier" } }, + ["json"] = { { "prettierd", "prettier" } }, + ["jsonc"] = { { "prettierd", "prettier" } }, + ["yaml"] = { { "prettierd", "prettier" } }, + ["markdown"] = { { "prettierd", "prettier" } }, + ["markdown.mdx"] = { { "prettierd", "prettier" } }, + ["graphql"] = { { "prettierd", "prettier" } }, + ["handlebars"] = { { "prettierd", "prettier" } }, + }, + }, + }, } diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index c2946adb..0b0cab70 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -97,6 +97,15 @@ return { end end, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + go = { "goimports", "gofumpt" }, + }, + }, + }, { "mfussenegger/nvim-dap", optional = true, diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index 14f9e34d..d244fd77 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -16,6 +16,21 @@ return { table.insert(opts.sources, nls.builtins.formatting.csharpier) end, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + cs = { "csharpier" }, + }, + formatters = { + csharpier = { + command = "dotnet-csharpier", + args = { "--write-stdout" }, + }, + }, + }, + }, { "williamboman/mason.nvim", opts = function(_, opts) diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index 182c9f52..cb3aeaa2 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -37,4 +37,15 @@ return { end end, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + terraform = { "terraform_fmt" }, + tf = { "terraform_fmt" }, + ["terraform-vars"] = { "terraform_fmt" }, + }, + }, + }, } diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 64c4becf..f862a8a7 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -5,6 +5,11 @@ local M = {} ---@type PluginLspOpts M.opts = nil +-- Allow plugins to set a custom formatter for a buffer. +-- See the conform extra for an example. +---@type fun(bufnr:number):boolean +M.custom_format = nil + function M.enabled() return M.opts.autoformat end @@ -30,6 +35,10 @@ function M.format(opts) return end + if M.custom_format and M.custom_format(buf) then + return + end + local formatters = M.get_formatters(buf) local client_ids = vim.tbl_map(function(client) return client.id From aab365a9f8b6405c6c5a938cb4745e9b770f2261 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 13:57:04 +0200 Subject: [PATCH 034/362] fix(typescript)!: removed `typescript.nvim` since it's deprecated --- .../plugins/extras/lang/typescript.lua | 29 +++++++++---------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 5e3171e4..44a963ec 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -13,15 +13,25 @@ return { -- correctly setup lspconfig { "neovim/nvim-lspconfig", - dependencies = { "jose-elias-alvarez/typescript.nvim" }, opts = { -- make sure mason installs the server servers = { ---@type lspconfig.options.tsserver tsserver = { keys = { - { "co", "TypescriptOrganizeImports", desc = "Organize Imports" }, - { "cR", "TypescriptRenameFile", desc = "Rename File" }, + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports.ts" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, }, settings = { typescript = { @@ -44,21 +54,8 @@ return { }, }, }, - setup = { - tsserver = function(_, opts) - require("typescript").setup({ server = opts }) - return true - end, - }, }, }, - { - "nvimtools/none-ls.nvim", - optional = true, - opts = function(_, opts) - table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions")) - end, - }, { "mfussenegger/nvim-dap", optional = true, From 9762e7e43110013a0931b8470be2929b54b4b641 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 14:14:57 +0200 Subject: [PATCH 035/362] feat(neo-tree): added support for LSP renaming to NeoTree --- lua/lazyvim/plugins/editor.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 3059dc84..8465ca89 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -59,6 +59,27 @@ return { }, }, config = function(_, opts) + opts.event_handlers = opts.event_handlers or {} + + local function on_move(data) + local clients = vim.lsp.get_active_clients() + for _, client in ipairs(clients) do + if client:supports_method("workspace/willRenameFiles") then + local resp = client.request_sync("workspace/willRenameFiles", { + files = { { oldUri = vim.uri_from_fname(data.source), newUri = vim.uri_from_fname(data.destination) } }, + }, 1000) + if resp and resp.result ~= nil then + vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) + end + end + end + end + + local events = require("neo-tree.events") + vim.list_extend(opts.event_handlers, { + { event = events.FILE_MOVED, handler = on_move }, + { event = events.FILE_RENAMED, handler = on_move }, + }) require("neo-tree").setup(opts) vim.api.nvim_create_autocmd("TermClose", { pattern = "*lazygit", From 05f45bb7200a6fd33ab7366553b957fa222e2cdf Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:05:01 +0200 Subject: [PATCH 036/362] feat(extras): added extra for nvim-lint --- lua/lazyvim/plugins/extras/lang/cmake.lua | 9 +++ lua/lazyvim/plugins/extras/lang/docker.lua | 9 +++ lua/lazyvim/plugins/extras/lang/terraform.lua | 10 +++ .../plugins/extras/linting/nvim-lint.lua | 65 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/linting/nvim-lint.lua diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index 30d7718c..cd802edf 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -18,6 +18,15 @@ return { }) end, }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + cmake = { "cmakelint" }, + }, + }, + }, { "mason.nvim", opts = function(_, opts) diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index 6d85c8d7..d3e06ecb 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -25,6 +25,15 @@ return { end, }, }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + dockerfile = { "hadolint" }, + }, + }, + }, { "neovim/nvim-lspconfig", opts = { diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index cb3aeaa2..6e368ff3 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -37,6 +37,16 @@ return { end end, }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + terraform = { "terraform_validate" }, + tf = { "terraform_validate" }, + }, + }, + }, { "stevearc/conform.nvim", optional = true, diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua new file mode 100644 index 00000000..c6c9629a --- /dev/null +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -0,0 +1,65 @@ +return { + { + "mfussenegger/nvim-lint", + event = "BufReadPost", + opts = { + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + linters_by_ft = { + fish = { "fish" }, + }, + linters = {}, + linter_opts = {}, + }, + config = function(_, opts) + local M = {} + M._did_setup = false + + function M.setup() + if M._did_setup then + return + end + local lint = require("lint") + for name, linter in pairs(opts.linters) do + lint.linters[name] = linter + end + lint.linters_by_ft = vim.tbl_extend("force", lint.linters_by_ft, opts.linters_by_ft) + for l, o in pairs(opts.linter_opts or {}) do + lint.linters[l] = vim.tbl_deep_extend("force", lint.linters[l], o) + end + M._did_setup = true + end + + function M.debounce(ms, fn) + local timer = vim.loop.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end + end + + function M.lint() + M.setup() + local lint = require("lint") + local names = lint.linters_by_ft[vim.bo.filetype] or {} + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + return linter and not (linter.condition and not linter.condition(ctx)) + end, names) + + if #names > 0 then + lint.try_lint(names) + end + end + + vim.api.nvim_create_autocmd(opts.events, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, + }, +} From 0f7a009d1cdd9e4449e45d4d40cde3e3813eb794 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:07:29 +0200 Subject: [PATCH 037/362] docs: added more docs to nvim-lint extensions --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index c6c9629a..46a00574 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -3,12 +3,25 @@ return { "mfussenegger/nvim-lint", event = "BufReadPost", opts = { + -- Event to trigger linters events = { "BufWritePost", "BufReadPost", "InsertLeave" }, linters_by_ft = { fish = { "fish" }, }, + -- Custom linters, or fully replace a builtin linters = {}, - linter_opts = {}, + -- LazyVim extension to easily override linter options + ---@type table + linter_opts = { + -- -- Example of using selene only when a selene.toml file is present + selene = { + -- `condition` is another LazyVim extension that allows you to + -- dynamically enable/disable linters based on the context. + condition = function(ctx) + return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + end, + }, + }, }, config = function(_, opts) local M = {} From 886d49eb89cc96dd8942182d4c3d87b252500831 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:15:38 +0200 Subject: [PATCH 038/362] style: comment the selene example --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index 46a00574..fd380c12 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -14,13 +14,13 @@ return { ---@type table linter_opts = { -- -- Example of using selene only when a selene.toml file is present - selene = { - -- `condition` is another LazyVim extension that allows you to - -- dynamically enable/disable linters based on the context. - condition = function(ctx) - return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] - end, - }, + -- selene = { + -- -- `condition` is another LazyVim extension that allows you to + -- -- dynamically enable/disable linters based on the context. + -- condition = function(ctx) + -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, }, }, config = function(_, opts) From 0e5ff5c0ab6930190122df086db5e3f91d8b38b8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:55:29 +0200 Subject: [PATCH 039/362] fix(format): wrap custom formatter with error handler --- lua/lazyvim/plugins/lsp/format.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index f862a8a7..6eb78d0d 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -35,7 +35,9 @@ function M.format(opts) return end - if M.custom_format and M.custom_format(buf) then + if M.custom_format and Util.try(function() + M.custom_format(buf) + end, { msg = "Custom formatter failed" }) then return end From 6bb0d1b66ffe6d0a77ad96d0f945113ddcb9fdb3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:56:20 +0200 Subject: [PATCH 040/362] fix(conform): use `formatters` for both custom and overriding formatters --- .../plugins/extras/formatting/conform.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index 9858c08e..d89385d7 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -1,10 +1,3 @@ --- When `conform.nvim` is enabled, it will automatically be used as the --- formatter for all files that it supports. --- When no conform formatter is available for a filetype, LSP format --- will be used instead. --- --- LazyVim adds a custom `formatter_opts` option to allow overriding the --- default options for each formatter. return { { "stevearc/conform.nvim", @@ -25,9 +18,10 @@ return { fish = { "fish_indent" }, sh = { "shfmt" }, }, - -- LazyVim extension to easily override formatter options + -- LazyVim will merge the options you set here with builtin formatters. + -- You can also define any custom formatters here. ---@type table - formatter_opts = { + formatters = { -- -- Example of using dprint only when a dprint.json file is present -- dprint = { -- condition = function(ctx) @@ -38,8 +32,9 @@ return { }, config = function(_, opts) opts.formatters = opts.formatters or {} - for f, o in pairs(opts.formatter_opts or {}) do - opts.formatters[f] = vim.tbl_deep_extend("force", require("conform.formatters." .. f), o) + for f, o in pairs(opts.formatters) do + local ok, formatter = pcall(require, "conform.formatters." .. f) + opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o) end require("conform").setup(opts) end, From 31d913697bc9b731bc941362021ce06617f627d3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 15:58:44 +0200 Subject: [PATCH 041/362] fix(nvim-lint): use `linters` for both custom and overriding linters --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index fd380c12..f893395c 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -8,11 +8,10 @@ return { linters_by_ft = { fish = { "fish" }, }, - -- Custom linters, or fully replace a builtin - linters = {}, -- LazyVim extension to easily override linter options + -- or add custom linters. ---@type table - linter_opts = { + linters = { -- -- Example of using selene only when a selene.toml file is present -- selene = { -- -- `condition` is another LazyVim extension that allows you to @@ -33,12 +32,9 @@ return { end local lint = require("lint") for name, linter in pairs(opts.linters) do - lint.linters[name] = linter + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name] or {}, linter) end lint.linters_by_ft = vim.tbl_extend("force", lint.linters_by_ft, opts.linters_by_ft) - for l, o in pairs(opts.linter_opts or {}) do - lint.linters[l] = vim.tbl_deep_extend("force", lint.linters[l], o) - end M._did_setup = true end From 718c5c6036f2aff6534501e151dd3e5ff13a42fa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 16:09:33 +0200 Subject: [PATCH 042/362] fix(docker): put hadolint in its own spec --- lua/lazyvim/plugins/extras/lang/docker.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index d3e06ecb..86c7175b 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -7,6 +7,13 @@ return { end end, }, + { + "mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "hadolint" }) + end, + }, { "nvimtools/none-ls.nvim", optional = true, @@ -17,13 +24,6 @@ return { nls.builtins.diagnostics.hadolint, }) end, - dependencies = { - "mason.nvim", - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "hadolint" }) - end, - }, }, { "mfussenegger/nvim-lint", From 300350686f761a87fe531afb8724590555ccf3bf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:14:13 +0200 Subject: [PATCH 043/362] chore(main): release 7.0.0 (#1521) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 392ba8fc..af533e12 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [7.0.0](https://github.com/LazyVim/LazyVim/compare/v6.4.3...v7.0.0) (2023-09-29) + + +### ⚠ BREAKING CHANGES + +* **typescript:** removed `typescript.nvim` since it's deprecated +* **null-ls:** use none-ls instead of null-ls ([#1517](https://github.com/LazyVim/LazyVim/issues/1517)) + +### Features + +* **extras:** added `conform.nvim` extra you can use instead of null-ls/none-ls ([f61a243](https://github.com/LazyVim/LazyVim/commit/f61a243d1aca582963aca3f2c2c7c2ae0be16b06)) +* **extras:** added extra for nvim-lint ([05f45bb](https://github.com/LazyVim/LazyVim/commit/05f45bb7200a6fd33ab7366553b957fa222e2cdf)) +* **neo-tree:** added support for LSP renaming to NeoTree ([9762e7e](https://github.com/LazyVim/LazyVim/commit/9762e7e43110013a0931b8470be2929b54b4b641)) +* **null-ls:** use none-ls instead of null-ls ([#1517](https://github.com/LazyVim/LazyVim/issues/1517)) ([7cac6f0](https://github.com/LazyVim/LazyVim/commit/7cac6f064c5b30f6b0ae4dffab62100aa6fe2568)) + + +### Bug Fixes + +* **conform:** use `formatters` for both custom and overriding formatters ([6bb0d1b](https://github.com/LazyVim/LazyVim/commit/6bb0d1b66ffe6d0a77ad96d0f945113ddcb9fdb3)) +* **docker:** put hadolint in its own spec ([718c5c6](https://github.com/LazyVim/LazyVim/commit/718c5c6036f2aff6534501e151dd3e5ff13a42fa)) +* **format:** wrap custom formatter with error handler ([0e5ff5c](https://github.com/LazyVim/LazyVim/commit/0e5ff5c0ab6930190122df086db5e3f91d8b38b8)) +* **nvim-lint:** use `linters` for both custom and overriding linters ([31d9136](https://github.com/LazyVim/LazyVim/commit/31d913697bc9b731bc941362021ce06617f627d3)) +* remove deprecated leap/flit code checks ([6b05ed7](https://github.com/LazyVim/LazyVim/commit/6b05ed7dcd729322e2e5b6752655a9491cd17f86)) +* **typescript:** removed `typescript.nvim` since it's deprecated ([aab365a](https://github.com/LazyVim/LazyVim/commit/aab365a9f8b6405c6c5a938cb4745e9b770f2261)) + ## [6.4.3](https://github.com/LazyVim/LazyVim/compare/v6.4.2...v6.4.3) (2023-09-28) From ff5f5886db321679e3fdc5dbb82b12daf6075510 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 29 Sep 2023 16:49:55 +0200 Subject: [PATCH 044/362] fix(nvim-lint): dont use default configured linters from nvim-lint --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index f893395c..825b257b 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -24,19 +24,12 @@ return { }, config = function(_, opts) local M = {} - M._did_setup = false - function M.setup() - if M._did_setup then - return - end - local lint = require("lint") - for name, linter in pairs(opts.linters) do - lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name] or {}, linter) - end - lint.linters_by_ft = vim.tbl_extend("force", lint.linters_by_ft, opts.linters_by_ft) - M._did_setup = true + local lint = require("lint") + for name, linter in pairs(opts.linters) do + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name] or {}, linter) end + lint.linters_by_ft = opts.linters_by_ft function M.debounce(ms, fn) local timer = vim.loop.new_timer() @@ -50,7 +43,6 @@ return { end function M.lint() - M.setup() local lint = require("lint") local names = lint.linters_by_ft[vim.bo.filetype] or {} local ctx = { filename = vim.api.nvim_buf_get_name(0) } From 6f9adbd4fba4132bd4f12404bd2b90c4a28ff136 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:52:39 +0200 Subject: [PATCH 045/362] chore(main): release 7.0.1 (#1523) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af533e12..daa2df35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [7.0.1](https://github.com/LazyVim/LazyVim/compare/v7.0.0...v7.0.1) (2023-09-29) + + +### Bug Fixes + +* **nvim-lint:** dont use default configured linters from nvim-lint ([ff5f588](https://github.com/LazyVim/LazyVim/commit/ff5f5886db321679e3fdc5dbb82b12daf6075510)) + ## [7.0.0](https://github.com/LazyVim/LazyVim/compare/v6.4.3...v7.0.0) (2023-09-29) From 1c878b9d06fb116135419d098fe5dfde5304b709 Mon Sep 17 00:00:00 2001 From: loqusion Date: Sat, 30 Sep 2023 10:48:19 -0500 Subject: [PATCH 046/362] fix(format): allow `custom_format` to return early (#1531) --- lua/lazyvim/plugins/lsp/format.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 6eb78d0d..1ec548ae 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -36,7 +36,7 @@ function M.format(opts) end if M.custom_format and Util.try(function() - M.custom_format(buf) + return M.custom_format(buf) end, { msg = "Custom formatter failed" }) then return end From bd485363353611f961cc73e613f9fac2f0130689 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 30 Sep 2023 15:48:50 +0000 Subject: [PATCH 047/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index cc9daf2b..3f17b717 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 29 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 30 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 7821c0e85199205af98ceedfb2c4990c96900e46 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis Date: Sat, 30 Sep 2023 18:51:47 +0300 Subject: [PATCH 048/362] fix(python): make venv-selector `dap_enabled` conditional on `nvim-dap-python` (#1529) --- lua/lazyvim/plugins/extras/lang/python.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index 4530bd97..ff4267fb 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -61,15 +61,19 @@ return { { "linux-cultist/venv-selector.nvim", cmd = "VenvSelect", - opts = { - name = { - "venv", - ".venv", - "env", - ".env", - }, - dap_enabled = true, -- Ensure that the venv selector affect PythonPath in nvim-dap as well! - }, + opts = function(_, opts) + if require("lazyvim.util").has("nvim-dap-python") then + opts.dap_enabled = true + end + return vim.tbl_deep_extend("force", opts, { + name = { + "venv", + ".venv", + "env", + ".env", + }, + }) + end, keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, }, } From 5eca3dc3bba081fd1baced79af80da2c60307c8a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 30 Sep 2023 18:08:39 +0200 Subject: [PATCH 049/362] chore(main): release 7.0.2 (#1532) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index daa2df35..e3f6119b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [7.0.2](https://github.com/LazyVim/LazyVim/compare/v7.0.1...v7.0.2) (2023-09-30) + + +### Bug Fixes + +* **format:** allow `custom_format` to return early ([#1531](https://github.com/LazyVim/LazyVim/issues/1531)) ([1c878b9](https://github.com/LazyVim/LazyVim/commit/1c878b9d06fb116135419d098fe5dfde5304b709)) +* **python:** make venv-selector `dap_enabled` conditional on `nvim-dap-python` ([#1529](https://github.com/LazyVim/LazyVim/issues/1529)) ([7821c0e](https://github.com/LazyVim/LazyVim/commit/7821c0e85199205af98ceedfb2c4990c96900e46)) + ## [7.0.1](https://github.com/LazyVim/LazyVim/compare/v7.0.0...v7.0.1) (2023-09-29) From 0136bfa4b5e0df397efbe2d4e348a521f0986759 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 30 Sep 2023 17:50:41 +0200 Subject: [PATCH 050/362] style: format --- lua/lazyvim/plugins/lsp/format.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 1ec548ae..72f18746 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -35,9 +35,12 @@ function M.format(opts) return end - if M.custom_format and Util.try(function() - return M.custom_format(buf) - end, { msg = "Custom formatter failed" }) then + if + M.custom_format + and Util.try(function() + return M.custom_format(buf) + end, { msg = "Custom formatter failed" }) + then return end From 964dd6c4b2135399758c87afed7e1f3c8e30b487 Mon Sep 17 00:00:00 2001 From: Ahmed W Date: Sat, 30 Sep 2023 12:30:52 -0500 Subject: [PATCH 051/362] fix(extras.go): remove unneeded formatters since gopls handles them (#1535) * fix(extras.go): remove unneeded formatters since gopls handles them * add optional back --- lua/lazyvim/plugins/extras/lang/go.lua | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index 0b0cab70..d46a215c 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -91,21 +91,10 @@ return { vim.list_extend(opts.sources, { nls.builtins.code_actions.gomodifytags, nls.builtins.code_actions.impl, - nls.builtins.formatting.gofumpt, - nls.builtins.formatting.goimports_reviser, }) end end, }, - { - "stevearc/conform.nvim", - optional = true, - opts = { - formatters_by_ft = { - go = { "goimports", "gofumpt" }, - }, - }, - }, { "mfussenegger/nvim-dap", optional = true, @@ -114,7 +103,7 @@ return { "mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "gofumpt", "goimports-reviser", "delve" }) + vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "delve" }) end, }, { From 4a2c89cd1dee9b0c842ea4f9d7509b915db6ba11 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 00:29:14 +0200 Subject: [PATCH 052/362] chore(main): release 7.0.3 (#1536) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3f6119b..3cfa3363 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [7.0.3](https://github.com/LazyVim/LazyVim/compare/v7.0.2...v7.0.3) (2023-09-30) + + +### Bug Fixes + +* **extras.go:** remove unneeded formatters since gopls handles them ([#1535](https://github.com/LazyVim/LazyVim/issues/1535)) ([964dd6c](https://github.com/LazyVim/LazyVim/commit/964dd6c4b2135399758c87afed7e1f3c8e30b487)) + ## [7.0.2](https://github.com/LazyVim/LazyVim/compare/v7.0.1...v7.0.2) (2023-09-30) From 9bb4e8755f5a822659ca1d8cb3689732435d90d0 Mon Sep 17 00:00:00 2001 From: Mark Tareshawty Date: Sun, 1 Oct 2023 04:21:35 -0400 Subject: [PATCH 053/362] feat: replace Copilot icon with logo (#1539) --- lua/lazyvim/config/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 5e1d5bf2..ad32353b 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -44,7 +44,7 @@ local defaults = { Color = " ", Constant = " ", Constructor = " ", - Copilot = " ", + Copilot = " ", Enum = " ", EnumMember = " ", Event = " ", From f7655a83c504d54ae5169d2fc706498e1c2d6535 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 1 Oct 2023 08:22:12 +0000 Subject: [PATCH 054/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 3f17b717..13a24ae6 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 30 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 01 ============================================================================== Table of Contents *LazyVim-table-of-contents* From bfe04222fe5585179f03197b01a6f6ed711d4421 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 14:01:12 +0200 Subject: [PATCH 055/362] docs!: LazyVim now requires Neovim >= 0.9.0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f1291cdb..ba763770 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ to tweak your config as needed, along with the convenience of a pre-configured s ## ⚡️ Requirements -- Neovim >= **0.8.0** (needs to be built with **LuaJIT**) +- Neovim >= **0.9.0** (needs to be built with **LuaJIT**) - Git >= **2.19.0** (for partial clones support) - a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** - a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements) From b8ffa5261abec398268a38b52111ec477200970a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 1 Oct 2023 12:01:59 +0000 Subject: [PATCH 056/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 13a24ae6..23cb4024 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -52,7 +52,7 @@ FEATURES *LazyVim-features* REQUIREMENTS *LazyVim-requirements* -- Neovim >= **0.8.0** (needs to be built with **LuaJIT**) +- Neovim >= **0.9.0** (needs to be built with **LuaJIT**) - Git >= **2.19.0** (for partial clones support) - a Nerd Font **(optional)** - a **C** compiler for `nvim-treesitter`. See here From 9935dc3944c4724d7ee7f70b6bc450f8c3b34a08 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 14:17:54 +0200 Subject: [PATCH 057/362] fix: cleanup all Neovim < 0.9.0 code --- lua/lazyvim/config/keymaps.lua | 4 +--- lua/lazyvim/config/options.lua | 8 ++------ lua/lazyvim/health.lua | 6 +++--- lua/lazyvim/plugins/editor.lua | 1 - 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 54107199..1186281e 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -125,9 +125,7 @@ map("n", "gG", function() Util.float_term({ "lazygit" }, {esc_esc = fals map("n", "qq", "qa", { desc = "Quit all" }) -- highlights under cursor -if vim.fn.has("nvim-0.9.0") == 1 then - map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) -end +map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) -- LazyVim Changelog map("n", "L", Util.changelog, {desc = "LazyVim Changelog"}) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index f3d94484..874aed05 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -27,7 +27,7 @@ opt.scrolloff = 4 -- Lines of context opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } opt.shiftround = true -- Round indent opt.shiftwidth = 2 -- Size of an indent -opt.shortmess:append({ W = true, I = true, c = true }) +opt.shortmess:append({ W = true, I = true, c = true, C = true }) opt.showmode = false -- Dont show mode since we have a statusline opt.sidescrolloff = 8 -- Columns of context opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time @@ -35,6 +35,7 @@ opt.smartcase = true -- Don't ignore case with capitals opt.smartindent = true -- Insert indents automatically opt.spelllang = { "en" } opt.splitbelow = true -- Put new windows below current +opt.splitkeep = "screen" opt.splitright = true -- Put new windows right of current opt.tabstop = 2 -- Number of spaces tabs count for opt.termguicolors = true -- True color support @@ -46,10 +47,5 @@ opt.wildmode = "longest:full,full" -- Command-line completion mode opt.winminwidth = 5 -- Minimum window width opt.wrap = false -- Disable line wrap -if vim.fn.has("nvim-0.9.0") == 1 then - opt.splitkeep = "screen" - opt.shortmess:append({ C = true }) -end - -- Fix markdown indentation settings vim.g.markdown_recommended_style = 0 diff --git a/lua/lazyvim/health.lua b/lua/lazyvim/health.lua index 810022e5..a23c90f5 100644 --- a/lua/lazyvim/health.lua +++ b/lua/lazyvim/health.lua @@ -8,10 +8,10 @@ local error = vim.health.error or vim.health.report_error function M.check() start("LazyVim") - if vim.fn.has("nvim-0.8.0") == 1 then - ok("Using Neovim >= 0.8.0") + if vim.fn.has("nvim-0.9.0") == 1 then + ok("Using Neovim >= 0.9.0") else - error("Neovim >= 0.8.0 is required") + error("Neovim >= 0.9.0 is required") end for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 8465ca89..a23393de 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -109,7 +109,6 @@ return { -- directory is a git repo. { "nvim-telescope/telescope.nvim", - commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil, cmd = "Telescope", version = false, -- telescope did only one release, so use HEAD for now keys = { From 2aea5c7210882a2f98526ee29115fe2e1a41d7b4 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 14:18:22 +0200 Subject: [PATCH 058/362] feat: show error and exit Neovim when version is too old --- lua/lazyvim/config/init.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index ad32353b..4a36450d 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -89,6 +89,21 @@ local options ---@param opts? LazyVimConfig function M.setup(opts) options = vim.tbl_deep_extend("force", defaults, opts or {}) + + if vim.fn.has("nvim-0.9.0") == 0 then + vim.api.nvim_echo({ + { + "LazyVim requires Neovim >= 0.9.0\n", + "ErrorMsg", + }, + { "Press any key to exit", "MoreMsg" }, + }, true, {}) + + vim.fn.getchar() + vim.cmd([[quit]]) + return + end + if not M.has() then require("lazy.core.util").error( "**LazyVim** needs **lazy.nvim** version " From 9d17c4308713e8db7ec03871ba62ff80a3bfb79c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 16:21:18 +0200 Subject: [PATCH 059/362] perf: dont't load schemastore as an lspconfig dep --- lua/lazyvim/plugins/extras/lang/json.lua | 11 +++++++---- lua/lazyvim/plugins/extras/lang/yaml.lua | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/json.lua b/lua/lazyvim/plugins/extras/lang/json.lua index d4dab0db..ff41ba4f 100644 --- a/lua/lazyvim/plugins/extras/lang/json.lua +++ b/lua/lazyvim/plugins/extras/lang/json.lua @@ -10,13 +10,16 @@ return { end, }, + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + -- correctly setup lspconfig { "neovim/nvim-lspconfig", - dependencies = { - "b0o/SchemaStore.nvim", - version = false, -- last release is way too old - }, opts = { -- make sure mason installs the server servers = { diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 0a174aa2..51f3d824 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -10,13 +10,16 @@ return { end, }, + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + -- correctly setup lspconfig { "neovim/nvim-lspconfig", - dependencies = { - "b0o/SchemaStore.nvim", - version = false, -- last release is way too old - }, opts = { -- make sure mason installs the server servers = { From dd95de5dbe31ecb106305920cbd0e24e26c17afe Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 16:28:37 +0200 Subject: [PATCH 060/362] chore(main): release 8.0.0 (#1542) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cfa3363..6983dcd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,32 @@ # Changelog +## [8.0.0](https://github.com/LazyVim/LazyVim/compare/v7.0.3...v8.0.0) (2023-10-01) + + +### ⚠ BREAKING CHANGES + +* LazyVim now requires Neovim >= 0.9.0 + +### Features + +* replace Copilot icon with logo ([#1539](https://github.com/LazyVim/LazyVim/issues/1539)) ([9bb4e87](https://github.com/LazyVim/LazyVim/commit/9bb4e8755f5a822659ca1d8cb3689732435d90d0)) +* show error and exit Neovim when version is too old ([2aea5c7](https://github.com/LazyVim/LazyVim/commit/2aea5c7210882a2f98526ee29115fe2e1a41d7b4)) + + +### Bug Fixes + +* cleanup all Neovim < 0.9.0 code ([9935dc3](https://github.com/LazyVim/LazyVim/commit/9935dc3944c4724d7ee7f70b6bc450f8c3b34a08)) + + +### Performance Improvements + +* dont't load schemastore as an lspconfig dep ([9d17c43](https://github.com/LazyVim/LazyVim/commit/9d17c4308713e8db7ec03871ba62ff80a3bfb79c)) + + +### Documentation + +* LazyVim now requires Neovim >= 0.9.0 ([bfe0422](https://github.com/LazyVim/LazyVim/commit/bfe04222fe5585179f03197b01a6f6ed711d4421)) + ## [7.0.3](https://github.com/LazyVim/LazyVim/compare/v7.0.2...v7.0.3) (2023-09-30) From 2ffd629cc7a68e6e4a721ac8babe6b7cf612868e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?George=20Guimar=C3=A3es?= Date: Sun, 1 Oct 2023 14:48:09 -0300 Subject: [PATCH 061/362] feat(elixir): Add credo if none-ls is used (#1546) --- lua/lazyvim/plugins/extras/lang/elixir.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua index 757afb07..dbd0e9a7 100644 --- a/lua/lazyvim/plugins/extras/lang/elixir.lua +++ b/lua/lazyvim/plugins/extras/lang/elixir.lua @@ -29,4 +29,24 @@ return { }, }, }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = opts.sources or {} + vim.list_extend(opts.sources, { + nls.builtins.diagnostics.credo, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + elixir = { "credo" }, + }, + }, + }, } From 3acdac917b79e22b1c3420aabde8b583d0799f6a Mon Sep 17 00:00:00 2001 From: ueaner Date: Mon, 2 Oct 2023 03:01:40 +0800 Subject: [PATCH 062/362] docs: LazyVim now requires Neovim >= 0.9.0 (#1548) See: https://github.com/LazyVim/LazyVim/commit/bfe04222fe5585179f03197b01a6f6ed711d4421 --- README-CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-CN.md b/README-CN.md index a879148d..395e146e 100644 --- a/README-CN.md +++ b/README-CN.md @@ -54,7 +54,7 @@ LazyVim 提供了两全其美的方式 - 根据需要调整配置的灵活性, ## ⚡️ 要求 -- Neovim >= **0.8.0** (需要用 **LuaJIT** 构建) +- Neovim >= **0.9.0** (需要用 **LuaJIT** 构建) - Git >= **2.19.0** (用于部分克隆支持) - 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_** - 一个用于 `nvim-treesitter` 的 **C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements) From e8ab2ff5b6a75952943d3ba44586c7de5588be33 Mon Sep 17 00:00:00 2001 From: Ahmed W Date: Sun, 1 Oct 2023 16:01:43 -0500 Subject: [PATCH 063/362] feat(go): add goimports (#1549) --- lua/lazyvim/plugins/extras/lang/go.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index d46a215c..b9966b7e 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -91,10 +91,20 @@ return { vim.list_extend(opts.sources, { nls.builtins.code_actions.gomodifytags, nls.builtins.code_actions.impl, + nls.builtins.formatting.goimports, }) end end, }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + go = { "goimports" }, + }, + }, + }, { "mfussenegger/nvim-dap", optional = true, @@ -103,7 +113,7 @@ return { "mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "delve" }) + vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "goimports", "delve" }) end, }, { From 0b04e3908c86a26192b48715a7b1005b4498911a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 23:30:26 +0200 Subject: [PATCH 064/362] chore(format): removed format_notify option --- lua/lazyvim/plugins/lsp/format.lua | 43 ------------------------------ lua/lazyvim/plugins/lsp/init.lua | 3 --- 2 files changed, 46 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 72f18746..dbabbe53 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -53,10 +53,6 @@ function M.format(opts) return end - if M.opts.format_notify then - M.notify(formatters) - end - vim.lsp.buf.format(vim.tbl_deep_extend("force", { bufnr = buf, filter = function(client) @@ -65,45 +61,6 @@ function M.format(opts) }, require("lazyvim.util").opts("nvim-lspconfig").format or {})) end ----@param formatters LazyVimFormatters -function M.notify(formatters) - local lines = { "# Active:" } - - for _, client in ipairs(formatters.active) do - local line = "- **" .. client.name .. "**" - if client.name == "null-ls" then - line = line - .. " (" - .. table.concat( - vim.tbl_map(function(f) - return "`" .. f.name .. "`" - end, formatters.null_ls), - ", " - ) - .. ")" - end - table.insert(lines, line) - end - - if #formatters.available > 0 then - table.insert(lines, "") - table.insert(lines, "# Disabled:") - for _, client in ipairs(formatters.available) do - table.insert(lines, "- **" .. client.name .. "**") - end - end - - vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, { - title = "Formatting", - on_open = function(win) - vim.api.nvim_win_set_option(win, "conceallevel", 3) - vim.api.nvim_win_set_option(win, "spell", false) - local buf = vim.api.nvim_win_get_buf(win) - vim.treesitter.start(buf, "markdown") - end, - }) -end - -- Gets all lsp clients that support formatting. -- When a null-ls formatter is available for the current filetype, -- only null-ls formatters are returned. diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index d69ec824..178102e3 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -41,9 +41,6 @@ return { capabilities = {}, -- Automatically format on save autoformat = true, - -- Enable this to show formatters used in a notification - -- Useful for debugging formatter issues - format_notify = false, -- options for vim.lsp.buf.format -- `bufnr` and `filter` is handled by the LazyVim formatter, -- but can be also overridden when specified From e36f7d811c396b60bcbf65f962b3f52d2f75b0b3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 23:30:56 +0200 Subject: [PATCH 065/362] feat(format): show warning when no formatter ran when using the format keymap --- lua/lazyvim/plugins/lsp/format.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index dbabbe53..7d1c9109 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -50,6 +50,9 @@ function M.format(opts) end, formatters.active) if #client_ids == 0 then + if opts and opts.force then + Util.warn("No formatter available", { title = "LazyVim" }) + end return end From 9b1677057377400ab292c51bbc085c82637a39d4 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 23:31:24 +0200 Subject: [PATCH 066/362] fix(format): moved formatting keymap to lua/lazyvim/config/keymaps.lua --- lua/lazyvim/config/keymaps.lua | 5 +++++ lua/lazyvim/plugins/lsp/keymaps.lua | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 1186281e..b5181936 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -103,6 +103,11 @@ if not Util.has("trouble.nvim") then map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) end +-- formatting +map({ "n", "v" }, "cf", function() + require("lazyvim.plugins.lsp.format").format({ force = true }) +end, { desc = "Format" }) + -- stylua: ignore start -- toggle options diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index b88d3056..695e6ce8 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -5,9 +5,6 @@ M._keys = nil ---@return (LazyKeys|{has?:string})[] function M.get() - local format = function() - require("lazyvim.plugins.lsp.format").format({ force = true }) - end if not M._keys then ---@class PluginLspKeys -- stylua: ignore @@ -28,8 +25,6 @@ function M.get() { "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" }, { "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" }, { "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" }, - { "cf", format, desc = "Format Document", has = "formatting" }, - { "cf", format, desc = "Format Range", mode = "v", has = "rangeFormatting" }, { "ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, { "cA", From 766d5e5bf7a8e40910a00aef4dc30f36376e5652 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 1 Oct 2023 23:36:26 +0200 Subject: [PATCH 067/362] feat(conform): set vim.opt.formatexpr --- lua/lazyvim/plugins/extras/formatting/conform.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index d89385d7..bc8da08b 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -5,6 +5,7 @@ return { lazy = true, cmd = "ConformInfo", init = function() + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" -- Install the conform formatter on VeryLazy require("lazyvim.util").on_very_lazy(function() require("lazyvim.plugins.lsp.format").custom_format = function(buf) From 0ca732e0ef2eb2fa610fe399be53943d10b076c5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 07:40:30 +0200 Subject: [PATCH 068/362] chore(main): release 8.1.0 (#1547) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6983dcd1..c7862af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [8.1.0](https://github.com/LazyVim/LazyVim/compare/v8.0.0...v8.1.0) (2023-10-01) + + +### Features + +* **conform:** set vim.opt.formatexpr ([766d5e5](https://github.com/LazyVim/LazyVim/commit/766d5e5bf7a8e40910a00aef4dc30f36376e5652)) +* **elixir:** Add credo if none-ls is used ([#1546](https://github.com/LazyVim/LazyVim/issues/1546)) ([2ffd629](https://github.com/LazyVim/LazyVim/commit/2ffd629cc7a68e6e4a721ac8babe6b7cf612868e)) +* **format:** show warning when no formatter ran when using the format keymap ([e36f7d8](https://github.com/LazyVim/LazyVim/commit/e36f7d811c396b60bcbf65f962b3f52d2f75b0b3)) +* **go:** add goimports ([#1549](https://github.com/LazyVim/LazyVim/issues/1549)) ([e8ab2ff](https://github.com/LazyVim/LazyVim/commit/e8ab2ff5b6a75952943d3ba44586c7de5588be33)) + + +### Bug Fixes + +* **format:** moved formatting keymap to lua/lazyvim/config/keymaps.lua ([9b16770](https://github.com/LazyVim/LazyVim/commit/9b1677057377400ab292c51bbc085c82637a39d4)) + ## [8.0.0](https://github.com/LazyVim/LazyVim/compare/v7.0.3...v8.0.0) (2023-10-01) From fe341e6b97d6916df50809dfd6a8cf1ea6a735b3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 2 Oct 2023 05:41:09 +0000 Subject: [PATCH 069/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 23cb4024..8ba69436 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 01 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 02 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 4ff51cd678343ea32668eaf0c1103caacb4334a2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 2 Oct 2023 11:02:53 +0200 Subject: [PATCH 070/362] feat(mini.files): added lsp rename support to mini.files --- lua/lazyvim/plugins/editor.lua | 15 ++----------- .../plugins/extras/editor/mini-files.lua | 7 +++++++ lua/lazyvim/util/init.lua | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index a23393de..20b466fd 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -59,23 +59,12 @@ return { }, }, config = function(_, opts) - opts.event_handlers = opts.event_handlers or {} - local function on_move(data) - local clients = vim.lsp.get_active_clients() - for _, client in ipairs(clients) do - if client:supports_method("workspace/willRenameFiles") then - local resp = client.request_sync("workspace/willRenameFiles", { - files = { { oldUri = vim.uri_from_fname(data.source), newUri = vim.uri_from_fname(data.destination) } }, - }, 1000) - if resp and resp.result ~= nil then - vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) - end - end - end + Util.on_rename(data.source, data.destination) end local events = require("neo-tree.events") + opts.event_handlers = opts.event_handlers or {} vim.list_extend(opts.event_handlers, { { event = events.FILE_MOVED, handler = on_move }, { event = events.FILE_RENAMED, handler = on_move }, diff --git a/lua/lazyvim/plugins/extras/editor/mini-files.lua b/lua/lazyvim/plugins/extras/editor/mini-files.lua index a9b318d8..c3ddd273 100644 --- a/lua/lazyvim/plugins/extras/editor/mini-files.lua +++ b/lua/lazyvim/plugins/extras/editor/mini-files.lua @@ -53,5 +53,12 @@ return { vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id }) end, }) + + vim.api.nvim_create_autocmd("User", { + pattern = "MiniFilesActionRename", + callback = function(event) + require("lazyvim.util").on_rename(event.data.from, event.data.to) + end, + }) end, } diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index dba6aaad..2a2f69f3 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -299,4 +299,25 @@ function M.changelog() vim.diagnostic.disable(float.buf) end +---@param from string +---@param to string +function M.on_rename(from, to) + local clients = vim.lsp.get_active_clients() + for _, client in ipairs(clients) do + if client:supports_method("workspace/willRenameFiles") then + local resp = client.request_sync("workspace/willRenameFiles", { + files = { + { + oldUri = vim.uri_from_fname(from), + newUri = vim.uri_from_fname(to), + }, + }, + }, 1000) + if resp and resp.result ~= nil then + vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) + end + end + end +end + return M From ecac59c9823c86ac4c916a4cc1aa761f43e040ec Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:27:12 +0200 Subject: [PATCH 071/362] chore(main): release 8.2.0 (#1551) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7862af3..9b87553c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [8.2.0](https://github.com/LazyVim/LazyVim/compare/v8.1.0...v8.2.0) (2023-10-02) + + +### Features + +* **mini.files:** added lsp rename support to mini.files ([4ff51cd](https://github.com/LazyVim/LazyVim/commit/4ff51cd678343ea32668eaf0c1103caacb4334a2)) + ## [8.1.0](https://github.com/LazyVim/LazyVim/compare/v8.0.0...v8.1.0) (2023-10-01) From 7c5a458761fe7002c6603d602e8d130b9a62dd68 Mon Sep 17 00:00:00 2001 From: loqusion Date: Mon, 2 Oct 2023 05:23:08 -0500 Subject: [PATCH 072/362] fix(indent-blankline): set `config.indent.tab_char` (#1552) See lukas-reineke/indent-blankline.nvim#665. --- lua/lazyvim/plugins/ui.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index c66c5a4f..d8d6e181 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -168,7 +168,10 @@ return { "lukas-reineke/indent-blankline.nvim", event = { "BufReadPost", "BufNewFile" }, opts = { - indent = { char = "│" }, + indent = { + char = "│", + tab_char = "│", + }, scope = { enabled = false }, exclude = { filetypes = { From 86d36946727bade57918c6a358c6b6bae52d441b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 2 Oct 2023 20:59:00 +0200 Subject: [PATCH 073/362] feat(conform): added new keymap (leader-cF) to format injected languages --- lua/lazyvim/plugins/extras/formatting/conform.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index bc8da08b..ee914f8e 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -4,6 +4,16 @@ return { dependencies = { "mason.nvim" }, lazy = true, cmd = "ConformInfo", + keys = { + { + "cF", + function() + require("conform").format({ formatters = { "injected" } }) + end, + mode = { "n", "v" }, + desc = "Format Injected Langs", + }, + }, init = function() vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" -- Install the conform formatter on VeryLazy From 4e277fcb8f6c73fe557f140ff407b3be691f31f6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 2 Oct 2023 23:00:47 +0200 Subject: [PATCH 074/362] chore(main): release 8.3.0 (#1553) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b87553c..adb6d442 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [8.3.0](https://github.com/LazyVim/LazyVim/compare/v8.2.0...v8.3.0) (2023-10-02) + + +### Features + +* **conform:** added new keymap (leader-cF) to format injected languages ([86d3694](https://github.com/LazyVim/LazyVim/commit/86d36946727bade57918c6a358c6b6bae52d441b)) + + +### Bug Fixes + +* **indent-blankline:** set `config.indent.tab_char` ([#1552](https://github.com/LazyVim/LazyVim/issues/1552)) ([7c5a458](https://github.com/LazyVim/LazyVim/commit/7c5a458761fe7002c6603d602e8d130b9a62dd68)) + ## [8.2.0](https://github.com/LazyVim/LazyVim/compare/v8.1.0...v8.2.0) (2023-10-02) From 450e0c6bebc5bb9a0c513cdffaf9c46d5f62d5fa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 08:01:48 +0200 Subject: [PATCH 075/362] feat(options): enable smoothscroll on nightly --- lua/lazyvim/config/options.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 874aed05..cee2bc26 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -47,5 +47,9 @@ opt.wildmode = "longest:full,full" -- Command-line completion mode opt.winminwidth = 5 -- Minimum window width opt.wrap = false -- Disable line wrap +if vim.fn.has("nvim-0.10") == 1 then + opt.smoothscroll = true +end + -- Fix markdown indentation settings vim.g.markdown_recommended_style = 0 From 19926d284862b5e58f29e73b71ec532ac29c54ba Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 08:02:10 +0200 Subject: [PATCH 076/362] feat(options): enabled treesitter folding and foldtext when available --- lua/lazyvim/config/options.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index cee2bc26..2262dbff 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -51,5 +51,17 @@ if vim.fn.has("nvim-0.10") == 1 then opt.smoothscroll = true end +-- Folding +vim.opt.foldlevel = 99 +if vim.treesitter.foldexpr then + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" +else + vim.opt.foldmethod = "indent" +end +if vim.treesitter.foldtext then + vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()" +end + -- Fix markdown indentation settings vim.g.markdown_recommended_style = 0 From fecc5faca25c209ed62e3658dd63731e26c0c643 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 3 Oct 2023 06:02:56 +0000 Subject: [PATCH 077/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 8ba69436..dd020d8e 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 02 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 03 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 3f868aa8254efbd494f6bf100c86a59c5a002c1c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 13:50:30 +0200 Subject: [PATCH 078/362] feat(keymaps): added toggle for relative line numbers --- lua/lazyvim/config/keymaps.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index b5181936..ff4b4af9 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -114,6 +114,7 @@ end, { desc = "Format" }) map("n", "uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "Toggle format on Save" }) map("n", "us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) +map("n", "uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) map("n", "ul", function() Util.toggle_number() end, { desc = "Toggle Line Numbers" }) map("n", "ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 From 364bcf325d91a06e6bd6516bdfed84399566cdb6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 14:56:09 +0200 Subject: [PATCH 079/362] feat(ui): fancy status column --- lua/lazyvim/config/options.lua | 2 ++ lua/lazyvim/util/ui.lua | 57 ++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 lua/lazyvim/util/ui.lua diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 2262dbff..16afa00a 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -61,6 +61,8 @@ else end if vim.treesitter.foldtext then vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()" +if vim.fn.has("nvim-0.9.0") == 1 then + vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] end -- Fix markdown indentation settings diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua new file mode 100644 index 00000000..549e3201 --- /dev/null +++ b/lua/lazyvim/util/ui.lua @@ -0,0 +1,57 @@ +local M = {} + +---@alias Sign {name:string, text:string, texthl:string} + +---@return Sign[] +function M.get_signs(win) + local buf = vim.api.nvim_win_get_buf(win) + ---@diagnostic disable-next-line: no-unknown + return vim.tbl_map(function(sign) + return vim.fn.sign_getdefined(sign.name)[1] + end, vim.fn.sign_getplaced(buf, { group = "*", lnum = vim.v.lnum })[1].signs) +end + +---@param sign? Sign +---@param len? number +function M.icon(sign, len) + sign = sign or {} + len = len or 1 + local text = vim.fn.strcharpart(sign.text or "", 0, len, false) ---@type string + text = text .. string.rep(" ", len - vim.fn.strchars(text)) + return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text +end + +function M.statuscolumn() + local win = vim.g.statusline_winid + if vim.wo[win].signcolumn == "no" then + return "" + end + + ---@type Sign?,Sign?,Sign? + local left, right, fold + for _, s in ipairs(M.get_signs(win)) do + if s.name:find("GitSign") then + right = s + elseif not left then + left = s + end + end + + if vim.fn.foldclosed(vim.v.lnum) >= 0 then + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } + end + + local nu = "" + if vim.wo[win].number and vim.v.virtnum == 0 then + nu = vim.wo[win].relativenumber and vim.v.relnum ~= 0 and vim.v.relnum or vim.v.lnum + end + + return table.concat({ + M.icon(left), + [[%=]], + nu .. " ", + M.icon(fold or right, 2), + }, "") +end + +return M From f1ce07510d2048e33fec2b609814d68a7175d591 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 14:56:28 +0200 Subject: [PATCH 080/362] feat(ui): fancy fold text --- lua/lazyvim/config/init.lua | 3 +++ lua/lazyvim/config/options.lua | 13 ++++++++++++- lua/lazyvim/util/ui.lua | 9 +++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 4a36450d..91a66f89 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -19,6 +19,9 @@ local defaults = { }, -- icons used by other plugins icons = { + misc = { + dots = "󰇘", + }, dap = { Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, Breakpoint = " ", diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 16afa00a..64774b0c 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -46,6 +46,15 @@ opt.updatetime = 200 -- Save swap file and trigger CursorHold opt.wildmode = "longest:full,full" -- Command-line completion mode opt.winminwidth = 5 -- Minimum window width opt.wrap = false -- Disable line wrap +opt.fillchars = { + foldopen = "", + foldclose = "", + -- fold = "⸱", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", +} if vim.fn.has("nvim-0.10") == 1 then opt.smoothscroll = true @@ -60,7 +69,9 @@ else vim.opt.foldmethod = "indent" end if vim.treesitter.foldtext then - vim.opt.foldtext = "v:lua.vim.treesitter.foldtext()" + vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()" +end + if vim.fn.has("nvim-0.9.0") == 1 then vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] end diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 549e3201..a26bf5e6 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -21,6 +21,15 @@ function M.icon(sign, len) return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text end +function M.foldtext() + local ret = vim.treesitter.foldtext and vim.treesitter.foldtext() + if not ret then + ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } } + end + table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots }) + return ret +end + function M.statuscolumn() local win = vim.g.statusline_winid if vim.wo[win].signcolumn == "no" then From afbe2043a73b6c90476812f9cc0ca4759814e5ac Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 14:59:26 +0200 Subject: [PATCH 081/362] fix(ui): Neovim < 0.10 --- lua/lazyvim/util/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index a26bf5e6..1e992ecc 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -16,7 +16,7 @@ end function M.icon(sign, len) sign = sign or {} len = len or 1 - local text = vim.fn.strcharpart(sign.text or "", 0, len, false) ---@type string + local text = vim.fn.strcharpart(sign.text or "", 0, len) ---@type string text = text .. string.rep(" ", len - vim.fn.strchars(text)) return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text end From 762017dc35fc961bdcc7879a5527dbccced27792 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 15:05:01 +0200 Subject: [PATCH 082/362] fix(ui): better fallback for foldtext when buffer does not have TreeSitter --- lua/lazyvim/util/ui.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 1e992ecc..fbe46d29 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -22,7 +22,8 @@ function M.icon(sign, len) end function M.foldtext() - local ret = vim.treesitter.foldtext and vim.treesitter.foldtext() + local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf()) + local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext() if not ret then ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } } end From 6428fc167c329cb43abc55dc63b32698d31c6faa Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:10:22 +0200 Subject: [PATCH 083/362] chore(main): release 8.4.0 (#1564) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index adb6d442..8ec3f654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [8.4.0](https://github.com/LazyVim/LazyVim/compare/v8.3.0...v8.4.0) (2023-10-03) + + +### Features + +* **keymaps:** added toggle for relative line numbers ([3f868aa](https://github.com/LazyVim/LazyVim/commit/3f868aa8254efbd494f6bf100c86a59c5a002c1c)) +* **options:** enable smoothscroll on nightly ([450e0c6](https://github.com/LazyVim/LazyVim/commit/450e0c6bebc5bb9a0c513cdffaf9c46d5f62d5fa)) +* **options:** enabled treesitter folding and foldtext when available ([19926d2](https://github.com/LazyVim/LazyVim/commit/19926d284862b5e58f29e73b71ec532ac29c54ba)) +* **ui:** fancy fold text ([f1ce075](https://github.com/LazyVim/LazyVim/commit/f1ce07510d2048e33fec2b609814d68a7175d591)) +* **ui:** fancy status column ([364bcf3](https://github.com/LazyVim/LazyVim/commit/364bcf325d91a06e6bd6516bdfed84399566cdb6)) + + +### Bug Fixes + +* **ui:** better fallback for foldtext when buffer does not have TreeSitter ([762017d](https://github.com/LazyVim/LazyVim/commit/762017dc35fc961bdcc7879a5527dbccced27792)) +* **ui:** Neovim < 0.10 ([afbe204](https://github.com/LazyVim/LazyVim/commit/afbe2043a73b6c90476812f9cc0ca4759814e5ac)) + ## [8.3.0](https://github.com/LazyVim/LazyVim/compare/v8.2.0...v8.3.0) (2023-10-02) From 13e9f6e6b5b085191b0ecf194ddf4c9e2d3ae6d7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 15:53:11 +0200 Subject: [PATCH 084/362] fix(ui): check folds of the statuscolumn win instead of current win --- lua/lazyvim/util/ui.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index fbe46d29..cc60ca7c 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -47,9 +47,11 @@ function M.statuscolumn() end end - if vim.fn.foldclosed(vim.v.lnum) >= 0 then - fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } - end + vim.api.nvim_win_call(win, function() + if vim.fn.foldclosed(vim.v.lnum) >= 0 then + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } + end + end) local nu = "" if vim.wo[win].number and vim.v.virtnum == 0 then From 63467c1f21c60382cc8838f6cab32591fd874aac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:55:11 +0200 Subject: [PATCH 085/362] chore(main): release 8.4.1 (#1568) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ec3f654..323401c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [8.4.1](https://github.com/LazyVim/LazyVim/compare/v8.4.0...v8.4.1) (2023-10-03) + + +### Bug Fixes + +* **ui:** check folds of the statuscolumn win instead of current win ([13e9f6e](https://github.com/LazyVim/LazyVim/commit/13e9f6e6b5b085191b0ecf194ddf4c9e2d3ae6d7)) + ## [8.4.0](https://github.com/LazyVim/LazyVim/compare/v8.3.0...v8.4.0) (2023-10-03) From b1ad48067e2c18747bedd7b7054c3ce97ef32890 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 16:32:05 +0200 Subject: [PATCH 086/362] fix(nvim-lint): dont evaluate conditions for linter functions. Fixes #1569 --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index 825b257b..879b2177 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -49,7 +49,7 @@ return { ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") names = vim.tbl_filter(function(name) local linter = lint.linters[name] - return linter and not (linter.condition and not linter.condition(ctx)) + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) end, names) if #names > 0 then From 1b74d67a0d5783e587dedc73a715cb0c9db6cd16 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 17:35:14 +0200 Subject: [PATCH 087/362] fix(ui): fixed foldtext on Neovim < 0.10 --- lua/lazyvim/util/ui.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index cc60ca7c..b11e6a04 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -28,6 +28,15 @@ function M.foldtext() ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } } end table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots }) + + if not vim.treesitter.foldtext then + return table.concat( + vim.tbl_map(function(line) + return line[1] + end, ret), + " " + ) + end return ret end From e105c9daf6e973b4a294a17b4d2d1882f2188ac6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 18:19:32 +0200 Subject: [PATCH 088/362] perf(options): better detection for foldtext,statuscolumn,folexpr support --- lua/lazyvim/config/options.lua | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 64774b0c..c2f3177d 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -62,18 +62,14 @@ end -- Folding vim.opt.foldlevel = 99 -if vim.treesitter.foldexpr then - vim.opt.foldmethod = "expr" - vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" -else - vim.opt.foldmethod = "indent" -end -if vim.treesitter.foldtext then - vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()" -end +vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()" if vim.fn.has("nvim-0.9.0") == 1 then + vim.opt.foldmethod = "expr" + vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] +else + vim.opt.foldmethod = "indent" end -- Fix markdown indentation settings From e08813fa11ad12fedada92f9fbdbc2e53176fb52 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 18:22:19 +0200 Subject: [PATCH 089/362] chore(main): release 8.4.2 (#1570) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 323401c7..eba18cda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [8.4.2](https://github.com/LazyVim/LazyVim/compare/v8.4.1...v8.4.2) (2023-10-03) + + +### Bug Fixes + +* **nvim-lint:** dont evaluate conditions for linter functions. Fixes [#1569](https://github.com/LazyVim/LazyVim/issues/1569) ([b1ad480](https://github.com/LazyVim/LazyVim/commit/b1ad48067e2c18747bedd7b7054c3ce97ef32890)) +* **ui:** fixed foldtext on Neovim < 0.10 ([1b74d67](https://github.com/LazyVim/LazyVim/commit/1b74d67a0d5783e587dedc73a715cb0c9db6cd16)) + + +### Performance Improvements + +* **options:** better detection for foldtext,statuscolumn,folexpr support ([e105c9d](https://github.com/LazyVim/LazyVim/commit/e105c9daf6e973b4a294a17b4d2d1882f2188ac6)) + ## [8.4.1](https://github.com/LazyVim/LazyVim/compare/v8.4.0...v8.4.1) (2023-10-03) From 6cf6b0a6241c659113f5646ff64fba7dbf5161b9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 18:28:02 +0200 Subject: [PATCH 090/362] fix(ui): always pad to 2 cells for status column icons. Fixes #1571 --- lua/lazyvim/util/ui.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index b11e6a04..0f96e87a 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -15,7 +15,7 @@ end ---@param len? number function M.icon(sign, len) sign = sign or {} - len = len or 1 + len = len or 2 local text = vim.fn.strcharpart(sign.text or "", 0, len) ---@type string text = text .. string.rep(" ", len - vim.fn.strchars(text)) return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text @@ -71,7 +71,7 @@ function M.statuscolumn() M.icon(left), [[%=]], nu .. " ", - M.icon(fold or right, 2), + M.icon(fold or right), }, "") end From 0e16033e9cfd375ad52ca183718af4e319ed5406 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 18:30:22 +0200 Subject: [PATCH 091/362] chore(main): release 8.4.3 (#1573) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eba18cda..4a10bce8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [8.4.3](https://github.com/LazyVim/LazyVim/compare/v8.4.2...v8.4.3) (2023-10-03) + + +### Bug Fixes + +* **ui:** always pad to 2 cells for status column icons. Fixes [#1571](https://github.com/LazyVim/LazyVim/issues/1571) ([6cf6b0a](https://github.com/LazyVim/LazyVim/commit/6cf6b0a6241c659113f5646ff64fba7dbf5161b9)) + ## [8.4.2](https://github.com/LazyVim/LazyVim/compare/v8.4.1...v8.4.2) (2023-10-03) From ccff8683ba957250d71ef66429fc877f0ee5cedb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 18:57:03 +0200 Subject: [PATCH 092/362] fix(ui): work-around for telescope issue with treesitter folds --- lua/lazyvim/config/autocmds.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index a3ba5c91..86635832 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -91,3 +91,16 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") end, }) + +-- HACK: re-caclulate folds when entering a buffer through Telescope +-- @see https://github.com/nvim-telescope/telescope.nvim/issues/699 +vim.api.nvim_create_autocmd("BufEnter", { + group = augroup("fix_folds"), + callback = function() + if vim.opt.foldmethod:get() == "expr" then + vim.schedule(function() + vim.opt.foldmethod = "expr" + end) + end + end, +}) From 758520dcbbf0f40774beceaf65de3f464b23fc3f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:00:20 +0200 Subject: [PATCH 093/362] chore(main): release 8.4.4 (#1575) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a10bce8..040cf6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [8.4.4](https://github.com/LazyVim/LazyVim/compare/v8.4.3...v8.4.4) (2023-10-03) + + +### Bug Fixes + +* **ui:** work-around for telescope issue with treesitter folds ([ccff868](https://github.com/LazyVim/LazyVim/commit/ccff8683ba957250d71ef66429fc877f0ee5cedb)) + ## [8.4.3](https://github.com/LazyVim/LazyVim/compare/v8.4.2...v8.4.3) (2023-10-03) From 5f0713d2b612a814586bffec39700ab6a30dc0ea Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 3 Oct 2023 20:17:30 +0200 Subject: [PATCH 094/362] feat(treesitter): map `vim` to `@namespace.builtin` --- queries/lua/highlights.scm | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 queries/lua/highlights.scm diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm new file mode 100644 index 00000000..829b2b08 --- /dev/null +++ b/queries/lua/highlights.scm @@ -0,0 +1,4 @@ +;; extends + +((identifier) @namespace.builtin + (#eq? @namespace.builtin "vim")) From 626ae1338a88f6cd8962d6c20bd79953a67f0b72 Mon Sep 17 00:00:00 2001 From: Ahmed W Date: Tue, 3 Oct 2023 16:40:32 -0500 Subject: [PATCH 095/362] feat(typescript): add typescriptreact/javascriptreact to types (#1574) * feat(typescript): add typescriptreact/javascriptreact to types * remove unneeded values * revert settings change --- lua/lazyvim/plugins/extras/lang/typescript.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 44a963ec..4af1deec 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -86,7 +86,7 @@ return { }, } end - for _, language in ipairs({ "typescript", "javascript" }) do + for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do if not dap.configurations[language] then dap.configurations[language] = { { From 0e66ef83934eb62ee2237e331dcbc0a22b809aae Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 00:12:32 +0200 Subject: [PATCH 096/362] feat(treesitter): added ]f, [f, ]F, [F, ]c, ]C, [c, [C for treesitter-textobjects --- lua/lazyvim/plugins/coding.lua | 1 - lua/lazyvim/plugins/treesitter.lua | 32 +++++++++--------------------- 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 7250638d..0e01d277 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -179,7 +179,6 @@ return { -- { "i", mode = { "x", "o" } }, -- }, event = "VeryLazy", - dependencies = { "nvim-treesitter-textobjects" }, opts = function() local ai = require("mini.ai") return { diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index b84d01a7..0b9b6895 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -1,4 +1,3 @@ -local load_textobjects = false return { -- Treesitter is a new parser generator tool that we can -- use in Neovim to power faster and more accurate @@ -11,13 +10,6 @@ return { dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - -- disable rtp plugin, as we only need its queries for mini.ai - -- In case other textobject modules are enabled, we will load them - -- once nvim-treesitter is loaded - require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") - load_textobjects = true - end, }, }, cmd = { "TSUpdateSync" }, @@ -59,6 +51,15 @@ return { node_decremental = "", }, }, + textobjects = { + move = { + enable = true, + goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" }, + goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" }, + goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" }, + goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" }, + }, + }, }, ---@param opts TSConfig config = function(_, opts) @@ -74,21 +75,6 @@ return { end, opts.ensure_installed) end require("nvim-treesitter.configs").setup(opts) - - if load_textobjects then - -- PERF: no need to load the plugin, if we only need its queries for mini.ai - if opts.textobjects then - for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do - if opts.textobjects[mod] and opts.textobjects[mod].enable then - local Loader = require("lazy.core.loader") - Loader.disabled_rtp_plugins["nvim-treesitter-textobjects"] = nil - local plugin = require("lazy.core.config").plugins["nvim-treesitter-textobjects"] - require("lazy.core.loader").source_runtime(plugin.dir, "plugin") - break - end - end - end - end end, }, } From d28c69e49eab62b45f7d1562b3bc00afee5fbb65 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 00:25:44 +0200 Subject: [PATCH 097/362] feat(mini.surround)!: default surround mappings are now gs instead of gz (unless you enabled the leap extra) --- lua/lazyvim/plugins/coding.lua | 14 +++++++------- lua/lazyvim/plugins/extras/editor/leap.lua | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 0e01d277..122187f8 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -140,13 +140,13 @@ return { end, opts = { mappings = { - add = "gza", -- Add surrounding in Normal and Visual modes - delete = "gzd", -- Delete surrounding - find = "gzf", -- Find surrounding (to the right) - find_left = "gzF", -- Find surrounding (to the left) - highlight = "gzh", -- Highlight surrounding - replace = "gzr", -- Replace surrounding - update_n_lines = "gzn", -- Update `n_lines` + add = "gsa", -- Add surrounding in Normal and Visual modes + delete = "gsd", -- Delete surrounding + find = "gsf", -- Find surrounding (to the right) + find_left = "gsF", -- Find surrounding (to the left) + highlight = "gsh", -- Highlight surrounding + replace = "gsr", -- Replace surrounding + update_n_lines = "gsn", -- Update `n_lines` }, }, }, diff --git a/lua/lazyvim/plugins/extras/editor/leap.lua b/lua/lazyvim/plugins/extras/editor/leap.lua index a104b98e..ab422abf 100644 --- a/lua/lazyvim/plugins/extras/editor/leap.lua +++ b/lua/lazyvim/plugins/extras/editor/leap.lua @@ -35,6 +35,22 @@ return { end, }, + -- rename surround mappings from gs to gz to prevent conflict with leap + { + "echasnovski/mini.surround", + opts = { + mappings = { + add = "gza", -- Add surrounding in Normal and Visual modes + delete = "gzd", -- Delete surrounding + find = "gzf", -- Find surrounding (to the right) + find_left = "gzF", -- Find surrounding (to the left) + highlight = "gzh", -- Highlight surrounding + replace = "gzr", -- Replace surrounding + update_n_lines = "gzn", -- Update `n_lines` + }, + }, + }, + -- makes some plugins dot-repeatable like leap { "tpope/vim-repeat", event = "VeryLazy" }, } From f15dd301e5fea81921a9320347e8a9b31f79814e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 10:43:44 +0200 Subject: [PATCH 098/362] style: fixed lua annotations --- lua/lazyvim/config/init.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 91a66f89..964ca5b9 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,9 +1,9 @@ ----@type LazyVimConfig +---@class LazyVimConfig: LazyVimOptions local M = {} M.lazy_version = ">=9.1.0" ----@class LazyVimConfig +---@class LazyVimOptions local defaults = { -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme ---@type string|fun() @@ -86,12 +86,12 @@ M.renames = { ["null-ls.nvim"] = "none-ls.nvim", } ----@type LazyVimConfig +---@type LazyVimOptions local options ----@param opts? LazyVimConfig +---@param opts? LazyVimOptions function M.setup(opts) - options = vim.tbl_deep_extend("force", defaults, opts or {}) + options = vim.tbl_deep_extend("force", defaults, opts or {}) or {} if vim.fn.has("nvim-0.9.0") == 0 then vim.api.nvim_echo({ @@ -199,6 +199,7 @@ function M.init() require("lazyvim.config").load("options") local Plugin = require("lazy.core.plugin") local add = Plugin.Spec.add + ---@diagnostic disable-next-line: duplicate-set-field Plugin.Spec.add = function(self, plugin, ...) if type(plugin) == "table" and M.renames[plugin[1]] then require("lazy.core.util").warn( From 936d74bb6127721eeefa62e5f697d9693ab04fdd Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 10:45:10 +0200 Subject: [PATCH 099/362] perf: added support for `LazyFile` event that properly loads file based plugins without blocking the ui --- lua/lazyvim/config/init.lua | 47 ++++++++++++++++++- lua/lazyvim/plugins/editor.lua | 6 +-- lua/lazyvim/plugins/extras/lang/cmake.lua | 2 +- .../plugins/extras/linting/nvim-lint.lua | 3 +- .../plugins/extras/util/mini-hipatterns.lua | 2 +- lua/lazyvim/plugins/lsp/init.lua | 4 +- lua/lazyvim/plugins/treesitter.lua | 2 +- lua/lazyvim/plugins/ui.lua | 6 +-- 8 files changed, 58 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 964ca5b9..36335f7b 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -124,8 +124,9 @@ function M.setup(opts) M.load("autocmds") end + local group = vim.api.nvim_create_augroup("LazyVim", { clear = true }) vim.api.nvim_create_autocmd("User", { - group = vim.api.nvim_create_augroup("LazyVim", { clear = true }), + group = group, pattern = "VeryLazy", callback = function() if lazy_autocmds then @@ -135,6 +136,8 @@ function M.setup(opts) end, }) + M.lazy_file() + require("lazy.core.util").try(function() if type(M.colorscheme) == "function" then M.colorscheme() @@ -150,6 +153,40 @@ function M.setup(opts) }) end +-- Properly load file based plugins without blocking the UI +function M.lazy_file() + local events = {} ---@type {event: string, pattern?: string, buf: number, data?: any}[] + + local function load() + if #events == 0 then + return + end + vim.api.nvim_del_augroup_by_name("lazy_file") + vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) + for _, event in ipairs(events) do + vim.api.nvim_exec_autocmds(event.event, { + pattern = event.pattern, + modeline = false, + buffer = event.buf, + data = event.data, + }) + end + events = {} + end + + -- schedule wrap so that nested autocmds are executed + -- and the UI can continue rendering without blocking + load = vim.schedule_wrap(load) + + vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "BufNewFile" }, { + group = vim.api.nvim_create_augroup("lazy_file", { clear = true }), + callback = function(event) + table.insert(events, event) + load() + end, + }) +end + ---@param range? string function M.has(range) local Semver = require("lazy.manage.semver") @@ -214,6 +251,14 @@ function M.init() end return add(self, plugin, ...) end + + -- Add support for the LazyFile event + local Event = require("lazy.core.handler.event") + local _event = Event._event + ---@diagnostic disable-next-line: duplicate-set-field + Event._event = function(self, value) + return value == "LazyFile" and "User LazyFile" or _event(self, value) + end end end diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 20b466fd..3f4c5d52 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -310,7 +310,7 @@ return { -- hunks in a commit. { "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", opts = { signs = { add = { text = "▎" }, @@ -349,7 +349,7 @@ return { -- instances. { "RRethy/vim-illuminate", - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", opts = { delay = 200, large_file_cutoff = 2000, @@ -440,7 +440,7 @@ return { { "folke/todo-comments.nvim", cmd = { "TodoTrouble", "TodoTelescope" }, - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", config = true, -- stylua: ignore keys = { diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index cd802edf..bc7b235a 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -45,6 +45,6 @@ return { { "Civitasv/cmake-tools.nvim", opts = {}, - event = "BufRead", + event = "LazyFile", }, } diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index 879b2177..2d750309 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -1,7 +1,7 @@ return { { "mfussenegger/nvim-lint", - event = "BufReadPost", + event = "LazyFile", opts = { -- Event to trigger linters events = { "BufWritePost", "BufReadPost", "InsertLeave" }, @@ -43,7 +43,6 @@ return { end function M.lint() - local lint = require("lint") local names = lint.linters_by_ft[vim.bo.filetype] or {} local ctx = { filename = vim.api.nvim_buf_get_name(0) } ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 1367f908..43b8c49d 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -5,7 +5,7 @@ M.hl = {} M.plugin = { "echasnovski/mini.hipatterns", - event = "BufReadPre", + event = "LazyFile", opts = function() local hi = require("mini.hipatterns") return { diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 178102e3..211385f9 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -2,7 +2,7 @@ return { -- lspconfig { "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", dependencies = { { "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } }, { "folke/neodev.nvim", opts = {} }, @@ -203,7 +203,7 @@ return { -- formatters { "nvimtools/none-ls.nvim", - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", dependencies = { "mason.nvim" }, opts = function() local nls = require("null-ls") diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 0b9b6895..f6d36519 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -6,7 +6,7 @@ return { "nvim-treesitter/nvim-treesitter", version = false, -- last release is way too old and doesn't work on Windows build = ":TSUpdate", - event = { "BufReadPost", "BufNewFile" }, + event = { "LazyFile", "VeryLazy" }, dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index d8d6e181..677b902a 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -53,7 +53,7 @@ return { -- tabs, which include filetype icons and close buttons. { "akinsho/bufferline.nvim", - event = "VeryLazy", + event = "LazyFile", keys = { { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, @@ -166,7 +166,7 @@ return { -- indent guides for Neovim { "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", opts = { indent = { char = "│", @@ -197,7 +197,7 @@ return { { "echasnovski/mini.indentscope", version = false, -- wait till new 0.7.0 release to put it back on semver - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", opts = { -- symbol = "▏", symbol = "│", From afc8e7f8cac06335efd12ec5f71cabb1f38a09b0 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 10:48:20 +0200 Subject: [PATCH 100/362] fix(autocmds): retore last location for correct buffer --- lua/lazyvim/config/autocmds.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 86635832..7d9feedd 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -31,9 +31,9 @@ vim.api.nvim_create_autocmd({ "VimResized" }, { -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { group = augroup("last_loc"), - callback = function() + callback = function(event) local exclude = { "gitcommit" } - local buf = vim.api.nvim_get_current_buf() + local buf = event.buf if vim.tbl_contains(exclude, vim.bo[buf].filetype) then return end From a12d4bd4e4b62635e6c4ef091c145f64a6eb9228 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 4 Oct 2023 08:49:22 +0000 Subject: [PATCH 101/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index dd020d8e..9a155be3 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 03 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 04 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 417de0193dd0663100a8b1eaedc2bc4976712c61 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 12:44:00 +0200 Subject: [PATCH 102/362] feat(extras): added extra for dashboard.nvim --- lua/lazyvim/plugins/extras/ui/dashboard.lua | 62 +++++++++++++++++++ .../plugins/extras/ui/mini-starter.lua | 1 + 2 files changed, 63 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/ui/dashboard.lua diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua new file mode 100644 index 00000000..b9801b75 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/dashboard.lua @@ -0,0 +1,62 @@ +return { + { "goolord/alpha-nvim", enabled = false }, + { "echasnovski/mini.starter", enabled = false }, + { + "glepnir/dashboard-nvim", + event = "VimEnter", + dependencies = { + -- disable alpha + { "goolord/alpha-nvim", enabled = false }, + }, + opts = function() + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + logo = string.rep("\n", 8) .. logo .. "\n\n" + + local opts = { + theme = "doom", + config = { + header = vim.split(logo, "\n"), + center = { + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, + }, + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" } + end, + }, + } + + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + end + + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardLoaded", + callback = function() + require("lazy").show() + end, + }) + end + return opts + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index ee35fc68..04a578be 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -2,6 +2,7 @@ return { -- disable alpha { "goolord/alpha-nvim", enabled = false }, + { "glepnir/dashboard-nvim", enabled = false }, -- enable mini.starter { From 35053290bf957a230c8758d31ba3997c0699f5f9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 12:47:24 +0200 Subject: [PATCH 103/362] fix(ui): use custom fold when treesitter foldtext returns a string --- lua/lazyvim/util/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 0f96e87a..92376a52 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -24,7 +24,7 @@ end function M.foldtext() local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf()) local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext() - if not ret then + if not ret or type(ret) == "string" then ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } } end table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots }) From bd2ac542a0bb4c58237cd6ca8848063bd20a5282 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 12:48:37 +0200 Subject: [PATCH 104/362] feat(ui): show alpha marks in statuscolumn --- lua/lazyvim/util/ui.lua | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 92376a52..43e2d583 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -3,12 +3,26 @@ local M = {} ---@alias Sign {name:string, text:string, texthl:string} ---@return Sign[] -function M.get_signs(win) - local buf = vim.api.nvim_win_get_buf(win) +---@param buf number +---@param lnum number +function M.get_signs(buf, lnum) ---@diagnostic disable-next-line: no-unknown return vim.tbl_map(function(sign) return vim.fn.sign_getdefined(sign.name)[1] - end, vim.fn.sign_getplaced(buf, { group = "*", lnum = vim.v.lnum })[1].signs) + end, vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) +end + +---@return Sign? +---@param buf number +---@param lnum number +function M.get_mark(buf, lnum) + local marks = vim.fn.getmarklist(buf) + vim.list_extend(marks, vim.fn.getmarklist()) + for _, mark in ipairs(marks) do + if mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then + return { text = mark.mark:sub(2), texthl = "DiagnosticHint" } + end + end end ---@param sign? Sign @@ -45,10 +59,11 @@ function M.statuscolumn() if vim.wo[win].signcolumn == "no" then return "" end + local buf = vim.api.nvim_win_get_buf(win) ---@type Sign?,Sign?,Sign? local left, right, fold - for _, s in ipairs(M.get_signs(win)) do + for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do if s.name:find("GitSign") then right = s elseif not left then @@ -68,7 +83,7 @@ function M.statuscolumn() end return table.concat({ - M.icon(left), + M.icon(M.get_mark(buf, vim.v.lnum) or left), [[%=]], nu .. " ", M.icon(fold or right), From 3833a7d1ce9b65d6cb85a72705670d00bce52e08 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 13:19:12 +0200 Subject: [PATCH 105/362] style: removed dead code --- lua/lazyvim/plugins/extras/vscode.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index 6a457cf1..6f78fd9f 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -18,7 +18,6 @@ local enabled = { } local Config = require("lazy.core.config") -local Plugin = require("lazy.core.plugin") Config.options.checker.enabled = false Config.options.change_detection.enabled = false Config.options.defaults.cond = function(plugin) From 2f16a7b2d96e912c9ab50ce99d9994413ff3678d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 13:43:36 +0200 Subject: [PATCH 106/362] perf(config): add LazyVim to the rtp early for faster spec loading --- lua/lazyvim/config/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 36335f7b..feed2dff 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -227,6 +227,7 @@ M.did_init = false function M.init() if not M.did_init then M.did_init = true + vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir) -- delay notifications till vim.notify was replaced or after 500ms require("lazyvim.util").lazy_notify() From 9f034ab10650e306e178d5189ee9214a52f2e8e5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 14:41:00 +0200 Subject: [PATCH 107/362] fix(conform): dont try to merge formatter functions --- lua/lazyvim/plugins/extras/formatting/conform.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index ee914f8e..eb1db8b1 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -44,8 +44,10 @@ return { config = function(_, opts) opts.formatters = opts.formatters or {} for f, o in pairs(opts.formatters) do - local ok, formatter = pcall(require, "conform.formatters." .. f) - opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o) + if type(o) ~= "function" then + local ok, formatter = pcall(require, "conform.formatters." .. f) + opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o) + end end require("conform").setup(opts) end, From f4750859f2c2c9a41b3974ac05962ce9648d6c16 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 14:44:24 +0200 Subject: [PATCH 108/362] fix(conform): dont try merging function formatters. Fixes #1582 --- lua/lazyvim/plugins/extras/formatting/conform.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index eb1db8b1..b2975882 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -43,10 +43,12 @@ return { }, config = function(_, opts) opts.formatters = opts.formatters or {} - for f, o in pairs(opts.formatters) do - if type(o) ~= "function" then - local ok, formatter = pcall(require, "conform.formatters." .. f) - opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o) + for name, formatter in pairs(opts.formatters) do + if type(formatter) == "table" then + local ok, defaults = pcall(require, "conform.formatters." .. name) + if ok and type(defaults) == "table" then + opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) + end end end require("conform").setup(opts) From 79010ae671035d8ed0040ce51df4fb59ec3962f8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 14:45:45 +0200 Subject: [PATCH 109/362] fix(nvim-lint): dont try merging function linters --- lua/lazyvim/plugins/extras/linting/nvim-lint.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua index 2d750309..1fb7ab5d 100644 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua @@ -27,7 +27,9 @@ return { local lint = require("lint") for name, linter in pairs(opts.linters) do - lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name] or {}, linter) + if type(linter) == "table" and type(lint.linters) == "table" then + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + end end lint.linters_by_ft = opts.linters_by_ft From c490c61d07b02755a34df188d283550d59a04c2f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 15:03:00 +0200 Subject: [PATCH 110/362] chore(main): release 9.0.0 (#1576) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 040cf6b5..c91f01bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +## [9.0.0](https://github.com/LazyVim/LazyVim/compare/v8.4.4...v9.0.0) (2023-10-04) + + +### ⚠ BREAKING CHANGES + +* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra) + +### Features + +* **extras:** added extra for dashboard.nvim ([417de01](https://github.com/LazyVim/LazyVim/commit/417de0193dd0663100a8b1eaedc2bc4976712c61)) +* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra) ([d28c69e](https://github.com/LazyVim/LazyVim/commit/d28c69e49eab62b45f7d1562b3bc00afee5fbb65)) +* **treesitter:** added ]f, [f, ]F, [F, ]c, ]C, [c, [C for treesitter-textobjects ([0e66ef8](https://github.com/LazyVim/LazyVim/commit/0e66ef83934eb62ee2237e331dcbc0a22b809aae)) +* **treesitter:** map `vim` to `[@namespace](https://github.com/namespace).builtin` ([5f0713d](https://github.com/LazyVim/LazyVim/commit/5f0713d2b612a814586bffec39700ab6a30dc0ea)) +* **typescript:** add typescriptreact/javascriptreact to types ([#1574](https://github.com/LazyVim/LazyVim/issues/1574)) ([626ae13](https://github.com/LazyVim/LazyVim/commit/626ae1338a88f6cd8962d6c20bd79953a67f0b72)) +* **ui:** show alpha marks in statuscolumn ([bd2ac54](https://github.com/LazyVim/LazyVim/commit/bd2ac542a0bb4c58237cd6ca8848063bd20a5282)) + + +### Bug Fixes + +* **autocmds:** retore last location for correct buffer ([afc8e7f](https://github.com/LazyVim/LazyVim/commit/afc8e7f8cac06335efd12ec5f71cabb1f38a09b0)) +* **conform:** dont try merging function formatters. Fixes [#1582](https://github.com/LazyVim/LazyVim/issues/1582) ([f475085](https://github.com/LazyVim/LazyVim/commit/f4750859f2c2c9a41b3974ac05962ce9648d6c16)) +* **conform:** dont try to merge formatter functions ([9f034ab](https://github.com/LazyVim/LazyVim/commit/9f034ab10650e306e178d5189ee9214a52f2e8e5)) +* **nvim-lint:** dont try merging function linters ([79010ae](https://github.com/LazyVim/LazyVim/commit/79010ae671035d8ed0040ce51df4fb59ec3962f8)) +* **ui:** use custom fold when treesitter foldtext returns a string ([3505329](https://github.com/LazyVim/LazyVim/commit/35053290bf957a230c8758d31ba3997c0699f5f9)) + + +### Performance Improvements + +* added support for `LazyFile` event that properly loads file based plugins without blocking the ui ([936d74b](https://github.com/LazyVim/LazyVim/commit/936d74bb6127721eeefa62e5f697d9693ab04fdd)) +* **config:** add LazyVim to the rtp early for faster spec loading ([2f16a7b](https://github.com/LazyVim/LazyVim/commit/2f16a7b2d96e912c9ab50ce99d9994413ff3678d)) + ## [8.4.4](https://github.com/LazyVim/LazyVim/compare/v8.4.3...v8.4.4) (2023-10-03) From 1abcffbfd940588fa67cc7438ce2115df1c58e92 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 16:44:29 +0200 Subject: [PATCH 111/362] fix(alpha): use `` instead of `:` for shortcuts --- lua/lazyvim/plugins/ui.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 677b902a..335cbcb8 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -296,14 +296,14 @@ return { dashboard.section.header.val = vim.split(logo, "\n") dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", ":Telescope find_files "), - dashboard.button("n", " " .. " New file", ":ene startinsert "), - dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", ":Telescope live_grep "), - dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), - dashboard.button("s", " " .. " Restore Session", [[:lua require("persistence").load() ]]), - dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy"), - dashboard.button("q", " " .. " Quit", ":qa"), + dashboard.button("f", " " .. " Find file", " Telescope find_files "), + dashboard.button("n", " " .. " New file", " ene startinsert "), + dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", " Telescope live_grep "), + dashboard.button("c", " " .. " Config", " e $MYVIMRC "), + dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), } for _, button in ipairs(dashboard.section.buttons.val) do button.opts.hl = "AlphaButtons" From 3849e0150b0a616dbd6e7e12ec5025aff6c81d39 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 17:53:00 +0200 Subject: [PATCH 112/362] fix(ui): show global marks in the correct buffer only --- lua/lazyvim/util/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 43e2d583..d24d4239 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -19,7 +19,7 @@ function M.get_mark(buf, lnum) local marks = vim.fn.getmarklist(buf) vim.list_extend(marks, vim.fn.getmarklist()) for _, mark in ipairs(marks) do - if mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then + if mark.pos[1] == buf and mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then return { text = mark.mark:sub(2), texthl = "DiagnosticHint" } end end From d989ecc943b3240db0be3aa0369b96089cee4b40 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 18:07:21 +0200 Subject: [PATCH 113/362] fix(options): only enable treesitter `foldexpr` on nightly. Fixes #1581 --- lua/lazyvim/config/options.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index c2f3177d..f1198397 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -65,9 +65,13 @@ vim.opt.foldlevel = 99 vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()" if vim.fn.has("nvim-0.9.0") == 1 then + vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] +end + +-- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now +if vim.fn.has("nvim-0.10") == 1 then vim.opt.foldmethod = "expr" vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" - vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] else vim.opt.foldmethod = "indent" end From b58446f7b3724ae321501a6c0cce6d3abdf1b918 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 18:09:31 +0200 Subject: [PATCH 114/362] chore(main): release 9.0.1 (#1585) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c91f01bd..b7b7644b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [9.0.1](https://github.com/LazyVim/LazyVim/compare/v9.0.0...v9.0.1) (2023-10-04) + + +### Bug Fixes + +* **alpha:** use `<cmd>` instead of `:` for shortcuts ([1abcffb](https://github.com/LazyVim/LazyVim/commit/1abcffbfd940588fa67cc7438ce2115df1c58e92)) +* **options:** only enable treesitter `foldexpr` on nightly. Fixes [#1581](https://github.com/LazyVim/LazyVim/issues/1581) ([d989ecc](https://github.com/LazyVim/LazyVim/commit/d989ecc943b3240db0be3aa0369b96089cee4b40)) +* **ui:** show global marks in the correct buffer only ([3849e01](https://github.com/LazyVim/LazyVim/commit/3849e0150b0a616dbd6e7e12ec5025aff6c81d39)) + ## [9.0.0](https://github.com/LazyVim/LazyVim/compare/v8.4.4...v9.0.0) (2023-10-04) From 7272b3e4b5b626597658dabf774998057892d066 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 20:04:56 +0200 Subject: [PATCH 115/362] fix(bufferline): load bufferline on VeryLazy. Fixes #1587 --- lua/lazyvim/plugins/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 335cbcb8..1df40c92 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -53,7 +53,7 @@ return { -- tabs, which include filetype icons and close buttons. { "akinsho/bufferline.nvim", - event = "LazyFile", + event = "VeryLazy", keys = { { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, From 0cc80b1b0594516ccc2c1e6c9a60c84012a29abb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 20:40:11 +0200 Subject: [PATCH 116/362] fix(autocmds): last_loc autocmd didn't work correctly for first opened file --- lua/lazyvim/config/autocmds.lua | 3 +++ lua/lazyvim/config/init.lua | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 7d9feedd..e2828726 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -32,6 +32,9 @@ vim.api.nvim_create_autocmd({ "VimResized" }, { vim.api.nvim_create_autocmd("BufReadPost", { group = augroup("last_loc"), callback = function(event) + if event.data and event.data.lazy_file then + return + end local exclude = { "gitcommit" } local buf = event.buf if vim.tbl_contains(exclude, vim.bo[buf].filetype) then diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index feed2dff..119d8b4c 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -168,9 +168,10 @@ function M.lazy_file() pattern = event.pattern, modeline = false, buffer = event.buf, - data = event.data, + data = { lazy_file = true }, }) end + vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) events = {} end From 86de423ef029abd085531e18b197a5f90e201d98 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Oct 2023 21:00:32 +0200 Subject: [PATCH 117/362] fix(treesitter): dont enable ]c, [c, ... in diff-mode --- lua/lazyvim/plugins/treesitter.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index f6d36519..753cfb7d 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -10,6 +10,18 @@ return { dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", + config = function() + -- Disable class keymaps in diff mode + vim.api.nvim_create_autocmd("BufReadPost", { + callback = function(event) + if vim.wo.diff then + for _, key in ipairs({ "[c", "]c", "[C", "]C" }) do + pcall(vim.keymap.del, "n", key, { buffer = event.buf }) + end + end + end, + }) + end, }, }, cmd = { "TSUpdateSync" }, From 49b91b6b1fe8a9bc55f643b390a346919f629948 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 4 Oct 2023 21:10:17 +0200 Subject: [PATCH 118/362] chore(main): release 9.0.2 (#1589) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b7644b..b2fbe7fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## [9.0.2](https://github.com/LazyVim/LazyVim/compare/v9.0.1...v9.0.2) (2023-10-04) + + +### Bug Fixes + +* **autocmds:** last_loc autocmd didn't work correctly for first opened file ([0cc80b1](https://github.com/LazyVim/LazyVim/commit/0cc80b1b0594516ccc2c1e6c9a60c84012a29abb)) +* **bufferline:** load bufferline on VeryLazy. Fixes [#1587](https://github.com/LazyVim/LazyVim/issues/1587) ([7272b3e](https://github.com/LazyVim/LazyVim/commit/7272b3e4b5b626597658dabf774998057892d066)) +* **treesitter:** dont enable ]c, [c, ... in diff-mode ([86de423](https://github.com/LazyVim/LazyVim/commit/86de423ef029abd085531e18b197a5f90e201d98)) + ## [9.0.1](https://github.com/LazyVim/LazyVim/compare/v9.0.0...v9.0.1) (2023-10-04) From d3e7f7717e960bb883b35e9a75badfd5b938cace Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 5 Oct 2023 08:07:53 +0200 Subject: [PATCH 119/362] fix(tailwind): allow overriding filetypes. Fixes #1590 --- lua/lazyvim/plugins/extras/lang/tailwind.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/tailwind.lua b/lua/lazyvim/plugins/extras/lang/tailwind.lua index bed7e6c0..d7d35963 100644 --- a/lua/lazyvim/plugins/extras/lang/tailwind.lua +++ b/lua/lazyvim/plugins/extras/lang/tailwind.lua @@ -4,16 +4,30 @@ return { opts = { servers = { tailwindcss = { + -- exclude a filetype from the default_config filetypes_exclude = { "markdown" }, + -- add additional filetypes to the default_config + filetypes_include = {}, + -- to fully override the default_config, change the below + -- filetypes = {} }, }, setup = { tailwindcss = function(_, opts) local tw = require("lspconfig.server_configurations.tailwindcss") + opts.filetypes = opts.filetypes or {} + + -- Add default filetypes + vim.list_extend(opts.filetypes, tw.default_config.filetypes) + + -- Remove excluded filetypes --- @param ft string opts.filetypes = vim.tbl_filter(function(ft) return not vim.tbl_contains(opts.filetypes_exclude or {}, ft) - end, tw.default_config.filetypes) + end, opts.filetypes) + + -- Add additional filetypes + vim.list_extend(opts.filetypes, opts.filetypes_include) end, }, }, From 6f6d58799895e0b76dec7feb241709c494007390 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 5 Oct 2023 06:08:38 +0000 Subject: [PATCH 120/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 9a155be3..d1cb1457 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 04 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 05 ============================================================================== Table of Contents *LazyVim-table-of-contents* From d6b56c075e88ce12e9e16fb2eeeea38fb7853600 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 5 Oct 2023 09:53:48 +0200 Subject: [PATCH 121/362] fix(dasboard): disable alpha only once --- lua/lazyvim/plugins/extras/ui/dashboard.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua index b9801b75..cf7c8860 100644 --- a/lua/lazyvim/plugins/extras/ui/dashboard.lua +++ b/lua/lazyvim/plugins/extras/ui/dashboard.lua @@ -4,10 +4,6 @@ return { { "glepnir/dashboard-nvim", event = "VimEnter", - dependencies = { - -- disable alpha - { "goolord/alpha-nvim", enabled = false }, - }, opts = function() local logo = [[ ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z From 1eb019274b5564e66ac6c7e119c140bae262e10c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 5 Oct 2023 10:43:21 +0200 Subject: [PATCH 122/362] fix(options): set default laststatus=3 and set it to 0 before loading dashboard to prevent flickering --- lua/lazyvim/config/options.lua | 2 +- lua/lazyvim/plugins/ui.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index f1198397..de54693f 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -16,7 +16,7 @@ opt.grepformat = "%f:%l:%c:%m" opt.grepprg = "rg --vimgrep" opt.ignorecase = true -- Ignore case opt.inccommand = "nosplit" -- preview incremental substitute -opt.laststatus = 0 +opt.laststatus = 3 -- global statusline opt.list = true -- Show some invisible characters (tabs... opt.mouse = "a" -- Enable mouse mode opt.number = true -- Print line number diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 1df40c92..1e45b9c4 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -316,6 +316,7 @@ return { return dashboard end, config = function(_, dashboard) + vim.o.laststatus = 0 -- close Lazy and re-open when the dashboard is ready if vim.o.filetype == "lazy" then vim.cmd.close() From 6f1cdfe4bd2ec9a85c92a312fa52ba86e02d1a9f Mon Sep 17 00:00:00 2001 From: Jonas Holst Damtoft Date: Thu, 5 Oct 2023 15:59:44 +0200 Subject: [PATCH 123/362] feat(dashboard): add projects if enabled (#1595) --- lua/lazyvim/plugins/extras/util/project.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 82234c4d..d6be2b9c 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -42,4 +42,17 @@ return { vim.list_extend(opts.items, items) end, }, + { + "glepnir/dashboard-nvim", + optional = true, + opts = function(_, opts) + local projects = { + action = "Telescope projects", + desc = " Projects", + icon = " ", + key = "p", + } + table.insert(opts.config.center, 3, projects) + end, + }, } From f2193646564cd90a3ac7f4a25cd09ddbe751b2f0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:03:46 +0200 Subject: [PATCH 124/362] chore(main): release 9.1.0 (#1592) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2fbe7fa..a40a88cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [9.1.0](https://github.com/LazyVim/LazyVim/compare/v9.0.2...v9.1.0) (2023-10-05) + + +### Features + +* **dashboard:** add projects if enabled ([#1595](https://github.com/LazyVim/LazyVim/issues/1595)) ([6f1cdfe](https://github.com/LazyVim/LazyVim/commit/6f1cdfe4bd2ec9a85c92a312fa52ba86e02d1a9f)) + + +### Bug Fixes + +* **dasboard:** disable alpha only once ([d6b56c0](https://github.com/LazyVim/LazyVim/commit/d6b56c075e88ce12e9e16fb2eeeea38fb7853600)) +* **options:** set default laststatus=3 and set it to 0 before loading dashboard to prevent flickering ([1eb0192](https://github.com/LazyVim/LazyVim/commit/1eb019274b5564e66ac6c7e119c140bae262e10c)) +* **tailwind:** allow overriding filetypes. Fixes [#1590](https://github.com/LazyVim/LazyVim/issues/1590) ([d3e7f77](https://github.com/LazyVim/LazyVim/commit/d3e7f7717e960bb883b35e9a75badfd5b938cace)) + ## [9.0.2](https://github.com/LazyVim/LazyVim/compare/v9.0.1...v9.0.2) (2023-10-04) From b2af9412907730068f038e6f642f3c7368c95c30 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 5 Oct 2023 16:33:01 +0200 Subject: [PATCH 125/362] ci: disable blank issues --- .github/ISSUE_TEMPLATE/config.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..3ba13e0c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false From 337cfdbec43003cb2c269e59b27167aa752bf41f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 5 Oct 2023 23:33:44 +0200 Subject: [PATCH 126/362] fix(ui): include extmark signs in signcolumn. Fixes #1596 --- lua/lazyvim/util/ui.lua | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index d24d4239..1cb3b81d 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -1,15 +1,44 @@ local M = {} ----@alias Sign {name:string, text:string, texthl:string} +---@alias Sign {name:string, text:string, texthl:string, priority:number} +-- Returns a list of regular and extmark signs sorted by priority (low to high) ---@return Sign[] ---@param buf number ---@param lnum number function M.get_signs(buf, lnum) - ---@diagnostic disable-next-line: no-unknown - return vim.tbl_map(function(sign) - return vim.fn.sign_getdefined(sign.name)[1] + -- Get regular signs + ---@type Sign[] + local signs = vim.tbl_map(function(sign) + ---@type Sign + local ret = vim.fn.sign_getdefined(sign.name)[1] + ret.priority = sign.priority + return ret end, vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) + + -- Get extmark signs + local extmarks = vim.api.nvim_buf_get_extmarks( + buf, + -1, + { lnum - 1, 0 }, + { lnum - 1, -1 }, + { details = true, type = "sign" } + ) + for _, extmark in pairs(extmarks) do + signs[#signs + 1] = { + name = extmark[4].sign_hl_group, + text = extmark[4].sign_text, + texthl = extmark[4].sign_hl_group, + priority = extmark[4].priority, + } + end + + -- Sort by priority + table.sort(signs, function(a, b) + return (a.priority or 0) < (b.priority or 0) + end) + + return signs end ---@return Sign? @@ -66,7 +95,7 @@ function M.statuscolumn() for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do if s.name:find("GitSign") then right = s - elseif not left then + else left = s end end From cce46cd6401239f04c6ce98113a3410677c1a82f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 01:02:16 +0200 Subject: [PATCH 127/362] chore(main): release 9.1.1 (#1597) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a40a88cd..a326204a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [9.1.1](https://github.com/LazyVim/LazyVim/compare/v9.1.0...v9.1.1) (2023-10-05) + + +### Bug Fixes + +* **ui:** include extmark signs in signcolumn. Fixes [#1596](https://github.com/LazyVim/LazyVim/issues/1596) ([337cfdb](https://github.com/LazyVim/LazyVim/commit/337cfdbec43003cb2c269e59b27167aa752bf41f)) + ## [9.1.0](https://github.com/LazyVim/LazyVim/compare/v9.0.2...v9.1.0) (2023-10-05) From f1ea518e29a601b773d9c9c94489fc9d273c2dea Mon Sep 17 00:00:00 2001 From: Latif Sulistyo Date: Fri, 6 Oct 2023 14:02:45 +0700 Subject: [PATCH 128/362] fix(which-key): change surround group key (#1598) --- lua/lazyvim/plugins/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 3f4c5d52..526509fc 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -282,7 +282,7 @@ return { defaults = { mode = { "n", "v" }, ["g"] = { name = "+goto" }, - ["gz"] = { name = "+surround" }, + ["gs"] = { name = "+surround" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, From 3823f177e93c5370190a4b230818b4ddd8b9bd85 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 6 Oct 2023 07:03:24 +0000 Subject: [PATCH 129/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index d1cb1457..2497b442 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 05 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 06 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 8a1de2b90a699bdfee704f3d4422e2ced18ae0f3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 09:18:04 +0200 Subject: [PATCH 130/362] fix(elixir): only enable credo when installed. Fixes #1546 --- lua/lazyvim/plugins/extras/lang/elixir.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua index dbd0e9a7..53454c37 100644 --- a/lua/lazyvim/plugins/extras/lang/elixir.lua +++ b/lua/lazyvim/plugins/extras/lang/elixir.lua @@ -33,6 +33,9 @@ return { "nvimtools/none-ls.nvim", optional = true, opts = function(_, opts) + if vim.fn.executable("credo") == 0 then + return + end local nls = require("null-ls") opts.sources = opts.sources or {} vim.list_extend(opts.sources, { @@ -43,10 +46,13 @@ return { { "mfussenegger/nvim-lint", optional = true, - opts = { - linters_by_ft = { + opts = function(_, opts) + if vim.fn.executable("credo") == 0 then + return + end + opts.linters_by_ft = { elixir = { "credo" }, - }, - }, + } + end, }, } From a1c5886947e20059ad7802e71e0a82b413af6657 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 09:26:14 +0200 Subject: [PATCH 131/362] feat(conform): ignore formatting errors for injected languages and fix condition example --- lua/lazyvim/plugins/extras/formatting/conform.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index b2975882..44f4ba40 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -33,9 +33,10 @@ return { -- You can also define any custom formatters here. ---@type table formatters = { + injected = { options = { ignore_errors = true } }, -- -- Example of using dprint only when a dprint.json file is present -- dprint = { - -- condition = function(ctx) + -- condition = function(self, ctx) -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] -- end, -- }, From 6e0e01f5b4dd7e97abbb50241a207d36d0ce9cd5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 15:40:27 +0200 Subject: [PATCH 132/362] fix(config): fixed issues related to LazyFile. Fixes #1601 --- lua/lazyvim/config/autocmds.lua | 3 --- lua/lazyvim/config/init.lua | 42 ++++++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index e2828726..7d9feedd 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -32,9 +32,6 @@ vim.api.nvim_create_autocmd({ "VimResized" }, { vim.api.nvim_create_autocmd("BufReadPost", { group = augroup("last_loc"), callback = function(event) - if event.data and event.data.lazy_file then - return - end local exclude = { "gitcommit" } local buf = event.buf if vim.tbl_contains(exclude, vim.bo[buf].filetype) then diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 119d8b4c..98ec867c 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -2,6 +2,7 @@ local M = {} M.lazy_version = ">=9.1.0" +M.use_lazy_file = true ---@class LazyVimOptions local defaults = { @@ -136,7 +137,10 @@ function M.setup(opts) end, }) - M.lazy_file() + M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil + if M.use_lazy_file then + M.lazy_file() + end require("lazy.core.util").try(function() if type(M.colorscheme) == "function" then @@ -155,31 +159,50 @@ end -- Properly load file based plugins without blocking the UI function M.lazy_file() - local events = {} ---@type {event: string, pattern?: string, buf: number, data?: any}[] + local events = {} ---@type {event: string, buf: number, data?: any}[] local function load() if #events == 0 then return end + local Event = require("lazy.core.handler.event") + local Util = require("lazy.core.util") vim.api.nvim_del_augroup_by_name("lazy_file") + + Util.track({ event = "LazyFile" }) + + ---@type table + local skips = { FileType = Event.get_augroups("FileType") } + for _, event in ipairs(events) do + skips[event.event] = skips[event.event] or Event.get_augroups(event.event) + end + vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) for _, event in ipairs(events) do - vim.api.nvim_exec_autocmds(event.event, { - pattern = event.pattern, - modeline = false, - buffer = event.buf, - data = { lazy_file = true }, + Event.trigger({ + event = event.event, + exclude = skips[event.event], + data = event.data, + buf = event.buf, }) + if vim.bo[event.buf].filetype then + Event.trigger({ + event = "FileType", + exclude = skips.FileType, + buf = event.buf, + }) + end end vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) events = {} + Util.track() end -- schedule wrap so that nested autocmds are executed -- and the UI can continue rendering without blocking load = vim.schedule_wrap(load) - vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "BufNewFile" }, { + vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { group = vim.api.nvim_create_augroup("lazy_file", { clear = true }), callback = function(event) table.insert(events, event) @@ -251,6 +274,9 @@ function M.init() ) plugin[1] = M.renames[plugin[1]] end + if not M.use_lazy_file and type(plugin) == "table" and plugin.event == "LazyFile" then + plugin.event = { "BufReadPost", "BufNewFile" } + end return add(self, plugin, ...) end From 6b4c872f2dacfd6e445438da460934ff7fb1f9cb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:53:13 +0200 Subject: [PATCH 133/362] chore(main): release 9.2.0 (#1600) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a326204a..ca4b160f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [9.2.0](https://github.com/LazyVim/LazyVim/compare/v9.1.1...v9.2.0) (2023-10-06) + + +### Features + +* **conform:** ignore formatting errors for injected languages and fix condition example ([a1c5886](https://github.com/LazyVim/LazyVim/commit/a1c5886947e20059ad7802e71e0a82b413af6657)) + + +### Bug Fixes + +* **config:** fixed issues related to LazyFile. Fixes [#1601](https://github.com/LazyVim/LazyVim/issues/1601) ([6e0e01f](https://github.com/LazyVim/LazyVim/commit/6e0e01f5b4dd7e97abbb50241a207d36d0ce9cd5)) +* **elixir:** only enable credo when installed. Fixes [#1546](https://github.com/LazyVim/LazyVim/issues/1546) ([8a1de2b](https://github.com/LazyVim/LazyVim/commit/8a1de2b90a699bdfee704f3d4422e2ced18ae0f3)) +* **which-key:** change surround group key ([#1598](https://github.com/LazyVim/LazyVim/issues/1598)) ([f1ea518](https://github.com/LazyVim/LazyVim/commit/f1ea518e29a601b773d9c9c94489fc9d273c2dea)) + ## [9.1.1](https://github.com/LazyVim/LazyVim/compare/v9.1.0...v9.1.1) (2023-10-05) From e1f5484c826a5ce4fff74ade82471e4c0b6c9f74 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 18:35:17 +0200 Subject: [PATCH 134/362] refactor: use_lazy_file --- lua/lazyvim/config/init.lua | 44 +++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 98ec867c..8af4193e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -137,7 +137,6 @@ function M.setup(opts) end, }) - M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil if M.use_lazy_file then M.lazy_file() end @@ -252,6 +251,10 @@ function M.init() if not M.did_init then M.did_init = true vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir) + + ---@diagnostic disable-next-line: undefined-field + M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil + -- delay notifications till vim.notify was replaced or after 500ms require("lazyvim.util").lazy_notify() @@ -263,19 +266,32 @@ function M.init() local add = Plugin.Spec.add ---@diagnostic disable-next-line: duplicate-set-field Plugin.Spec.add = function(self, plugin, ...) - if type(plugin) == "table" and M.renames[plugin[1]] then - require("lazy.core.util").warn( - ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( - plugin[1], - M.renames[plugin[1]], - self.importing or "LazyVim" - ), - { title = "LazyVim" } - ) - plugin[1] = M.renames[plugin[1]] - end - if not M.use_lazy_file and type(plugin) == "table" and plugin.event == "LazyFile" then - plugin.event = { "BufReadPost", "BufNewFile" } + if type(plugin) == "table" then + if M.renames[plugin[1]] then + require("lazy.core.util").warn( + ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( + plugin[1], + M.renames[plugin[1]], + self.importing or "LazyVim" + ), + { title = "LazyVim" } + ) + plugin[1] = M.renames[plugin[1]] + end + if not M.use_lazy_file and plugin.event then + if plugin.event == "LazyFile" then + plugin.event = { "BufReadPost", "BufNewFile" } + elseif type(plugin.event) == "table" then + local events = {} ---@type string[] + for i, event in ipairs(plugin.event) do + if event == "LazyFile" then + vim.list_extend(events, { "BufReadPost", "BufNewFile" }) + else + events[#events + 1] = event + end + end + end + end end return add(self, plugin, ...) end From 54df3e26aca5c5c4da746f210e6f7e7de30673bb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 18:35:53 +0200 Subject: [PATCH 135/362] feat(bufremove): ask to save changes before trying to remove a buffer --- lua/lazyvim/plugins/editor.lua | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 526509fc..c26d00d5 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -387,9 +387,27 @@ return { -- buffer remove { "echasnovski/mini.bufremove", - -- stylua: ignore + keys = { - { "bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" }, + { + "bd", + function() + local bd = require("mini.bufremove").delete + if vim.bo.modified then + local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel") + if choice == 1 then -- Yes + vim.cmd.write() + bd(0) + elseif choice == 2 then -- No + bd(0, true) + end + else + bd(0) + end + end, + desc = "Delete Buffer", + }, + -- stylua: ignore { "bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, }, }, From 11c9084ec576c8735a87550f7975640eb75e6ff7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 18:43:52 +0200 Subject: [PATCH 136/362] perf(config): only enable LazyFile when opening a file from the cmdline --- lua/lazyvim/config/init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 8af4193e..0f4ce24e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,6 +3,7 @@ local M = {} M.lazy_version = ">=9.1.0" M.use_lazy_file = true +M.lazy_file_events = { "BufReadPost", "BufNewFile" } ---@class LazyVimOptions local defaults = { @@ -168,7 +169,7 @@ function M.lazy_file() local Util = require("lazy.core.util") vim.api.nvim_del_augroup_by_name("lazy_file") - Util.track({ event = "LazyFile" }) + Util.track({ event = "LazyVim.lazy_file" }) ---@type table local skips = { FileType = Event.get_augroups("FileType") } @@ -201,7 +202,7 @@ function M.lazy_file() -- and the UI can continue rendering without blocking load = vim.schedule_wrap(load) - vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, { + vim.api.nvim_create_autocmd(M.lazy_file_events, { group = vim.api.nvim_create_augroup("lazy_file", { clear = true }), callback = function(event) table.insert(events, event) @@ -252,6 +253,7 @@ function M.init() M.did_init = true vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir) + M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil @@ -280,12 +282,12 @@ function M.init() end if not M.use_lazy_file and plugin.event then if plugin.event == "LazyFile" then - plugin.event = { "BufReadPost", "BufNewFile" } + plugin.event = M.lazy_file_events elseif type(plugin.event) == "table" then local events = {} ---@type string[] - for i, event in ipairs(plugin.event) do + for _, event in ipairs(plugin.event) do if event == "LazyFile" then - vim.list_extend(events, { "BufReadPost", "BufNewFile" }) + vim.list_extend(events, M.lazy_file_events) else events[#events + 1] = event end From d8f4382dd3850550076b33d64a5f455daf7e6450 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 23:06:41 +0200 Subject: [PATCH 137/362] fix(tailwind): nil check for filetypes_include. Fixes #1607 --- lua/lazyvim/plugins/extras/lang/tailwind.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/tailwind.lua b/lua/lazyvim/plugins/extras/lang/tailwind.lua index d7d35963..795449ee 100644 --- a/lua/lazyvim/plugins/extras/lang/tailwind.lua +++ b/lua/lazyvim/plugins/extras/lang/tailwind.lua @@ -27,7 +27,7 @@ return { end, opts.filetypes) -- Add additional filetypes - vim.list_extend(opts.filetypes, opts.filetypes_include) + vim.list_extend(opts.filetypes, opts.filetypes_include or {}) end, }, }, From 8bcc241b720517d4e61fcdd2021d1e39008f5415 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Oct 2023 23:16:59 +0200 Subject: [PATCH 138/362] chore(main): release 9.3.0 (#1603) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca4b160f..cc9c3b5e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## [9.3.0](https://github.com/LazyVim/LazyVim/compare/v9.2.0...v9.3.0) (2023-10-06) + + +### Features + +* **bufremove:** ask to save changes before trying to remove a buffer ([54df3e2](https://github.com/LazyVim/LazyVim/commit/54df3e26aca5c5c4da746f210e6f7e7de30673bb)) + + +### Bug Fixes + +* **tailwind:** nil check for filetypes_include. Fixes [#1607](https://github.com/LazyVim/LazyVim/issues/1607) ([d8f4382](https://github.com/LazyVim/LazyVim/commit/d8f4382dd3850550076b33d64a5f455daf7e6450)) + + +### Performance Improvements + +* **config:** only enable LazyFile when opening a file from the cmdline ([11c9084](https://github.com/LazyVim/LazyVim/commit/11c9084ec576c8735a87550f7975640eb75e6ff7)) + ## [9.2.0](https://github.com/LazyVim/LazyVim/compare/v9.1.1...v9.2.0) (2023-10-06) From fb110e76d86096fd0ad5585537cb7915b6d3cf8d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 6 Oct 2023 23:25:24 +0200 Subject: [PATCH 139/362] docs(conform): conform condition example --- lua/lazyvim/plugins/extras/formatting/conform.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index 44f4ba40..601967c5 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -36,7 +36,7 @@ return { injected = { options = { ignore_errors = true } }, -- -- Example of using dprint only when a dprint.json file is present -- dprint = { - -- condition = function(self, ctx) + -- condition = function(ctx) -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] -- end, -- }, From 0fcdbe20daf44f00252668b3866b19ac18b339df Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 7 Oct 2023 11:18:04 +0200 Subject: [PATCH 140/362] fix(ui): properly handly signs without name. Fixes #1612 --- lua/lazyvim/util/ui.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 1cb3b81d..66ec4bca 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -26,7 +26,7 @@ function M.get_signs(buf, lnum) ) for _, extmark in pairs(extmarks) do signs[#signs + 1] = { - name = extmark[4].sign_hl_group, + name = extmark[4].sign_hl_group or "", text = extmark[4].sign_text, texthl = extmark[4].sign_hl_group, priority = extmark[4].priority, @@ -93,7 +93,7 @@ function M.statuscolumn() ---@type Sign?,Sign?,Sign? local left, right, fold for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do - if s.name:find("GitSign") then + if s.name and s.name:find("GitSign") then right = s else left = s From 75a26e850970cc1b250cd5b5bc471715ca52a0e4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 7 Oct 2023 09:18:48 +0000 Subject: [PATCH 141/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 2497b442..ce460501 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 06 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 07 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 237be9e3a7f5ca8165d4242d47df34d8d407f4cc Mon Sep 17 00:00:00 2001 From: jyuan0 Date: Sat, 7 Oct 2023 05:45:03 -0400 Subject: [PATCH 142/362] fix(rust): explicitly enable nvim-cmp source registration for crates (#1609) --- lua/lazyvim/plugins/extras/lang/rust.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index 699ad563..1e6e0594 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -7,7 +7,11 @@ return { { "Saecki/crates.nvim", event = { "BufRead Cargo.toml" }, - config = true, + opts = { + src = { + cmp = { enabled = true }, + }, + }, }, }, ---@param opts cmp.ConfigSchema From 1935486ff143dd5cf100b8c89204dc01d8e06021 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 7 Oct 2023 15:06:13 +0200 Subject: [PATCH 143/362] fix(treesitter-textobjects): use normal ]c,]C,[c,[C when in diff-mode instead of goto class. Fixes #1610 --- lua/lazyvim/plugins/treesitter.lua | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 753cfb7d..ed8bf964 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -11,16 +11,26 @@ return { { "nvim-treesitter/nvim-treesitter-textobjects", config = function() - -- Disable class keymaps in diff mode - vim.api.nvim_create_autocmd("BufReadPost", { - callback = function(event) - if vim.wo.diff then - for _, key in ipairs({ "[c", "]c", "[C", "]C" }) do - pcall(vim.keymap.del, "n", key, { buffer = event.buf }) + -- When in diff mode, we want to use the default + -- vim text objects c & C instead of the treesitter ones. + local move = require("nvim-treesitter.textobjects.move") ---@type table + local configs = require("nvim-treesitter.configs") + for name, fn in pairs(move) do + if name:find("goto") == 1 then + move[name] = function(q, ...) + if vim.wo.diff then + local config = configs.get_module("textobjects.move")[name] ---@type table + for key, query in pairs(config or {}) do + if q == query and key:find("[%]%[][cC]") then + vim.cmd("normal! " .. key) + return + end + end end + return fn(q, ...) end - end, - }) + end + end end, }, }, From 862e140a7ad8452cd5a103982687fca63a2f44da Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 7 Oct 2023 15:15:33 +0200 Subject: [PATCH 144/362] fix(config): trigger all buf filetype events on LazyFile --- lua/lazyvim/config/init.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 0f4ce24e..39899750 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -172,7 +172,7 @@ function M.lazy_file() Util.track({ event = "LazyVim.lazy_file" }) ---@type table - local skips = { FileType = Event.get_augroups("FileType") } + local skips = {} for _, event in ipairs(events) do skips[event.event] = skips[event.event] or Event.get_augroups(event.event) end @@ -188,7 +188,6 @@ function M.lazy_file() if vim.bo[event.buf].filetype then Event.trigger({ event = "FileType", - exclude = skips.FileType, buf = event.buf, }) end From 8c20e0b5889ed254613dbac26b203130764d9c5f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 7 Oct 2023 15:19:39 +0200 Subject: [PATCH 145/362] chore(main): release 9.3.1 (#1613) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc9c3b5e..40e3dd41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [9.3.1](https://github.com/LazyVim/LazyVim/compare/v9.3.0...v9.3.1) (2023-10-07) + + +### Bug Fixes + +* **config:** trigger all buf filetype events on LazyFile ([862e140](https://github.com/LazyVim/LazyVim/commit/862e140a7ad8452cd5a103982687fca63a2f44da)) +* **rust:** explicitly enable nvim-cmp source registration for crates ([#1609](https://github.com/LazyVim/LazyVim/issues/1609)) ([237be9e](https://github.com/LazyVim/LazyVim/commit/237be9e3a7f5ca8165d4242d47df34d8d407f4cc)) +* **treesitter-textobjects:** use normal ]c,]C,[c,[C when in diff-mode instead of goto class. Fixes [#1610](https://github.com/LazyVim/LazyVim/issues/1610) ([1935486](https://github.com/LazyVim/LazyVim/commit/1935486ff143dd5cf100b8c89204dc01d8e06021)) +* **ui:** properly handly signs without name. Fixes [#1612](https://github.com/LazyVim/LazyVim/issues/1612) ([0fcdbe2](https://github.com/LazyVim/LazyVim/commit/0fcdbe20daf44f00252668b3866b19ac18b339df)) + ## [9.3.0](https://github.com/LazyVim/LazyVim/compare/v9.2.0...v9.3.0) (2023-10-06) From 3c92fa4eb04f827c79c095905ca9391d540fea79 Mon Sep 17 00:00:00 2001 From: Radvil <36059968+radvil@users.noreply.github.com> Date: Sun, 8 Oct 2023 02:42:33 +0800 Subject: [PATCH 146/362] perf(navic): enable lazy_update_context option to update context on "CursorHold" instead of of using default "CursorMove" (#1620) Co-authored-by: Radvil --- lua/lazyvim/plugins/ui.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 1e45b9c4..7782ee69 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -362,6 +362,7 @@ return { highlight = true, depth_limit = 5, icons = require("lazyvim.config").icons.kinds, + lazy_update_context = true, } end, }, From 30d573502a2f9264273a14143e6bddb0b876a391 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 7 Oct 2023 21:07:29 +0200 Subject: [PATCH 147/362] fix(alpha): reset laststatus when alpha unloads. Fixes #1623 --- lua/lazyvim/plugins/ui.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 7782ee69..95c00eaf 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -316,11 +316,13 @@ return { return dashboard end, config = function(_, dashboard) + local laststatus = vim.o.laststatus vim.o.laststatus = 0 -- close Lazy and re-open when the dashboard is ready if vim.o.filetype == "lazy" then vim.cmd.close() vim.api.nvim_create_autocmd("User", { + once = true, pattern = "AlphaReady", callback = function() require("lazy").show() @@ -328,9 +330,18 @@ return { }) end + vim.api.nvim_create_autocmd("BufUnload", { + once = true, + buffer = vim.api.nvim_get_current_buf(), + callback = function() + vim.opt.laststatus = laststatus + end, + }) + require("alpha").setup(dashboard.opts) vim.api.nvim_create_autocmd("User", { + once = true, pattern = "LazyVimStarted", callback = function() local stats = require("lazy").stats() From 9372d78e7e4ed46612de9818868373da81b6f4f1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 7 Oct 2023 21:08:16 +0200 Subject: [PATCH 148/362] feat(nlua): make lua dap keybindings buffer-local --- lua/lazyvim/plugins/extras/dap/nlua.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/dap/nlua.lua b/lua/lazyvim/plugins/extras/dap/nlua.lua index 1d9eb650..21a9e51d 100644 --- a/lua/lazyvim/plugins/extras/dap/nlua.lua +++ b/lua/lazyvim/plugins/extras/dap/nlua.lua @@ -6,8 +6,8 @@ return { "jbyuki/one-small-step-for-vimkind", -- stylua: ignore keys = { - { "daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server" }, - { "dal", function() require("osv").run_this() end, desc = "Adapter Lua" }, + { "daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server", ft = "lua" }, + { "dal", function() require("osv").run_this() end, desc = "Adapter Lua", ft = "lua" }, }, config = function() local dap = require("dap") From af9e4528543d98bccce333d39eccc34e433ef6dc Mon Sep 17 00:00:00 2001 From: Andreas Gerlach Date: Sat, 7 Oct 2023 21:09:36 +0200 Subject: [PATCH 149/362] feat(codeium): add codeium extra (#1619) * [feat] add codeium extension * PR comments --- lua/lazyvim/config/init.lua | 1 + lua/lazyvim/plugins/extras/coding/codeium.lua | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/coding/codeium.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 39899750..61ea1fd9 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -46,6 +46,7 @@ local defaults = { Array = " ", Boolean = " ", Class = " ", + Codeium = " ", Color = " ", Constant = " ", Constructor = " ", diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua new file mode 100644 index 00000000..b55c5274 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -0,0 +1,25 @@ +return { + + -- codeium + { + "Exafunction/codeium.nvim", + cmd = "Codeium", + build = ":Codeium Auth", + opts = {}, + }, + -- codeium cmp source + { + "nvim-cmp", + dependencies = { + { + "Exafunction/codeium.nvim", + }, + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, 1, { name = "codeium", group_index = 2 }) + opts.sorting = opts.sorting or require("cmp.config.default")().sorting + end, + }, + +} From 1bc78272da28821479e98df528d399214a8cdbee Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 10:15:26 +0200 Subject: [PATCH 150/362] feat(keymaps): added support for lazy's per-mode keymap disabling --- lua/lazyvim/config/init.lua | 43 +++++++++++++------ lua/lazyvim/config/keymaps.lua | 10 ++++- lua/lazyvim/plugins/lsp/init.lua | 2 +- lua/lazyvim/plugins/lsp/keymaps.lua | 66 +++++++++++++---------------- 4 files changed, 68 insertions(+), 53 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 61ea1fd9..739d093e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,7 +1,7 @@ ---@class LazyVimConfig: LazyVimOptions local M = {} -M.lazy_version = ">=9.1.0" +M.lazy_version = ">=10.8.0" M.use_lazy_file = true M.lazy_file_events = { "BufReadPost", "BufNewFile" } @@ -92,33 +92,50 @@ M.renames = { ---@type LazyVimOptions local options +---@param lines {[1]:string, [2]:string}[] +function M.msg(lines) + vim.cmd([[clear]]) + vim.api.nvim_echo(lines, true, {}) + vim.fn.getchar() +end + ---@param opts? LazyVimOptions function M.setup(opts) options = vim.tbl_deep_extend("force", defaults, opts or {}) or {} if vim.fn.has("nvim-0.9.0") == 0 then - vim.api.nvim_echo({ + M.msg({ { "LazyVim requires Neovim >= 0.9.0\n", "ErrorMsg", }, { "Press any key to exit", "MoreMsg" }, - }, true, {}) - - vim.fn.getchar() + }) vim.cmd([[quit]]) return end if not M.has() then - require("lazy.core.util").error( - "**LazyVim** needs **lazy.nvim** version " - .. M.lazy_version - .. " to work properly.\n" - .. "Please upgrade **lazy.nvim**", - { title = "LazyVim" } - ) - error("Exiting") + M.msg({ + { + "LazyVim requires lazy.nvim " .. M.lazy_version .. "\n", + "WarningMsg", + }, + { "Press any key to attempt an upgrade", "MoreMsg" }, + }) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + require("lazy").update({ plugins = { "lazy.nvim" }, wait = true }) + M.msg({ + { + "**lazy.nvim** has been upgraded.\nPlease restart **Neovim**", + "WarningMsg", + }, + }) + end, + }) end -- autocmds can be loaded lazily when not opening a file diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index ff4b4af9..375f9775 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -4,14 +4,20 @@ local Util = require("lazyvim.util") local function map(mode, lhs, rhs, opts) local keys = require("lazy.core.handler").handlers.keys ---@cast keys LazyKeysHandler + local modes = type(mode) == "string" and { mode } or mode + + modes = vim.tbl_filter(function(mode) + return not (keys.have and keys:have(lhs, mode)) + end, modes) + -- do not create the keymap if a lazy keys handler exists - if not keys.active[keys.parse({ lhs, mode = mode }).id] then + if #modes > 0 then opts = opts or {} opts.silent = opts.silent ~= false if opts.remap and not vim.g.vscode then opts.remap = nil end - vim.keymap.set(mode, lhs, rhs, opts) + vim.keymap.set(modes, lhs, rhs, opts) end end diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 211385f9..ee8393a0 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -55,7 +55,7 @@ return { -- mason = false, -- set to false if you don't want this server to be installed with mason -- Use this to add any additional keymaps -- for specific lsp servers - ---@type LazyKeys[] + ---@type LazyKeysSpec[] -- keys = {}, settings = { Lua = { diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index 695e6ce8..dd48691a 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -1,12 +1,16 @@ local M = {} ----@type PluginLspKeys +---@type LazyKeysLspSpec[]|nil M._keys = nil ----@return (LazyKeys|{has?:string})[] +---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string} +---@alias LazyKeysLsp LazyKeys|{has?:string} + +---@return LazyKeysLspSpec[] function M.get() - if not M._keys then - ---@class PluginLspKeys + if M._keys then + return M._keys + end -- stylua: ignore M._keys = { { "cd", vim.diagnostic.open_float, desc = "Line Diagnostics" }, @@ -42,20 +46,19 @@ function M.get() has = "codeAction", } } - if require("lazyvim.util").has("inc-rename.nvim") then - M._keys[#M._keys + 1] = { - "cr", - function() - local inc_rename = require("inc_rename") - return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") - end, - expr = true, - desc = "Rename", - has = "rename", - } - else - M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } - end + if require("lazyvim.util").has("inc-rename.nvim") then + M._keys[#M._keys + 1] = { + "cr", + function() + local inc_rename = require("inc_rename") + return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") + end, + expr = true, + desc = "Rename", + has = "rename", + } + else + M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } end return M._keys end @@ -72,34 +75,23 @@ function M.has(buffer, method) return false end +---@return (LazyKeys|{has?:string})[] function M.resolve(buffer) local Keys = require("lazy.core.handler.keys") - local keymaps = {} ---@type table - - local function add(keymap) - local keys = Keys.parse(keymap) - if keys[2] == false then - keymaps[keys.id] = nil - else - keymaps[keys.id] = keys - end + if not Keys.resolve then + return {} end - for _, keymap in ipairs(M.get()) do - add(keymap) - end - + local spec = M.get() local opts = require("lazyvim.util").opts("nvim-lspconfig") local clients = vim.lsp.get_active_clients({ bufnr = buffer }) for _, client in ipairs(clients) do local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} - for _, keymap in ipairs(maps) do - add(keymap) - end + vim.list_extend(spec, maps) end - return keymaps + return Keys.resolve(spec) end -function M.on_attach(client, buffer) +function M.on_attach(_, buffer) local Keys = require("lazy.core.handler.keys") local keymaps = M.resolve(buffer) @@ -110,7 +102,7 @@ function M.on_attach(client, buffer) opts.has = nil opts.silent = opts.silent ~= false opts.buffer = buffer - vim.keymap.set(keys.mode or "n", keys[1], keys[2], opts) + vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts) end end end From 89d0805fb817b2089c567603fc2cf93afed0912f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 8 Oct 2023 08:16:15 +0000 Subject: [PATCH 151/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index ce460501..d29b094b 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 07 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 08 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 0cdc23a51d928202fecf7ff3c8da7dc62c6a501d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 10:17:20 +0200 Subject: [PATCH 152/362] chore(main): release 9.4.0 (#1622) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40e3dd41..ea72c8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [9.4.0](https://github.com/LazyVim/LazyVim/compare/v9.3.1...v9.4.0) (2023-10-08) + + +### Features + +* **codeium:** add codeium extra ([#1619](https://github.com/LazyVim/LazyVim/issues/1619)) ([af9e452](https://github.com/LazyVim/LazyVim/commit/af9e4528543d98bccce333d39eccc34e433ef6dc)) +* **keymaps:** added support for lazy's per-mode keymap disabling ([1bc7827](https://github.com/LazyVim/LazyVim/commit/1bc78272da28821479e98df528d399214a8cdbee)) +* **nlua:** make lua dap keybindings buffer-local ([9372d78](https://github.com/LazyVim/LazyVim/commit/9372d78e7e4ed46612de9818868373da81b6f4f1)) + + +### Bug Fixes + +* **alpha:** reset laststatus when alpha unloads. Fixes [#1623](https://github.com/LazyVim/LazyVim/issues/1623) ([30d5735](https://github.com/LazyVim/LazyVim/commit/30d573502a2f9264273a14143e6bddb0b876a391)) + + +### Performance Improvements + +* **navic:** enable lazy_update_context option to update context on "CursorHold" instead of of using default "CursorMove" ([#1620](https://github.com/LazyVim/LazyVim/issues/1620)) ([3c92fa4](https://github.com/LazyVim/LazyVim/commit/3c92fa4eb04f827c79c095905ca9391d540fea79)) + ## [9.3.1](https://github.com/LazyVim/LazyVim/compare/v9.3.0...v9.3.1) (2023-10-07) From 25f3587f3f158cb878537112934c7a410d358583 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 10:27:59 +0200 Subject: [PATCH 153/362] refactor(keymaps): move safe keymap.set wrapper to util and add message not to use it in a personal config --- lua/lazyvim/config/keymaps.lua | 22 +++------------------- lua/lazyvim/util/init.lua | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 375f9775..e8307f45 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -1,25 +1,9 @@ -- This file is automatically loaded by lazyvim.config.init local Util = require("lazyvim.util") -local function map(mode, lhs, rhs, opts) - local keys = require("lazy.core.handler").handlers.keys - ---@cast keys LazyKeysHandler - local modes = type(mode) == "string" and { mode } or mode - - modes = vim.tbl_filter(function(mode) - return not (keys.have and keys:have(lhs, mode)) - end, modes) - - -- do not create the keymap if a lazy keys handler exists - if #modes > 0 then - opts = opts or {} - opts.silent = opts.silent ~= false - if opts.remap and not vim.g.vscode then - opts.remap = nil - end - vim.keymap.set(modes, lhs, rhs, opts) - end -end +-- DO NOT USE THIS IN YOU OWN CONFIG!! +-- use `vim.keymap.set` instead +local map = Util.safe_keymap_set -- better up/down map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 2a2f69f3..cd92ac70 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -320,4 +320,27 @@ function M.on_rename(from, to) end end +-- Wrapper around vim.keymap.set that will +-- not create a keymap if a lazy key handler exists. +-- It will also set `silent` to true by default. +function M.safe_keymap_set(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + ---@cast keys LazyKeysHandler + local modes = type(mode) == "string" and { mode } or mode + + modes = vim.tbl_filter(function(mode) + return not (keys.have and keys:have(lhs, mode)) + end, modes) + + -- do not create the keymap if a lazy keys handler exists + if #modes > 0 then + opts = opts or {} + opts.silent = opts.silent ~= false + if opts.remap and not vim.g.vscode then + opts.remap = nil + end + vim.keymap.set(modes, lhs, rhs, opts) + end +end + return M From 21ee35f7108f4eefbce84d88a002572b168fc357 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 10:44:17 +0200 Subject: [PATCH 154/362] fix(util): fixed lsp willRenameFiles support check --- lua/lazyvim/util/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index cd92ac70..cceca322 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -304,7 +304,7 @@ end function M.on_rename(from, to) local clients = vim.lsp.get_active_clients() for _, client in ipairs(clients) do - if client:supports_method("workspace/willRenameFiles") then + if client.supports_method("workspace/willRenameFiles") then local resp = client.request_sync("workspace/willRenameFiles", { files = { { From 6b837e9165a02a334259b87fd251d617cffd9cdc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 10:45:38 +0200 Subject: [PATCH 155/362] style: lua annotations and handle deprecated methods --- lua/lazyvim/plugins/lsp/format.lua | 2 +- lua/lazyvim/plugins/lsp/keymaps.lua | 5 ++--- lua/lazyvim/util/init.lua | 26 +++++++++++++++++--------- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua index 7d1c9109..f507a38a 100644 --- a/lua/lazyvim/plugins/lsp/format.lua +++ b/lua/lazyvim/plugins/lsp/format.lua @@ -82,7 +82,7 @@ function M.get_formatters(bufnr) } ---@type lsp.Client[] - local clients = vim.lsp.get_active_clients({ bufnr = bufnr }) + local clients = require("lazyvim.util").get_clients({ bufnr = bufnr }) for _, client in ipairs(clients) do if M.supports_format(client) then if (#null_ls > 0 and client.name == "null-ls") or #null_ls == 0 then diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index dd48691a..ad05b334 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -66,7 +66,7 @@ end ---@param method string function M.has(buffer, method) method = method:find("/") and method or "textDocument/" .. method - local clients = vim.lsp.get_active_clients({ bufnr = buffer }) + local clients = require("lazyvim.util").get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do if client.supports_method(method) then return true @@ -83,7 +83,7 @@ function M.resolve(buffer) end local spec = M.get() local opts = require("lazyvim.util").opts("nvim-lspconfig") - local clients = vim.lsp.get_active_clients({ bufnr = buffer }) + local clients = require("lazyvim.util").get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} vim.list_extend(spec, maps) @@ -98,7 +98,6 @@ function M.on_attach(_, buffer) for _, keys in pairs(keymaps) do if not keys.has or M.has(buffer, keys.has) then local opts = Keys.opts(keys) - ---@diagnostic disable-next-line: no-unknown opts.has = nil opts.silent = opts.silent ~= false opts.buffer = buffer diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index cceca322..ff01a3d0 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -8,7 +8,7 @@ M.root_patterns = { ".git", "lua" } function M.on_attach(on_attach) vim.api.nvim_create_autocmd("LspAttach", { callback = function(args) - local buffer = args.buf + local buffer = args.buf ---@type number local client = vim.lsp.get_client_by_id(args.data.client_id) on_attach(client, buffer) end, @@ -22,9 +22,11 @@ end function M.fg(name) ---@type {foreground?:number}? + ---@diagnostic disable-next-line: deprecated local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) - local fg = hl and hl.fg or hl.foreground - return fg and { fg = string.format("#%06x", fg) } + ---@diagnostic disable-next-line: undefined-field + local fg = hl and (hl.fg or hl.foreground) + return fg and { fg = string.format("#%06x", fg) } or nil end ---@param fn fun() @@ -47,6 +49,8 @@ function M.opts(name) return Plugin.values(plugin, "opts", false) end +M.get_clients = vim.lsp.get_clients or vim.lsp_get_active_clients + -- returns the root directory based on: -- * lsp workspace folders -- * lsp root_dir @@ -60,7 +64,7 @@ function M.get_root() ---@type string[] local roots = {} if path then - for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do + for _, client in pairs(M.get_clients({ bufnr = 0 })) do local workspace = client.config.workspace_folders local paths = workspace and vim.tbl_map(function(ws) return vim.uri_to_fname(ws.uri) @@ -227,7 +231,7 @@ function M.lazy_notify() vim.notify = temp local timer = vim.loop.new_timer() - local check = vim.loop.new_check() + local check = assert(vim.loop.new_check()) local replay = function() timer:stop() @@ -253,6 +257,7 @@ function M.lazy_notify() timer:start(500, 0, replay) end +---@return _.lspconfig.options function M.lsp_get_config(server) local configs = require("lspconfig.configs") return rawget(configs, server) @@ -263,6 +268,7 @@ end function M.lsp_disable(server, cond) local util = require("lspconfig.util") local def = M.lsp_get_config(server) + ---@diagnostic disable-next-line: undefined-field def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir) if cond(root_dir, config) then config.enabled = false @@ -302,9 +308,10 @@ end ---@param from string ---@param to string function M.on_rename(from, to) - local clients = vim.lsp.get_active_clients() + local clients = M.get_clients() for _, client in ipairs(clients) do if client.supports_method("workspace/willRenameFiles") then + ---@diagnostic disable-next-line: invisible local resp = client.request_sync("workspace/willRenameFiles", { files = { { @@ -312,7 +319,7 @@ function M.on_rename(from, to) newUri = vim.uri_from_fname(to), }, }, - }, 1000) + }, 1000, 0) if resp and resp.result ~= nil then vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) end @@ -328,8 +335,9 @@ function M.safe_keymap_set(mode, lhs, rhs, opts) ---@cast keys LazyKeysHandler local modes = type(mode) == "string" and { mode } or mode - modes = vim.tbl_filter(function(mode) - return not (keys.have and keys:have(lhs, mode)) + ---@param m string + modes = vim.tbl_filter(function(m) + return not (keys.have and keys:have(lhs, m)) end, modes) -- do not create the keymap if a lazy keys handler exists From 4e0a05808cb0997e0ac7d939421f68e9dfa5d74d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 11:33:03 +0200 Subject: [PATCH 156/362] fix(config): dont append LazyVim early to the rtp when bootstrapping --- lua/lazyvim/config/init.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 739d093e..0fb7ad67 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -268,7 +268,10 @@ M.did_init = false function M.init() if not M.did_init then M.did_init = true - vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir) + local plugin = require("lazy.core.config").spec.plugins.LazyVim + if plugin then + vim.opt.rtp:append(plugin.dir) + end M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field From 6e3fb589d5aeb12f46fedf70dcd8c14e21afb8cf Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 11:42:13 +0200 Subject: [PATCH 157/362] chore(main): release 9.4.1 (#1628) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea72c8e6..0683eac8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [9.4.1](https://github.com/LazyVim/LazyVim/compare/v9.4.0...v9.4.1) (2023-10-08) + + +### Bug Fixes + +* **config:** dont append LazyVim early to the rtp when bootstrapping ([4e0a058](https://github.com/LazyVim/LazyVim/commit/4e0a05808cb0997e0ac7d939421f68e9dfa5d74d)) +* **util:** fixed lsp willRenameFiles support check ([21ee35f](https://github.com/LazyVim/LazyVim/commit/21ee35f7108f4eefbce84d88a002572b168fc357)) + ## [9.4.0](https://github.com/LazyVim/LazyVim/compare/v9.3.1...v9.4.0) (2023-10-08) From c9bbb922e58b223d49785cddbed2feeea536237e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 12:37:59 +0200 Subject: [PATCH 158/362] feat(treesitter): add diff, jsonc and yaml by default --- lua/lazyvim/plugins/treesitter.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index ed8bf964..65b84c17 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -46,10 +46,12 @@ return { ensure_installed = { "bash", "c", + "diff", "html", "javascript", "jsdoc", "json", + "jsonc", "lua", "luadoc", "luap", @@ -58,6 +60,7 @@ return { "python", "query", "regex", + "toml", "tsx", "typescript", "vim", From eebdceca1723801e1889d2a65bd676d17139fc6c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 12:55:50 +0200 Subject: [PATCH 159/362] fix(util): fixup typo vim.lsp.get_active_clients --- lua/lazyvim/util/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index ff01a3d0..12b3c409 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -49,7 +49,7 @@ function M.opts(name) return Plugin.values(plugin, "opts", false) end -M.get_clients = vim.lsp.get_clients or vim.lsp_get_active_clients +M.get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients -- returns the root directory based on: -- * lsp workspace folders From 80e66963431e235baea04998384c41b0244c1f7e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 12:58:53 +0200 Subject: [PATCH 160/362] chore(main): release 9.5.0 (#1631) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0683eac8..02bfe9b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [9.5.0](https://github.com/LazyVim/LazyVim/compare/v9.4.1...v9.5.0) (2023-10-08) + + +### Features + +* **treesitter:** add diff, jsonc and yaml by default ([c9bbb92](https://github.com/LazyVim/LazyVim/commit/c9bbb922e58b223d49785cddbed2feeea536237e)) + + +### Bug Fixes + +* **util:** fixup typo vim.lsp.get_active_clients ([eebdcec](https://github.com/LazyVim/LazyVim/commit/eebdceca1723801e1889d2a65bd676d17139fc6c)) + ## [9.4.1](https://github.com/LazyVim/LazyVim/compare/v9.4.0...v9.4.1) (2023-10-08) From 639a6e7545830602c09711b3757a28537baf8e75 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 13:45:54 +0200 Subject: [PATCH 161/362] feat(extra): add extra `util.dot` that configures multiple ft and treesitter langs when needed --- lua/lazyvim/plugins/extras/util/dot.lua | 62 +++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/util/dot.lua diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua new file mode 100644 index 00000000..159c9421 --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -0,0 +1,62 @@ +---@type string +local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config" + +---@param path string +local function have(path) + return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil +end + +return { + + -- Add Hyprland Parser + { + "luckasRanarison/tree-sitter-hypr", + enabled = have("hypr"), + event = "BufRead */hypr/*.conf", + config = function() + -- Fix ft detection for hyprland + vim.filetype.add({ + pattern = { [".*/hypr/.*%.conf"] = "hypr" }, + }) + require("nvim-treesitter.parsers").get_parser_configs().hypr = { + install_info = { + url = "https://github.com/luckasRanarison/tree-sitter-hypr", + files = { "src/parser.c" }, + branch = "master", + }, + filetype = "hypr", + } + end, + }, + + -- add some stuff to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + local function add(lang) + if type(opts.ensure_installed) ~= "table" then + table.insert(opts.ensure_installed, lang) + end + end + + vim.filetype.add({ + extension = { rasi = "rasi" }, + pattern = { + [".*/waybar/config"] = "jsonc", + [".*/mako/config"] = "dosini", + [".*/kitty/*.conf"] = "bash", + }, + }) + + add("git_config") + + if have("fish") then + add("fish") + end + + if have("rofi") or have("wofi") then + add("rasi") + end + end, + }, +} From e11a3cbe800a1216062f7cefd25827f6fdad9daa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 15:17:50 +0200 Subject: [PATCH 162/362] fix(config): trigger LazyFile additionally on BufWritePre for saving unnamed files --- lua/lazyvim/config/init.lua | 2 +- lua/lazyvim/plugins/treesitter.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 0fb7ad67..9afe1c5a 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local M = {} M.lazy_version = ">=10.8.0" M.use_lazy_file = true -M.lazy_file_events = { "BufReadPost", "BufNewFile" } +M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" } ---@class LazyVimOptions local defaults = { diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 65b84c17..c06adbf0 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -40,6 +40,7 @@ return { { "", desc = "Decrement selection", mode = "x" }, }, ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields opts = { highlight = { enable = true }, indent = { enable = true }, From 33c677a55e97ee115ad7050856856df7cd96b3e1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 19:29:00 +0200 Subject: [PATCH 163/362] fix(yaml): yaml schemas are a dict, not a list, so merge properly. Fixes #1636 --- lua/lazyvim/plugins/extras/lang/yaml.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 51f3d824..fdfba404 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -35,8 +35,11 @@ return { }, -- lazy-load schemastore when needed on_new_config = function(new_config) - new_config.settings.yaml.schemas = new_config.settings.yaml.schemas or {} - vim.list_extend(new_config.settings.yaml.schemas, require("schemastore").yaml.schemas()) + new_config.settings.yaml.schemas = vim.tbl_deep_extend( + "force", + new_config.settings.yaml.schemas or {}, + require("schemastore").yaml.schemas() + ) end, settings = { redhat = { telemetry = { enabled = false } }, From 3f67ac3c739968f85ff0293666fc75f61ecffb5e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Oct 2023 19:53:20 +0200 Subject: [PATCH 164/362] chore(main): release 9.6.0 (#1632) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02bfe9b1..174f4466 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [9.6.0](https://github.com/LazyVim/LazyVim/compare/v9.5.0...v9.6.0) (2023-10-08) + + +### Features + +* **extra:** add extra `util.dot` that configures multiple ft and treesitter langs when needed ([639a6e7](https://github.com/LazyVim/LazyVim/commit/639a6e7545830602c09711b3757a28537baf8e75)) + + +### Bug Fixes + +* **config:** trigger LazyFile additionally on BufWritePre for saving unnamed files ([e11a3cb](https://github.com/LazyVim/LazyVim/commit/e11a3cbe800a1216062f7cefd25827f6fdad9daa)) +* **yaml:** yaml schemas are a dict, not a list, so merge properly. Fixes [#1636](https://github.com/LazyVim/LazyVim/issues/1636) ([33c677a](https://github.com/LazyVim/LazyVim/commit/33c677a55e97ee115ad7050856856df7cd96b3e1)) + ## [9.5.0](https://github.com/LazyVim/LazyVim/compare/v9.4.1...v9.5.0) (2023-10-08) From 1eac633c4f0621d5bd07db1ab7d563db5b342e82 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 20:22:47 +0200 Subject: [PATCH 165/362] perf(util): closure for get_clients to prevent loading vim.lsp cascade early --- lua/lazyvim/util/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 12b3c409..ffa6df47 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -3,6 +3,10 @@ local Util = require("lazy.core.util") local M = {} M.root_patterns = { ".git", "lua" } +function M.get_clients(...) + local fn = vim.lsp.get_clients or vim.lsp.get_active_clients + return fn(...) +end ---@param on_attach fun(client, buffer) function M.on_attach(on_attach) @@ -49,8 +53,6 @@ function M.opts(name) return Plugin.values(plugin, "opts", false) end -M.get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients - -- returns the root directory based on: -- * lsp workspace folders -- * lsp root_dir From 51e25a94b4ff2339028bdded993756360145d1b3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 20:23:22 +0200 Subject: [PATCH 166/362] fix(plugins): make sure init specs are loaded first --- lua/lazyvim/plugins/{core.lua => init.lua} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename lua/lazyvim/plugins/{core.lua => init.lua} (100%) diff --git a/lua/lazyvim/plugins/core.lua b/lua/lazyvim/plugins/init.lua similarity index 100% rename from lua/lazyvim/plugins/core.lua rename to lua/lazyvim/plugins/init.lua From 502d32490b29e7f52b2941cfa6a306b45633d63e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 20:23:49 +0200 Subject: [PATCH 167/362] fix(options): set sessionoptions the same as persistence --- lua/lazyvim/config/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index de54693f..2e7e07c9 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -24,7 +24,7 @@ opt.pumblend = 10 -- Popup blend opt.pumheight = 10 -- Maximum number of entries in a popup opt.relativenumber = true -- Relative line numbers opt.scrolloff = 4 -- Lines of context -opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } +opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" } opt.shiftround = true -- Round indent opt.shiftwidth = 2 -- Size of an indent opt.shortmess:append({ W = true, I = true, c = true, C = true }) From de93848f584b3443204247f49b405b81b0a3d4c1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 22:32:03 +0200 Subject: [PATCH 168/362] fix(cmp): properly set cmp `group_index` to fix issues with copilot and other sources (#1639) --- lua/lazyvim/plugins/coding.lua | 12 ++++++------ lua/lazyvim/plugins/extras/coding/codeium.lua | 3 +-- lua/lazyvim/plugins/extras/coding/copilot.lua | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 122187f8..511a3e7f 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -67,12 +67,12 @@ return { select = true, }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "path" }, - }), + sources = { + { name = "nvim_lsp", group_index = 1 }, + { name = "luasnip", group_index = 1 }, + { name = "buffer", group_index = 2 }, + { name = "path", group_index = 2 }, + }, formatting = { format = function(_, item) local icons = require("lazyvim.config").icons.kinds diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index b55c5274..823568d3 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -17,9 +17,8 @@ return { }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - table.insert(opts.sources, 1, { name = "codeium", group_index = 2 }) + table.insert(opts.sources, 1, { name = "codeium", group_index = 1 }) opts.sorting = opts.sorting or require("cmp.config.default")().sorting end, }, - } diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index bed0d4e9..61989a0c 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -70,7 +70,7 @@ return { }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - table.insert(opts.sources, 1, { name = "copilot", group_index = 2 }) + table.insert(opts.sources, 1, { name = "copilot", group_index = 1 }) opts.sorting = opts.sorting or require("cmp.config.default")().sorting table.insert(opts.sorting.comparators, 1, require("copilot_cmp.comparators").prioritize) end, From 5219cad564152337d5d48572466ac976f300a557 Mon Sep 17 00:00:00 2001 From: Markis Taylor Date: Sun, 8 Oct 2023 16:34:06 -0400 Subject: [PATCH 169/362] feat(black): added an extra for black with none-ls & conform.nvim (#1245) * feat(black): added an extra for black with null-ls * fix: update to none-ls/conform --- .../plugins/extras/formatting/black.lua | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/formatting/black.lua diff --git a/lua/lazyvim/plugins/extras/formatting/black.lua b/lua/lazyvim/plugins/extras/formatting/black.lua new file mode 100644 index 00000000..d153be53 --- /dev/null +++ b/lua/lazyvim/plugins/extras/formatting/black.lua @@ -0,0 +1,25 @@ +return { + { + "williamboman/mason.nvim", + opts = function(_, opts) + table.insert(opts.ensure_installed, "black") + end, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + table.insert(opts.sources, nls.builtins.formatting.black) + end, + }, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + ["python"] = { { "blackd", "black" } }, + }, + }, + }, +} From 838ce85ad6ae2dc2fa1d7518b0c5eb1eb8fe29b2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 22:59:50 +0200 Subject: [PATCH 170/362] fix(bufferline): fix bufferline when restoring a session --- lua/lazyvim/plugins/ui.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 95c00eaf..1d954484 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -82,6 +82,17 @@ return { }, }, }, + config = function(_, opts) + require("bufferline").setup(opts) + -- Fix bufferline when restoring a session + vim.api.nvim_create_autocmd("BufAdd", { + callback = function() + vim.schedule(function() + pcall(nvim_bufferline) + end) + end, + }) + end, }, -- statusline From dd55cbdc99021267bee8260c224582a053552dfe Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 8 Oct 2023 23:27:46 +0200 Subject: [PATCH 171/362] fix(lualine): only show statusline as soon as lualine loads --- lua/lazyvim/plugins/extras/ui/dashboard.lua | 6 ++++++ lua/lazyvim/plugins/ui.lua | 16 ++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua index cf7c8860..23d208e6 100644 --- a/lua/lazyvim/plugins/extras/ui/dashboard.lua +++ b/lua/lazyvim/plugins/extras/ui/dashboard.lua @@ -18,6 +18,11 @@ return { local opts = { theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, config = { header = vim.split(logo, "\n"), center = { @@ -52,6 +57,7 @@ return { end, }) end + return opts end, }, diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 1d954484..bec52d69 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -99,10 +99,16 @@ return { { "nvim-lualine/lualine.nvim", event = "VeryLazy", + init = function() + vim.g.lualine_laststatus = vim.o.laststatus + vim.o.laststatus = 0 + end, opts = function() local icons = require("lazyvim.config").icons local Util = require("lazyvim.util") + vim.o.laststatus = vim.g.lualine_laststatus + return { options = { theme = "auto", @@ -327,8 +333,6 @@ return { return dashboard end, config = function(_, dashboard) - local laststatus = vim.o.laststatus - vim.o.laststatus = 0 -- close Lazy and re-open when the dashboard is ready if vim.o.filetype == "lazy" then vim.cmd.close() @@ -341,14 +345,6 @@ return { }) end - vim.api.nvim_create_autocmd("BufUnload", { - once = true, - buffer = vim.api.nvim_get_current_buf(), - callback = function() - vim.opt.laststatus = laststatus - end, - }) - require("alpha").setup(dashboard.opts) vim.api.nvim_create_autocmd("User", { From eddd3af3512133f22eb26dda81c3c6f871453276 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 00:06:58 +0200 Subject: [PATCH 172/362] feat(cmp): added custom comparator to prioritize AI sources like copilot and codeium --- lua/lazyvim/plugins/coding.lua | 20 +++++++++++++++++++ lua/lazyvim/plugins/extras/coding/codeium.lua | 2 +- lua/lazyvim/plugins/extras/coding/copilot.lua | 3 +-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 511a3e7f..8ef48f16 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -45,6 +45,26 @@ return { vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") local defaults = require("cmp.config.default")() + + -- LazyVim extension to prioritise certain sources + defaults.sorting.primary = {} + + ---@param entry Cmp.Entry + local function is_primary(entry) + local config = require("cmp.config").global + return vim.tbl_contains(config.sorting.primary or {}, entry.source:get_debug_name()) + end + + table.insert(defaults.sorting.comparators, 1, function(a, b) + local aa = is_primary(a) + local bb = is_primary(b) + if aa and not bb then + return true + end + if not aa and bb then + return false + end + end) return { completion = { completeopt = "menu,menuone,noinsert", diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index 823568d3..13f43cc0 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -18,7 +18,7 @@ return { ---@param opts cmp.ConfigSchema opts = function(_, opts) table.insert(opts.sources, 1, { name = "codeium", group_index = 1 }) - opts.sorting = opts.sorting or require("cmp.config.default")().sorting + table.insert(opts.sorting.primary, "codeium") end, }, } diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 61989a0c..16534f79 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -71,8 +71,7 @@ return { ---@param opts cmp.ConfigSchema opts = function(_, opts) table.insert(opts.sources, 1, { name = "copilot", group_index = 1 }) - opts.sorting = opts.sorting or require("cmp.config.default")().sorting - table.insert(opts.sorting.comparators, 1, require("copilot_cmp.comparators").prioritize) + table.insert(opts.sorting.primary, "copilot") end, }, } From 302c1ff66e5b1d7bbe95f29e81c2d642e2cd4468 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 08:25:02 +0200 Subject: [PATCH 173/362] feat(codeium): use actual codeium icon --- lua/lazyvim/config/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 9afe1c5a..8d01fef4 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -46,7 +46,7 @@ local defaults = { Array = " ", Boolean = " ", Class = " ", - Codeium = " ", + Codeium = "󰘦 ", Color = " ", Constant = " ", Constructor = " ", From bff3a996971c1f526eb893d8e778daa19a4245b5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 09:12:29 +0200 Subject: [PATCH 174/362] feat(cmp): removed priority comparator in favor of source priorities for copilot/codeium --- lua/lazyvim/plugins/coding.lua | 20 ------------------- lua/lazyvim/plugins/extras/coding/codeium.lua | 19 +++++++++--------- lua/lazyvim/plugins/extras/coding/copilot.lua | 7 +++++-- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 8ef48f16..511a3e7f 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -45,26 +45,6 @@ return { vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") local defaults = require("cmp.config.default")() - - -- LazyVim extension to prioritise certain sources - defaults.sorting.primary = {} - - ---@param entry Cmp.Entry - local function is_primary(entry) - local config = require("cmp.config").global - return vim.tbl_contains(config.sorting.primary or {}, entry.source:get_debug_name()) - end - - table.insert(defaults.sorting.comparators, 1, function(a, b) - local aa = is_primary(a) - local bb = is_primary(b) - if aa and not bb then - return true - end - if not aa and bb then - return false - end - end) return { completion = { completeopt = "menu,menuone,noinsert", diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index 13f43cc0..d809ab85 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -1,24 +1,25 @@ return { - -- codeium - { - "Exafunction/codeium.nvim", - cmd = "Codeium", - build = ":Codeium Auth", - opts = {}, - }, -- codeium cmp source { "nvim-cmp", dependencies = { + -- codeium { "Exafunction/codeium.nvim", + cmd = "Codeium", + build = ":Codeium Auth", + opts = {}, }, }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - table.insert(opts.sources, 1, { name = "codeium", group_index = 1 }) - table.insert(opts.sorting.primary, "codeium") + table.insert(opts.sources, 1, { + name = "codeium", + group_index = 1, + priority = 100, + }) end, }, + } diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 16534f79..708446ed 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -70,8 +70,11 @@ return { }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - table.insert(opts.sources, 1, { name = "copilot", group_index = 1 }) - table.insert(opts.sorting.primary, "copilot") + table.insert(opts.sources, 1, { + name = "copilot", + group_index = 1, + priority = 100, + }) end, }, } From 22271cdbbc80277d0fff4ef1b5af41e17c7957de Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 09:12:48 +0200 Subject: [PATCH 175/362] refactor(copilot): dont use deprecated get_clients --- lua/lazyvim/plugins/extras/coding/copilot.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 708446ed..38630917 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -33,7 +33,13 @@ return { return icon .. (status.message or "") end, cond = function() - local ok, clients = pcall(vim.lsp.get_active_clients, { name = "copilot", bufnr = 0 }) + if not package.loaded["copilot"] then + return + end + local ok, clients = pcall(require("lazyvim.util").get_clients, { name = "copilot", bufnr = 0 }) + if not ok then + return false + end return ok and #clients > 0 end, color = function() From b05783de8c518c8a6e5c3f648448c3a6f00d0050 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 09:13:14 +0200 Subject: [PATCH 176/362] feat(codeium): added lualine component with codeium status similar to copilot --- lua/lazyvim/plugins/extras/coding/codeium.lua | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index d809ab85..f8d4c671 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -22,4 +22,48 @@ return { end, }, + { + "nvim-lualine/lualine.nvim", + optional = true, + event = "VeryLazy", + opts = function(_, opts) + local started = false + local function status() + if not package.loaded["cmp"] then + return + end + for _, s in ipairs(require("cmp").core.sources) do + if s.name == "codeium" then + if s.source:is_available() then + started = true + else + return started and "error" or nil + end + if s.status == s.SourceStatus.FETCHING then + return "pending" + end + return "ok" + end + end + end + + local Util = require("lazyvim.util") + local colors = { + ok = Util.fg("Special"), + error = Util.fg("DiagnosticError"), + pending = Util.fg("DiagnosticWarn"), + } + table.insert(opts.sections.lualine_x, 2, { + function() + return require("lazyvim.config").icons.kinds.Codeium + end, + cond = function() + return status() ~= nil + end, + color = function() + return colors[status()] or colors.ok + end, + }) + end, + }, } From cc8397ade365b9e9c4f41d071be5c72ede919409 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 9 Oct 2023 07:14:25 +0000 Subject: [PATCH 177/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index d29b094b..ba1cbc6c 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 08 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 09 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 177985842665921e11f9e9813348fd6bef852e27 Mon Sep 17 00:00:00 2001 From: jyuan0 Date: Mon, 9 Oct 2023 03:15:15 -0400 Subject: [PATCH 178/362] fix(black): remove unknown blackd from conform (#1640) --- lua/lazyvim/plugins/extras/formatting/black.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/formatting/black.lua b/lua/lazyvim/plugins/extras/formatting/black.lua index d153be53..bfa383a8 100644 --- a/lua/lazyvim/plugins/extras/formatting/black.lua +++ b/lua/lazyvim/plugins/extras/formatting/black.lua @@ -18,7 +18,7 @@ return { optional = true, opts = { formatters_by_ft = { - ["python"] = { { "blackd", "black" } }, + ["python"] = { "black" }, }, }, }, From efbe4e57937f8540f0cc69bab0bdffec18338e02 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 9 Oct 2023 09:18:33 +0200 Subject: [PATCH 179/362] chore(main): release 9.7.0 (#1638) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 174f4466..1c7d4e4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # Changelog +## [9.7.0](https://github.com/LazyVim/LazyVim/compare/v9.6.0...v9.7.0) (2023-10-09) + + +### Features + +* **black:** added an extra for black with none-ls & conform.nvim ([#1245](https://github.com/LazyVim/LazyVim/issues/1245)) ([5219cad](https://github.com/LazyVim/LazyVim/commit/5219cad564152337d5d48572466ac976f300a557)) +* **cmp:** added custom comparator to prioritize AI sources like copilot and codeium ([eddd3af](https://github.com/LazyVim/LazyVim/commit/eddd3af3512133f22eb26dda81c3c6f871453276)) +* **cmp:** removed priority comparator in favor of source priorities for copilot/codeium ([bff3a99](https://github.com/LazyVim/LazyVim/commit/bff3a996971c1f526eb893d8e778daa19a4245b5)) +* **codeium:** added lualine component with codeium status similar to copilot ([b05783d](https://github.com/LazyVim/LazyVim/commit/b05783de8c518c8a6e5c3f648448c3a6f00d0050)) +* **codeium:** use actual codeium icon ([302c1ff](https://github.com/LazyVim/LazyVim/commit/302c1ff66e5b1d7bbe95f29e81c2d642e2cd4468)) + + +### Bug Fixes + +* **black:** remove unknown blackd from conform ([#1640](https://github.com/LazyVim/LazyVim/issues/1640)) ([1779858](https://github.com/LazyVim/LazyVim/commit/177985842665921e11f9e9813348fd6bef852e27)) +* **bufferline:** fix bufferline when restoring a session ([838ce85](https://github.com/LazyVim/LazyVim/commit/838ce85ad6ae2dc2fa1d7518b0c5eb1eb8fe29b2)) +* **cmp:** properly set cmp `group_index` to fix issues with copilot and other sources ([#1639](https://github.com/LazyVim/LazyVim/issues/1639)) ([de93848](https://github.com/LazyVim/LazyVim/commit/de93848f584b3443204247f49b405b81b0a3d4c1)) +* **lualine:** only show statusline as soon as lualine loads ([dd55cbd](https://github.com/LazyVim/LazyVim/commit/dd55cbdc99021267bee8260c224582a053552dfe)) +* **options:** set sessionoptions the same as persistence ([502d324](https://github.com/LazyVim/LazyVim/commit/502d32490b29e7f52b2941cfa6a306b45633d63e)) +* **plugins:** make sure init specs are loaded first ([51e25a9](https://github.com/LazyVim/LazyVim/commit/51e25a94b4ff2339028bdded993756360145d1b3)) + + +### Performance Improvements + +* **util:** closure for get_clients to prevent loading vim.lsp cascade early ([1eac633](https://github.com/LazyVim/LazyVim/commit/1eac633c4f0621d5bd07db1ab7d563db5b342e82)) + ## [9.6.0](https://github.com/LazyVim/LazyVim/compare/v9.5.0...v9.6.0) (2023-10-08) From d894556c375c1c2398f170c21f9323c9c1eba9d4 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 09:51:53 +0200 Subject: [PATCH 180/362] feat(cmp): ctrl+CR will abort cmp and enter a new line --- lua/lazyvim/plugins/coding.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 511a3e7f..c6515802 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -66,6 +66,10 @@ return { behavior = cmp.ConfirmBehavior.Replace, select = true, }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = function(fallback) + cmp.abort() + fallback() + end, }), sources = { { name = "nvim_lsp", group_index = 1 }, From 0a05888d992b37749f9aae25c7f63f2534ec1024 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 10:05:57 +0200 Subject: [PATCH 181/362] fix(cmp): set default group_index to 1 to prevent issues with custom sources --- lua/lazyvim/plugins/coding.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index c6515802..c6571433 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -71,12 +71,13 @@ return { fallback() end, }), - sources = { - { name = "nvim_lsp", group_index = 1 }, - { name = "luasnip", group_index = 1 }, - { name = "buffer", group_index = 2 }, - { name = "path", group_index = 2 }, - }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + }, { + { name = "buffer" }, + }), formatting = { format = function(_, item) local icons = require("lazyvim.config").icons.kinds @@ -94,6 +95,13 @@ return { sorting = defaults.sorting, } end, + ---@param opts cmp.ConfigSchema + config = function(_, opts) + for _, source in ipairs(opts.sources) do + source.group_index = source.group_index or 1 + end + require("cmp").setup(opts) + end, }, -- auto pairs From 4fe7ccae73b0924b48dd16d26bb1f89a643adc54 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 11:34:23 +0200 Subject: [PATCH 182/362] build(format): sort requires --- stylua.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stylua.toml b/stylua.toml index 5d6c50dc..9732fe64 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,3 +1,6 @@ indent_type = "Spaces" indent_width = 2 -column_width = 120 \ No newline at end of file +column_width = 120 +[sort_requires] +enabled = true + From 2c658a374dc9f25ff779605e62572b09130f4801 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 11:34:58 +0200 Subject: [PATCH 183/362] style(cmp): dont include cmp-nvim-lsp as a dep of lspconfig --- lua/lazyvim/plugins/lsp/init.lua | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index ee8393a0..bdef1a74 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -8,12 +8,6 @@ return { { "folke/neodev.nvim", opts = {} }, "mason.nvim", "williamboman/mason-lspconfig.nvim", - { - "hrsh7th/cmp-nvim-lsp", - cond = function() - return require("lazyvim.util").has("nvim-cmp") - end, - }, }, ---@class PluginLspOpts opts = { From 2abb5907efe1dbb6da731a907dd4555958eb91c7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 12:49:09 +0200 Subject: [PATCH 184/362] style(config): added tracking for colorscheme --- lua/lazyvim/config/init.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 8d01fef4..c0319dcf 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,3 +1,5 @@ +local Util = require("lazy.core.util") + ---@class LazyVimConfig: LazyVimOptions local M = {} @@ -160,7 +162,8 @@ function M.setup(opts) M.lazy_file() end - require("lazy.core.util").try(function() + Util.track("colorscheme") + Util.try(function() if type(M.colorscheme) == "function" then M.colorscheme() else @@ -169,10 +172,11 @@ function M.setup(opts) end, { msg = "Could not load your colorscheme", on_error = function(msg) - require("lazy.core.util").error(msg) + Util.error(msg) vim.cmd.colorscheme("habamax") end, }) + Util.track() end -- Properly load file based plugins without blocking the UI @@ -184,7 +188,6 @@ function M.lazy_file() return end local Event = require("lazy.core.handler.event") - local Util = require("lazy.core.util") vim.api.nvim_del_augroup_by_name("lazy_file") Util.track({ event = "LazyVim.lazy_file" }) @@ -236,7 +239,6 @@ end ---@param name "autocmds" | "options" | "keymaps" function M.load(name) - local Util = require("lazy.core.util") local function _load(mod) Util.try(function() require(mod) @@ -290,7 +292,7 @@ function M.init() Plugin.Spec.add = function(self, plugin, ...) if type(plugin) == "table" then if M.renames[plugin[1]] then - require("lazy.core.util").warn( + Util.warn( ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( plugin[1], M.renames[plugin[1]], From 9670c8a400100d38e15c9662f488232508bfb1bb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 12:49:33 +0200 Subject: [PATCH 185/362] feat(dashboard): show loaded/count plugins on dashboard instead of just count --- lua/lazyvim/plugins/extras/ui/dashboard.lua | 2 +- lua/lazyvim/plugins/ui.lua | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua index 23d208e6..2c678f36 100644 --- a/lua/lazyvim/plugins/extras/ui/dashboard.lua +++ b/lua/lazyvim/plugins/extras/ui/dashboard.lua @@ -38,7 +38,7 @@ return { footer = function() local stats = require("lazy").stats() local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" } + return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } end, }, } diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index bec52d69..d4e8859b 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -353,7 +353,13 @@ return { callback = function() local stats = require("lazy").stats() local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" + dashboard.section.footer.val = "⚡ Neovim loaded " + .. stats.loaded + .. "/" + .. stats.count + .. " plugins in " + .. ms + .. "ms" pcall(vim.cmd.AlphaRedraw) end, }) From 6b857f1de648292f2410f9beaa95318bd30454d5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 17:49:00 +0200 Subject: [PATCH 186/362] feat(options): set `virtualedit=block` by default --- lua/lazyvim/config/options.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 2e7e07c9..f110f7fb 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -43,6 +43,7 @@ opt.timeoutlen = 300 opt.undofile = true opt.undolevels = 10000 opt.updatetime = 200 -- Save swap file and trigger CursorHold +opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode opt.wildmode = "longest:full,full" -- Command-line completion mode opt.winminwidth = 5 -- Minimum window width opt.wrap = false -- Disable line wrap From 5d44c976a746e29cfe52ceab93dd3de5db2eafa8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 20:11:05 +0200 Subject: [PATCH 187/362] fix(autocmds): extra check that we didn't do last_loc more than once for the buffer --- lua/lazyvim/config/autocmds.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 7d9feedd..9f4344cf 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -34,9 +34,10 @@ vim.api.nvim_create_autocmd("BufReadPost", { callback = function(event) local exclude = { "gitcommit" } local buf = event.buf - if vim.tbl_contains(exclude, vim.bo[buf].filetype) then + if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then return end + vim.b[buf].lazyvim_last_loc = true local mark = vim.api.nvim_buf_get_mark(buf, '"') local lcount = vim.api.nvim_buf_line_count(buf) if mark[1] > 0 and mark[1] <= lcount then From c0ce89fe62bffc0fe35bf76d3e5f501c8b5276c2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 20:11:45 +0200 Subject: [PATCH 188/362] feat(telescope): smarter way to determine the window to open a file in --- lua/lazyvim/plugins/editor.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index c26d00d5..93864953 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -201,6 +201,19 @@ return { defaults = { prompt_prefix = " ", selection_caret = " ", + -- open files in the first window that is an actual file. + -- use the current window if no other window is available. + get_selection_window = function() + local wins = vim.api.nvim_list_wins() + table.insert(wins, 1, vim.api.nvim_get_current_win()) + for _, win in ipairs(wins) do + local buf = vim.api.nvim_win_get_buf(win) + if vim.bo[buf].buftype == "" then + return win + end + end + return 0 + end, mappings = { i = { [""] = open_with_trouble, From fb7017005809d6be06a1ece748ef2406c37a34d9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 20:12:07 +0200 Subject: [PATCH 189/362] feat(edgy): when edgy is enabled, use edgy's main window for Telescope to open results in --- lua/lazyvim/plugins/extras/ui/edgy.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index fdc0d330..5d6eb9d8 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -118,6 +118,19 @@ return { end, }, + -- use edgy's selection window + { + "nvim-telescope/telescope.nvim", + opts = { + defaults = { + get_selecition_window = function() + require("edgy").goto_main() + return 0 + end, + }, + }, + }, + -- prevent neo-tree from opening files in edgy windows { "nvim-neo-tree/neo-tree.nvim", From 9357ea2881fdd57b028256597c01e15601c29aaf Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 20:12:45 +0200 Subject: [PATCH 190/362] fix(edgy): typo --- lua/lazyvim/plugins/extras/ui/edgy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 5d6eb9d8..2e0db1c1 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -123,7 +123,7 @@ return { "nvim-telescope/telescope.nvim", opts = { defaults = { - get_selecition_window = function() + get_selection_window = function() require("edgy").goto_main() return 0 end, From 9a4b9aa804cfa2c112b1ef50c68936421995b048 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 20:16:02 +0200 Subject: [PATCH 191/362] refactor(edgy): make telescope optional --- lua/lazyvim/plugins/extras/ui/edgy.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 2e0db1c1..8692d481 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -121,6 +121,7 @@ return { -- use edgy's selection window { "nvim-telescope/telescope.nvim", + optional = true, opts = { defaults = { get_selection_window = function() From 4e8a88fc1f28d0420aa3badb703296f344d89968 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 22:09:39 +0200 Subject: [PATCH 192/362] fix(util): dont schedule on_load --- lua/lazyvim/util/init.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index ffa6df47..05bc8154 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -283,9 +283,7 @@ end function M.on_load(name, fn) local Config = require("lazy.core.config") if Config.plugins[name] and Config.plugins[name]._.loaded then - vim.schedule(function() - fn(name) - end) + fn(name) else vim.api.nvim_create_autocmd("User", { pattern = "LazyLoad", From 0955129796749651e1413006e36e9a1c6d3027f3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 22:11:17 +0200 Subject: [PATCH 193/362] fix(project): make sure to load telescope extension after telescope ran setup --- lua/lazyvim/plugins/extras/util/project.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index d6be2b9c..0800e5d5 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -9,7 +9,9 @@ return { event = "VeryLazy", config = function(_, opts) require("project_nvim").setup(opts) - require("telescope").load_extension("projects") + require("lazyvim.util").on_load("telescope.nvim", function() + require("telescope").load_extension("projects") + end) end, keys = { { "fp", "Telescope projects", desc = "Projects" }, From 44984dcbe25c13e0e1bc582d5a51ccc2a4be8f70 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 22:28:09 +0200 Subject: [PATCH 194/362] feat(telescope): add telescope-fzf-native by default. Will only be enabled if `make` is on your system. --- lua/lazyvim/plugins/editor.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 93864953..e8df2e0b 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -100,6 +100,18 @@ return { "nvim-telescope/telescope.nvim", cmd = "Telescope", version = false, -- telescope did only one release, so use HEAD for now + dependencies = { + { + "nvim-telescope/telescope-fzf-native.nvim", + build = "make", + enabled = vim.fn.executable("make") == 1, + config = function() + Util.on_load("telescope.nvim", function() + require("telescope").load_extension("fzf") + end) + end, + }, + }, keys = { { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, From 02bc41412a14c1c0bb823421ef82ff5596f42571 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 9 Oct 2023 23:32:34 +0200 Subject: [PATCH 195/362] fix(telescope): remove telescope folding hack since PR with fix has been merged upstream --- lua/lazyvim/config/autocmds.lua | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 9f4344cf..4cc6f1ec 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -92,16 +92,3 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") end, }) - --- HACK: re-caclulate folds when entering a buffer through Telescope --- @see https://github.com/nvim-telescope/telescope.nvim/issues/699 -vim.api.nvim_create_autocmd("BufEnter", { - group = augroup("fix_folds"), - callback = function() - if vim.opt.foldmethod:get() == "expr" then - vim.schedule(function() - vim.opt.foldmethod = "expr" - end) - end - end, -}) From 23a0004a86071164e66b76c32459c9b45b0d1e3e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 00:13:40 +0200 Subject: [PATCH 196/362] chore(main): release 9.8.0 (#1642) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c7d4e4d..7f9d136f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [9.8.0](https://github.com/LazyVim/LazyVim/compare/v9.7.0...v9.8.0) (2023-10-09) + + +### Features + +* **cmp:** ctrl+CR will abort cmp and enter a new line ([d894556](https://github.com/LazyVim/LazyVim/commit/d894556c375c1c2398f170c21f9323c9c1eba9d4)) +* **dashboard:** show loaded/count plugins on dashboard instead of just count ([9670c8a](https://github.com/LazyVim/LazyVim/commit/9670c8a400100d38e15c9662f488232508bfb1bb)) +* **edgy:** when edgy is enabled, use edgy's main window for Telescope to open results in ([fb70170](https://github.com/LazyVim/LazyVim/commit/fb7017005809d6be06a1ece748ef2406c37a34d9)) +* **options:** set `virtualedit=block` by default ([6b857f1](https://github.com/LazyVim/LazyVim/commit/6b857f1de648292f2410f9beaa95318bd30454d5)) +* **telescope:** add telescope-fzf-native by default. Will only be enabled if `make` is on your system. ([44984dc](https://github.com/LazyVim/LazyVim/commit/44984dcbe25c13e0e1bc582d5a51ccc2a4be8f70)) +* **telescope:** smarter way to determine the window to open a file in ([c0ce89f](https://github.com/LazyVim/LazyVim/commit/c0ce89fe62bffc0fe35bf76d3e5f501c8b5276c2)) + + +### Bug Fixes + +* **autocmds:** extra check that we didn't do last_loc more than once for the buffer ([5d44c97](https://github.com/LazyVim/LazyVim/commit/5d44c976a746e29cfe52ceab93dd3de5db2eafa8)) +* **cmp:** set default group_index to 1 to prevent issues with custom sources ([0a05888](https://github.com/LazyVim/LazyVim/commit/0a05888d992b37749f9aae25c7f63f2534ec1024)) +* **edgy:** typo ([9357ea2](https://github.com/LazyVim/LazyVim/commit/9357ea2881fdd57b028256597c01e15601c29aaf)) +* **project:** make sure to load telescope extension after telescope ran setup ([0955129](https://github.com/LazyVim/LazyVim/commit/0955129796749651e1413006e36e9a1c6d3027f3)) +* **telescope:** remove telescope folding hack since PR with fix has been merged upstream ([02bc414](https://github.com/LazyVim/LazyVim/commit/02bc41412a14c1c0bb823421ef82ff5596f42571)) +* **util:** dont schedule on_load ([4e8a88f](https://github.com/LazyVim/LazyVim/commit/4e8a88fc1f28d0420aa3badb703296f344d89968)) + ## [9.7.0](https://github.com/LazyVim/LazyVim/compare/v9.6.0...v9.7.0) (2023-10-09) From 88d465c3efac065f912e1de162c9a48bbae15316 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 07:51:00 +0200 Subject: [PATCH 197/362] fix(hypr): automatically update/install hypr treesitter parser when needed --- lua/lazyvim/plugins/extras/util/dot.lua | 1 + lua/lazyvim/plugins/treesitter.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index 159c9421..6dda53d3 100644 --- a/lua/lazyvim/plugins/extras/util/dot.lua +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -13,6 +13,7 @@ return { "luckasRanarison/tree-sitter-hypr", enabled = have("hypr"), event = "BufRead */hypr/*.conf", + build = ":TSUpdate hypr", config = function() -- Fix ft detection for hyprland vim.filetype.add({ diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index c06adbf0..68161f6c 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -34,7 +34,7 @@ return { end, }, }, - cmd = { "TSUpdateSync" }, + cmd = { "TSUpdateSync", "TSUdate", "TSIntsall" }, keys = { { "", desc = "Increment selection" }, { "", desc = "Decrement selection", mode = "x" }, From 4719dadfdad49fdfbbb592434e17b5802d1c21c4 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 10 Oct 2023 05:51:42 +0000 Subject: [PATCH 198/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index ba1cbc6c..4bf837e5 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 09 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 10 ============================================================================== Table of Contents *LazyVim-table-of-contents* From b1c9fd15bdbc0bae5bf1ba1efd88ce7355e7f2c1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 11:05:57 +0200 Subject: [PATCH 199/362] feat(dap): added run with args `leader-ca`. Fixes #1629 --- lua/lazyvim/plugins/extras/dap/core.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index 3b623df5..1f079630 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -1,3 +1,14 @@ +---@param config {args?:string[]|fun():string[]?} +local function get_args(config) + local args = type(config.args) == "function" and (config.args() or {}) or config.args or {} + ---@cast args string[] + config.args = function() + local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]] + return vim.split(vim.fn.expand(new_args) --[[@as string]], " ") + end + return config +end + return { "mfussenegger/nvim-dap", @@ -76,6 +87,7 @@ return { { "dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" }, { "db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, { "dc", function() require("dap").continue() end, desc = "Continue" }, + { "da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" }, { "dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" }, { "dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" }, { "di", function() require("dap").step_into() end, desc = "Step Into" }, From 599798a366d5fead7e8486e1b02dd2362d2e6bd1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 11:07:58 +0200 Subject: [PATCH 200/362] fix(treesitter): typo with commands --- lua/lazyvim/plugins/treesitter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 68161f6c..47e58f1d 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -34,7 +34,7 @@ return { end, }, }, - cmd = { "TSUpdateSync", "TSUdate", "TSIntsall" }, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, keys = { { "", desc = "Increment selection" }, { "", desc = "Decrement selection", mode = "x" }, From e8c26c70e27d468cec11926890105d61f99f9218 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 11:54:33 +0200 Subject: [PATCH 201/362] refactor(eslint): use util.get_clients instead of deprecated method --- lua/lazyvim/plugins/extras/linting/eslint.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/linting/eslint.lua b/lua/lazyvim/plugins/extras/linting/eslint.lua index 32498cb5..1fea3c8c 100644 --- a/lua/lazyvim/plugins/extras/linting/eslint.lua +++ b/lua/lazyvim/plugins/extras/linting/eslint.lua @@ -21,7 +21,7 @@ return { return end - local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1] + local client = require("lazyvim.util").get_clients({ bufnr = event.buf, name = "eslint" })[1] if client then local diag = vim.diagnostic.get(event.buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) }) if #diag > 0 then From 28b7a5add22a2f94dc75ba9f99fdc0c0bbd63d66 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:39:44 +0200 Subject: [PATCH 202/362] chore(main): release 9.9.0 (#1648) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f9d136f..0163c09c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [9.9.0](https://github.com/LazyVim/LazyVim/compare/v9.8.0...v9.9.0) (2023-10-10) + + +### Features + +* **dap:** added run with args `leader-ca`. Fixes [#1629](https://github.com/LazyVim/LazyVim/issues/1629) ([b1c9fd1](https://github.com/LazyVim/LazyVim/commit/b1c9fd15bdbc0bae5bf1ba1efd88ce7355e7f2c1)) + + +### Bug Fixes + +* **hypr:** automatically update/install hypr treesitter parser when needed ([88d465c](https://github.com/LazyVim/LazyVim/commit/88d465c3efac065f912e1de162c9a48bbae15316)) +* **treesitter:** typo with commands ([599798a](https://github.com/LazyVim/LazyVim/commit/599798a366d5fead7e8486e1b02dd2362d2e6bd1)) + ## [9.8.0](https://github.com/LazyVim/LazyVim/compare/v9.7.0...v9.8.0) (2023-10-09) From 8e88aa51f4d104e9da4ced0b4e9ae05d91565a36 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 11 Oct 2023 12:42:26 +0000 Subject: [PATCH 203/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 4bf837e5..a950794a 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 10 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 11 ============================================================================== Table of Contents *LazyVim-table-of-contents* From ee7a401388f2933729afcd7090fb8e69631b912f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 14:46:05 +0200 Subject: [PATCH 204/362] fix(config): disable LazyFile till v10.0 --- lua/lazyvim/config/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index c0319dcf..d993ac19 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -278,6 +278,7 @@ function M.init() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil + M.use_lazy_file = false -- disablle for now till v10.0 -- delay notifications till vim.notify was replaced or after 500ms require("lazyvim.util").lazy_notify() @@ -314,6 +315,7 @@ function M.init() events[#events + 1] = event end end + plugin.event = events end end end From 61f1c308bf6b87c51a2b49c314c7c7379f19a27e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 11 Oct 2023 15:00:18 +0200 Subject: [PATCH 205/362] chore(main): release 9.9.1 (#1661) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0163c09c..c1136f07 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [9.9.1](https://github.com/LazyVim/LazyVim/compare/v9.9.0...v9.9.1) (2023-10-11) + + +### Bug Fixes + +* **config:** disable LazyFile till v10.0 ([ee7a401](https://github.com/LazyVim/LazyVim/commit/ee7a401388f2933729afcd7090fb8e69631b912f)) + ## [9.9.0](https://github.com/LazyVim/LazyVim/compare/v9.8.0...v9.9.0) (2023-10-10) From 5f5acb5b88789f4eae4781d3bf2ab52f880b3b86 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 14:56:29 +0200 Subject: [PATCH 206/362] Revert "fix(config): disable LazyFile till v10.0" This reverts commit ee7a401388f2933729afcd7090fb8e69631b912f. --- lua/lazyvim/config/init.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index d993ac19..c0319dcf 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -278,7 +278,6 @@ function M.init() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil - M.use_lazy_file = false -- disablle for now till v10.0 -- delay notifications till vim.notify was replaced or after 500ms require("lazyvim.util").lazy_notify() @@ -315,7 +314,6 @@ function M.init() events[#events + 1] = event end end - plugin.event = events end end end From c8c929c9fdc44cc69cb034c47bd89d2bc4e4a429 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 19:29:24 +0200 Subject: [PATCH 207/362] perf(util): split lazyvim.util in smaller separate modules --- lua/lazyvim/config/init.lua | 27 +- lua/lazyvim/config/keymaps.lua | 12 +- lua/lazyvim/config/options.lua | 4 +- lua/lazyvim/plugins/editor.lua | 6 +- lua/lazyvim/plugins/extras/coding/codeium.lua | 6 +- lua/lazyvim/plugins/extras/coding/copilot.lua | 12 +- .../plugins/extras/editor/mini-files.lua | 2 +- lua/lazyvim/plugins/extras/lang/go.lua | 2 +- lua/lazyvim/plugins/extras/lang/python.lua | 2 +- lua/lazyvim/plugins/extras/lang/yaml.lua | 2 +- lua/lazyvim/plugins/lsp/init.lua | 13 +- lua/lazyvim/plugins/lsp/keymaps.lua | 4 +- lua/lazyvim/plugins/ui.lua | 12 +- lua/lazyvim/util/init.lua | 280 +++--------------- lua/lazyvim/util/lsp.lua | 112 +++++++ lua/lazyvim/util/root.lua | 49 +++ lua/lazyvim/util/telescope.lua | 53 ++++ lua/lazyvim/util/terminal.lua | 55 ++++ lua/lazyvim/util/toggle.lua | 62 ++++ lua/lazyvim/util/ui.lua | 10 + 20 files changed, 442 insertions(+), 283 deletions(-) create mode 100644 lua/lazyvim/util/lsp.lua create mode 100644 lua/lazyvim/util/root.lua create mode 100644 lua/lazyvim/util/telescope.lua create mode 100644 lua/lazyvim/util/terminal.lua create mode 100644 lua/lazyvim/util/toggle.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index c0319dcf..23ca90d4 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,4 +1,4 @@ -local Util = require("lazy.core.util") +local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} @@ -155,6 +155,7 @@ function M.setup(opts) M.load("autocmds") end M.load("keymaps") + Util.format.setup() end, }) @@ -240,18 +241,11 @@ end ---@param name "autocmds" | "options" | "keymaps" function M.load(name) local function _load(mod) - Util.try(function() - require(mod) - end, { - msg = "Failed loading " .. mod, - on_error = function(msg) - local info = require("lazy.core.cache").find(mod) - if info == nil or (type(info) == "table" and #info == 0) then - return - end - Util.error(msg) - end, - }) + if require("lazy.core.cache").find(mod)[1] then + Util.try(function() + require(mod) + end, { msg = "Failed loading " .. mod }) + end end -- always load lazyvim, then user file if M.defaults[name] or name == "options" then @@ -275,6 +269,11 @@ function M.init() vim.opt.rtp:append(plugin.dir) end + package.preload["lazyvim.plugins.lsp.format"] = function() + Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) + return Util.format + end + M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil @@ -285,7 +284,7 @@ function M.init() -- load options here, before lazy init while sourcing plugin modules -- this is needed to make sure options will be correctly applied -- after installing missing plugins - require("lazyvim.config").load("options") + M.load("options") local Plugin = require("lazy.core.plugin") local add = Plugin.Spec.add ---@diagnostic disable-next-line: duplicate-set-field diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index e8307f45..b60aa43e 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -105,8 +105,8 @@ map("n", "uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "T map("n", "us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) map("n", "uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) -map("n", "ul", function() Util.toggle_number() end, { desc = "Toggle Line Numbers" }) -map("n", "ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" }) +map("n", "ul", function() Util.toggle.number() end, { desc = "Toggle Line Numbers" }) +map("n", "ud", function() Util.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 map("n", "uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) if vim.lsp.inlay_hint then @@ -114,8 +114,8 @@ if vim.lsp.inlay_hint then end -- lazygit -map("n", "gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) -map("n", "gG", function() Util.float_term({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) +map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root.get(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) +map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) -- quit map("n", "qq", "qa", { desc = "Quit all" }) @@ -127,9 +127,9 @@ map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) map("n", "L", Util.changelog, {desc = "LazyVim Changelog"}) -- floating terminal -local lazyterm = function() Util.float_term(nil, { cwd = Util.get_root() }) end +local lazyterm = function() Util.terminal(nil, { cwd = Util.root.get() }) end map("n", "ft", lazyterm, { desc = "Terminal (root dir)" }) -map("n", "fT", function() Util.float_term() end, { desc = "Terminal (cwd)" }) +map("n", "fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) map("n", "", lazyterm, { desc = "Terminal (root dir)" }) map("n", "", lazyterm, { desc = "which_key_ignore" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index f110f7fb..e2ae9485 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -63,10 +63,10 @@ end -- Folding vim.opt.foldlevel = 99 -vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()" +vim.opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()" if vim.fn.has("nvim-0.9.0") == 1 then - vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]] + vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]] end -- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index e8df2e0b..0fb63944 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -11,7 +11,7 @@ return { { "fe", function() - require("neo-tree.command").execute({ toggle = true, dir = require("lazyvim.util").get_root() }) + require("neo-tree.command").execute({ toggle = true, dir = Util.root.get() }) end, desc = "Explorer NeoTree (root dir)", }, @@ -60,7 +60,7 @@ return { }, config = function(_, opts) local function on_move(data) - Util.on_rename(data.source, data.destination) + Util.lsp.on_rename(data.source, data.destination) end local events = require("neo-tree.events") @@ -270,7 +270,7 @@ return { "nvim-telescope/telescope.nvim", optional = true, opts = function(_, opts) - if not require("lazyvim.util").has("flash.nvim") then + if not Util.has("flash.nvim") then return end local function flash(prompt_bufnr) diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index f8d4c671..457535cd 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -49,9 +49,9 @@ return { local Util = require("lazyvim.util") local colors = { - ok = Util.fg("Special"), - error = Util.fg("DiagnosticError"), - pending = Util.fg("DiagnosticWarn"), + ok = Util.ui.fg("Special"), + error = Util.ui.fg("DiagnosticError"), + pending = Util.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, 2, { function() diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 38630917..279a974f 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -21,10 +21,10 @@ return { opts = function(_, opts) local Util = require("lazyvim.util") local colors = { - [""] = Util.fg("Special"), - ["Normal"] = Util.fg("Special"), - ["Warning"] = Util.fg("DiagnosticError"), - ["InProgress"] = Util.fg("DiagnosticWarn"), + [""] = Util.ui.fg("Special"), + ["Normal"] = Util.ui.fg("Special"), + ["Warning"] = Util.ui.fg("DiagnosticError"), + ["InProgress"] = Util.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, 2, { function() @@ -36,7 +36,7 @@ return { if not package.loaded["copilot"] then return end - local ok, clients = pcall(require("lazyvim.util").get_clients, { name = "copilot", bufnr = 0 }) + local ok, clients = pcall(require("lazyvim.util").lsp.get_clients, { name = "copilot", bufnr = 0 }) if not ok then return false end @@ -66,7 +66,7 @@ return { copilot_cmp.setup(opts) -- attach cmp source whenever copilot attaches -- fixes lazy-loading issues with the copilot cmp source - require("lazyvim.util").on_attach(function(client) + require("lazyvim.util").lsp.on_attach(function(client) if client.name == "copilot" then copilot_cmp._on_insert_enter({}) end diff --git a/lua/lazyvim/plugins/extras/editor/mini-files.lua b/lua/lazyvim/plugins/extras/editor/mini-files.lua index c3ddd273..55fc768c 100644 --- a/lua/lazyvim/plugins/extras/editor/mini-files.lua +++ b/lua/lazyvim/plugins/extras/editor/mini-files.lua @@ -57,7 +57,7 @@ return { vim.api.nvim_create_autocmd("User", { pattern = "MiniFilesActionRename", callback = function(event) - require("lazyvim.util").on_rename(event.data.from, event.data.to) + require("lazyvim.util").lsp.on_rename(event.data.from, event.data.to) end, }) end, diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index b9966b7e..39410353 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -61,7 +61,7 @@ return { gopls = function(_, opts) -- workaround for gopls not supporting semanticTokensProvider -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 - require("lazyvim.util").on_attach(function(client, _) + require("lazyvim.util").lsp.on_attach(function(client, _) if client.name == "gopls" then if not client.server_capabilities.semanticTokensProvider then local semantic = client.config.capabilities.textDocument.semanticTokens diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index ff4267fb..835c9da8 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -16,7 +16,7 @@ return { }, setup = { ruff_lsp = function() - require("lazyvim.util").on_attach(function(client, _) + require("lazyvim.util").lsp.on_attach(function(client, _) if client.name == "ruff_lsp" then -- Disable hover in favor of Pyright client.server_capabilities.hoverProvider = false diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index fdfba404..5afe1b83 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -64,7 +64,7 @@ return { yamlls = function() -- Neovim < 0.10 does not have dynamic registration for formatting if vim.fn.has("nvim-0.10") == 0 then - require("lazyvim.util").on_attach(function(client, _) + require("lazyvim.util").lsp.on_attach(function(client, _) if client.name == "yamlls" then client.server_capabilities.documentFormattingProvider = true end diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index bdef1a74..f18eed4f 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -1,3 +1,5 @@ +local Util = require("lazyvim.util") + return { -- lspconfig { @@ -88,6 +90,8 @@ return { require("lazyvim.plugins.lsp.format").setup(opts) -- setup formatting and keymaps Util.on_attach(function(client, buffer) + -- setup keymaps + Util.lsp.on_attach(function(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) end) @@ -112,7 +116,7 @@ return { local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint if opts.inlay_hints.enabled and inlay_hint then - Util.on_attach(function(client, buffer) + Util.lsp.on_attach(function(client, buffer) if client.supports_method("textDocument/inlayHint") then inlay_hint(buffer, true) end @@ -184,10 +188,10 @@ return { mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) end - if Util.lsp_get_config("denols") and Util.lsp_get_config("tsserver") then + if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") - Util.lsp_disable("tsserver", is_deno) - Util.lsp_disable("denols", function(root_dir) + Util.lsp.disable("tsserver", is_deno) + Util.lsp.disable("denols", function(root_dir) return not is_deno(root_dir) end) end @@ -208,7 +212,6 @@ return { nls.builtins.diagnostics.fish, nls.builtins.formatting.stylua, nls.builtins.formatting.shfmt, - -- nls.builtins.diagnostics.flake8, }, } end, diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index ad05b334..7b9c2189 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -66,7 +66,7 @@ end ---@param method string function M.has(buffer, method) method = method:find("/") and method or "textDocument/" .. method - local clients = require("lazyvim.util").get_clients({ bufnr = buffer }) + local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do if client.supports_method(method) then return true @@ -83,7 +83,7 @@ function M.resolve(buffer) end local spec = M.get() local opts = require("lazyvim.util").opts("nvim-lspconfig") - local clients = require("lazyvim.util").get_clients({ bufnr = buffer }) + local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} vim.list_extend(spec, maps) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index d4e8859b..f1bac031 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -141,21 +141,21 @@ return { { function() return require("noice").api.status.command.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, - color = Util.fg("Statement"), + color = Util.ui.fg("Statement"), }, -- stylua: ignore { function() return require("noice").api.status.mode.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, - color = Util.fg("Constant"), + color = Util.ui.fg("Constant"), }, -- stylua: ignore { function() return " " .. require("dap").status() end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = Util.fg("Debug"), + color = Util.ui.fg("Debug"), }, - { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.fg("Special") }, + { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.ui.fg("Special") }, { "diff", symbols = { @@ -374,8 +374,8 @@ return { lazy = true, init = function() vim.g.navic_silence = true - require("lazyvim.util").on_attach(function(client, buffer) - if client.server_capabilities.documentSymbolProvider then + require("lazyvim.util").lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/documentSymbol") then require("nvim-navic").attach(client, buffer) end end) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 05bc8154..146e73e2 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -1,38 +1,54 @@ -local Util = require("lazy.core.util") +local LazyUtil = require("lazy.core.util") +---@class lazyvim.util: LazyUtilCore +---@field ui lazyvim.util.ui +---@field lsp lazyvim.util.lsp +---@field root lazyvim.util.root +---@field telescope lazyvim.util.telescope +---@field terminal lazyvim.util.terminal +---@field toggle lazyvim.util.toggle +---@field format lazyvim.util.format local M = {} -M.root_patterns = { ".git", "lua" } -function M.get_clients(...) - local fn = vim.lsp.get_clients or vim.lsp.get_active_clients - return fn(...) -end +---@type table +local deprecated = { + get_clients = "lsp", + on_attach = "lsp", + on_rename = "lsp", + root_patterns = { "root", "patterns" }, + get_root = { "root", "get" }, + float_term = { "terminal", "open" }, + toggle = { "toggle", "option" }, + toggle_diagnostics = { "toggle", "diagnostics" }, + toggle_number = { "toggle", "number" }, + fg = "ui", +} ----@param on_attach fun(client, buffer) -function M.on_attach(on_attach) - vim.api.nvim_create_autocmd("LspAttach", { - callback = function(args) - local buffer = args.buf ---@type number - local client = vim.lsp.get_client_by_id(args.data.client_id) - on_attach(client, buffer) - end, - }) -end +setmetatable(M, { + __index = function(t, k) + if LazyUtil[k] then + return LazyUtil[k] + end + local dep = deprecated[k] + if dep then + local mod = type(dep) == "table" and dep[1] or dep + local key = type(dep) == "table" and dep[2] or k + M.deprecate([[require("lazyvim.util").]] .. k, [[require("lazyvim.util").]] .. mod .. "." .. key) + ---@diagnostic disable-next-line: no-unknown + t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops + return t[mod][key] + end + ---@diagnostic disable-next-line: no-unknown + t[k] = require("lazyvim.util." .. k) + return t[k] + end, +}) ---@param plugin string function M.has(plugin) return require("lazy.core.config").spec.plugins[plugin] ~= nil end -function M.fg(name) - ---@type {foreground?:number}? - ---@diagnostic disable-next-line: deprecated - local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) - ---@diagnostic disable-next-line: undefined-field - local fg = hl and (hl.fg or hl.foreground) - return fg and { fg = string.format("#%06x", fg) } or nil -end - ---@param fn fun() function M.on_very_lazy(fn) vim.api.nvim_create_autocmd("User", { @@ -53,173 +69,13 @@ function M.opts(name) return Plugin.values(plugin, "opts", false) end --- returns the root directory based on: --- * lsp workspace folders --- * lsp root_dir --- * root pattern of filename of the current buffer --- * root pattern of cwd ----@return string -function M.get_root() - ---@type string? - local path = vim.api.nvim_buf_get_name(0) - path = path ~= "" and vim.loop.fs_realpath(path) or nil - ---@type string[] - local roots = {} - if path then - for _, client in pairs(M.get_clients({ bufnr = 0 })) do - local workspace = client.config.workspace_folders - local paths = workspace and vim.tbl_map(function(ws) - return vim.uri_to_fname(ws.uri) - end, workspace) or client.config.root_dir and { client.config.root_dir } or {} - for _, p in ipairs(paths) do - local r = vim.loop.fs_realpath(p) - if path:find(r, 1, true) then - roots[#roots + 1] = r - end - end - end - end - table.sort(roots, function(a, b) - return #a > #b - end) - ---@type string? - local root = roots[1] - if not root then - path = path and vim.fs.dirname(path) or vim.loop.cwd() - ---@type string? - root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1] - root = root and vim.fs.dirname(root) or vim.loop.cwd() - end - ---@cast root string - return root -end - --- this will return a function that calls telescope. --- cwd will default to lazyvim.util.get_root --- for `files`, git_files or find_files will be chosen depending on .git -function M.telescope(builtin, opts) - local params = { builtin = builtin, opts = opts } - return function() - builtin = params.builtin - opts = params.opts - opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) - if builtin == "files" then - if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then - opts.show_untracked = true - builtin = "git_files" - else - builtin = "find_files" - end - end - if opts.cwd and opts.cwd ~= vim.loop.cwd() then - opts.attach_mappings = function(_, map) - map("i", "", function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - M.telescope( - params.builtin, - vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line }) - )() - end) - return true - end - end - - require("telescope.builtin")[builtin](opts) - end -end - ----@type table -local terminals = {} - --- Opens a floating terminal (interactive by default) ----@param cmd? string[]|string ----@param opts? LazyCmdOptions|{interactive?:boolean, esc_esc?:false, ctrl_hjkl?:false} -function M.float_term(cmd, opts) - opts = vim.tbl_deep_extend("force", { - ft = "lazyterm", - size = { width = 0.9, height = 0.9 }, - }, opts or {}, { persistent = true }) - ---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false} - - local termkey = vim.inspect({ cmd = cmd or "shell", cwd = opts.cwd, env = opts.env, count = vim.v.count1 }) - - if terminals[termkey] and terminals[termkey]:buf_valid() then - terminals[termkey]:toggle() - else - terminals[termkey] = require("lazy.util").float_term(cmd, opts) - local buf = terminals[termkey].buf - vim.b[buf].lazyterm_cmd = cmd - if opts.esc_esc == false then - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - end - if opts.ctrl_hjkl == false then - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - end - - vim.api.nvim_create_autocmd("BufEnter", { - buffer = buf, - callback = function() - vim.cmd.startinsert() - end, - }) - end - - return terminals[termkey] -end - ----@param silent boolean? ----@param values? {[1]:any, [2]:any} -function M.toggle(option, silent, values) - if values then - if vim.opt_local[option]:get() == values[1] then - vim.opt_local[option] = values[2] - else - vim.opt_local[option] = values[1] - end - return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" }) - end - vim.opt_local[option] = not vim.opt_local[option]:get() - if not silent then - if vim.opt_local[option]:get() then - Util.info("Enabled " .. option, { title = "Option" }) - else - Util.warn("Disabled " .. option, { title = "Option" }) - end - end -end - -local nu = { number = true, relativenumber = true } -function M.toggle_number() - if vim.opt_local.number:get() or vim.opt_local.relativenumber:get() then - nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() } - vim.opt_local.number = false - vim.opt_local.relativenumber = false - Util.warn("Disabled line numbers", { title = "Option" }) - else - vim.opt_local.number = nu.number - vim.opt_local.relativenumber = nu.relativenumber - Util.info("Enabled line numbers", { title = "Option" }) - end -end - -local enabled = true -function M.toggle_diagnostics() - enabled = not enabled - if enabled then - vim.diagnostic.enable() - Util.info("Enabled diagnostics", { title = "Diagnostics" }) - else - vim.diagnostic.disable() - Util.warn("Disabled diagnostics", { title = "Diagnostics" }) - end -end - function M.deprecate(old, new) - Util.warn(("`%s` is deprecated. Please use `%s` instead"):format(old, new), { title = "LazyVim" }) + M.warn(("`%s` is deprecated. Please use `%s` instead"):format(old, new), { + title = "LazyVim", + once = true, + stacktrace = true, + stacklevel = 6, + }) end -- delay notifications till vim.notify was replaced or after 500ms @@ -259,25 +115,6 @@ function M.lazy_notify() timer:start(500, 0, replay) end ----@return _.lspconfig.options -function M.lsp_get_config(server) - local configs = require("lspconfig.configs") - return rawget(configs, server) -end - ----@param server string ----@param cond fun( root_dir, config): boolean -function M.lsp_disable(server, cond) - local util = require("lspconfig.util") - local def = M.lsp_get_config(server) - ---@diagnostic disable-next-line: undefined-field - def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir) - if cond(root_dir, config) then - config.enabled = false - end - end) -end - ---@param name string ---@param fn fun(name:string) function M.on_load(name, fn) @@ -305,28 +142,6 @@ function M.changelog() vim.diagnostic.disable(float.buf) end ----@param from string ----@param to string -function M.on_rename(from, to) - local clients = M.get_clients() - for _, client in ipairs(clients) do - if client.supports_method("workspace/willRenameFiles") then - ---@diagnostic disable-next-line: invisible - local resp = client.request_sync("workspace/willRenameFiles", { - files = { - { - oldUri = vim.uri_from_fname(from), - newUri = vim.uri_from_fname(to), - }, - }, - }, 1000, 0) - if resp and resp.result ~= nil then - vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) - end - end - end -end - -- Wrapper around vim.keymap.set that will -- not create a keymap if a lazy key handler exists. -- It will also set `silent` to true by default. @@ -345,6 +160,7 @@ function M.safe_keymap_set(mode, lhs, rhs, opts) opts = opts or {} opts.silent = opts.silent ~= false if opts.remap and not vim.g.vscode then + ---@diagnostic disable-next-line: no-unknown opts.remap = nil end vim.keymap.set(modes, lhs, rhs, opts) diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua new file mode 100644 index 00000000..d5903cd8 --- /dev/null +++ b/lua/lazyvim/util/lsp.lua @@ -0,0 +1,112 @@ +---@class lazyvim.util.lsp +local M = {} + +function M.get_clients(...) + ---@diagnostic disable-next-line: deprecated + local fn = vim.lsp.get_clients or vim.lsp.get_active_clients + return fn(...) +end + +---@param on_attach fun(client, buffer) +function M.on_attach(on_attach) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local buffer = args.buf ---@type number + local client = vim.lsp.get_client_by_id(args.data.client_id) + on_attach(client, buffer) + end, + }) +end + +---@param from string +---@param to string +function M.on_rename(from, to) + local clients = M.get_clients() + for _, client in ipairs(clients) do + if client.supports_method("workspace/willRenameFiles") then + ---@diagnostic disable-next-line: invisible + local resp = client.request_sync("workspace/willRenameFiles", { + files = { + { + oldUri = vim.uri_from_fname(from), + newUri = vim.uri_from_fname(to), + }, + }, + }, 1000, 0) + if resp and resp.result ~= nil then + vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) + end + end + end +end + +---@return _.lspconfig.options +function M.get_config(server) + local configs = require("lspconfig.configs") + return rawget(configs, server) +end + +---@param server string +---@param cond fun( root_dir, config): boolean +function M.disable(server, cond) + local util = require("lspconfig.util") + local def = M.get_config(server) + ---@diagnostic disable-next-line: undefined-field + def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir) + if cond(root_dir, config) then + config.enabled = false + end + end) +end + +---@alias lsp.Client.filter fun(client: lsp.Client): boolean + +---@param name string +---@return lsp.Client.filter +function M.filter(name) + return function(client) + return client.name == name + end +end + +---@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter), bufnr?: number} +function M.formatter(opts) + opts = opts or {} + local filter = opts.filter + filter = type(filter) == "string" and M.filter(filter) or filter + ---@cast filter lsp.Client.filter? + ---@type LazyFormatter + local ret = { + name = "LSP", + primary = true, + priority = 1, + format = function(buf) + M.format({ bufnr = buf, filter = filter }) + end, + sources = function(buf) + local clients = M.get_clients({ bufnr = buf }) + ---@param client lsp.Client + local ret = vim.tbl_filter(function(client) + return (not filter or filter(client)) + and ( + client.supports_method("textDocument/formatting") + or client.supports_method("textDocument/rangeFormatting") + ) + end, clients) + ---@param client lsp.Client + return vim.tbl_map(function(client) + return client.name + end, ret) + end, + } + return vim.tbl_deep_extend("force", ret, opts) --[[@as LazyFormatter]] +end + +---@param opts? {filter?: lsp.Client.filter, bufnr?: number} +function M.format(opts) + vim.lsp.buf.format( + vim.tbl_deep_extend("force", opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {}) + ) +end + +return M diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua new file mode 100644 index 00000000..296e045b --- /dev/null +++ b/lua/lazyvim/util/root.lua @@ -0,0 +1,49 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.root +local M = {} + +M.patterns = { ".git", "lua" } + +-- returns the root directory based on: +-- * lsp workspace folders +-- * lsp root_dir +-- * root pattern of filename of the current buffer +-- * root pattern of cwd +---@return string +function M.get() + ---@type string? + local path = vim.api.nvim_buf_get_name(0) + path = path ~= "" and vim.loop.fs_realpath(path) or nil + ---@type string[] + local roots = {} + if path then + for _, client in pairs(Util.lsp.get_clients({ bufnr = 0 })) do + local workspace = client.config.workspace_folders + local paths = workspace and vim.tbl_map(function(ws) + return vim.uri_to_fname(ws.uri) + end, workspace) or client.config.root_dir and { client.config.root_dir } or {} + for _, p in ipairs(paths) do + local r = vim.loop.fs_realpath(p) + if path:find(r, 1, true) then + roots[#roots + 1] = r + end + end + end + end + table.sort(roots, function(a, b) + return #a > #b + end) + ---@type string? + local root = roots[1] + if not root then + path = path and vim.fs.dirname(path) or vim.loop.cwd() + ---@type string? + root = vim.fs.find(M.patterns, { path = path, upward = true })[1] + root = root and vim.fs.dirname(root) or vim.loop.cwd() + end + ---@cast root string + return root +end + +return M diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua new file mode 100644 index 00000000..2aae403d --- /dev/null +++ b/lua/lazyvim/util/telescope.lua @@ -0,0 +1,53 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.telescope.opts +---@field cwd? string|boolean +---@field show_untracked? boolean + +---@class lazyvim.util.telescope +---@overload fun(builtin:string, opts?:lazyvim.util.telescope.opts) +local M = setmetatable({}, { + __call = function(m, ...) + return m.telescope(...) + end, +}) + +-- this will return a function that calls telescope. +-- cwd will default to lazyvim.util.get_root +-- for `files`, git_files or find_files will be chosen depending on .git +---@param builtin string +---@param opts? lazyvim.util.telescope.opts +function M.telescope(builtin, opts) + local params = { builtin = builtin, opts = opts } + return function() + builtin = params.builtin + opts = params.opts + opts = vim.tbl_deep_extend("force", { cwd = Util.root.get() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] + if builtin == "files" then + if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then + opts.show_untracked = true + builtin = "git_files" + else + builtin = "find_files" + end + end + if opts.cwd and opts.cwd ~= vim.loop.cwd() then + ---@diagnostic disable-next-line: inject-field + opts.attach_mappings = function(_, map) + map("i", "", function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + M.telescope( + params.builtin, + vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line }) + )() + end) + return true + end + end + + require("telescope.builtin")[builtin](opts) + end +end + +return M diff --git a/lua/lazyvim/util/terminal.lua b/lua/lazyvim/util/terminal.lua new file mode 100644 index 00000000..7787615b --- /dev/null +++ b/lua/lazyvim/util/terminal.lua @@ -0,0 +1,55 @@ +---@class lazyvim.util.terminal +---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat +local M = setmetatable({}, { + __call = function(m, ...) + return m.open(...) + end, +}) + +---@type table +local terminals = {} + +---@class LazyTermOpts: LazyCmdOptions +---@field interactive? boolean +---@field esc_esc? boolean +---@field ctrl_hjkl? boolean + +-- Opens a floating terminal (interactive by default) +---@param cmd? string[]|string +---@param opts? LazyTermOpts +function M.open(cmd, opts) + opts = vim.tbl_deep_extend("force", { + ft = "lazyterm", + size = { width = 0.9, height = 0.9 }, + }, opts or {}, { persistent = true }) --[[@as LazyTermOpts]] + + local termkey = vim.inspect({ cmd = cmd or "shell", cwd = opts.cwd, env = opts.env, count = vim.v.count1 }) + + if terminals[termkey] and terminals[termkey]:buf_valid() then + terminals[termkey]:toggle() + else + terminals[termkey] = require("lazy.util").float_term(cmd, opts) + local buf = terminals[termkey].buf + vim.b[buf].lazyterm_cmd = cmd + if opts.esc_esc == false then + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + end + if opts.ctrl_hjkl == false then + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + end + + vim.api.nvim_create_autocmd("BufEnter", { + buffer = buf, + callback = function() + vim.cmd.startinsert() + end, + }) + end + + return terminals[termkey] +end + +return M diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua new file mode 100644 index 00000000..b520070b --- /dev/null +++ b/lua/lazyvim/util/toggle.lua @@ -0,0 +1,62 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.toggle +local M = {} + +---@param silent boolean? +---@param values? {[1]:any, [2]:any} +function M.option(option, silent, values) + if values then + if vim.opt_local[option]:get() == values[1] then + ---@diagnostic disable-next-line: no-unknown + vim.opt_local[option] = values[2] + else + ---@diagnostic disable-next-line: no-unknown + vim.opt_local[option] = values[1] + end + return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" }) + end + ---@diagnostic disable-next-line: no-unknown + vim.opt_local[option] = not vim.opt_local[option]:get() + if not silent then + if vim.opt_local[option]:get() then + Util.info("Enabled " .. option, { title = "Option" }) + else + Util.warn("Disabled " .. option, { title = "Option" }) + end + end +end + +local nu = { number = true, relativenumber = true } +function M.number() + if vim.opt_local.number:get() or vim.opt_local.relativenumber:get() then + nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() } + vim.opt_local.number = false + vim.opt_local.relativenumber = false + Util.warn("Disabled line numbers", { title = "Option" }) + else + vim.opt_local.number = nu.number + vim.opt_local.relativenumber = nu.relativenumber + Util.info("Enabled line numbers", { title = "Option" }) + end +end + +local enabled = true +function M.diagnostics() + enabled = not enabled + if enabled then + vim.diagnostic.enable() + Util.info("Enabled diagnostics", { title = "Diagnostics" }) + else + vim.diagnostic.disable() + Util.warn("Disabled diagnostics", { title = "Diagnostics" }) + end +end + +setmetatable(M, { + __call = function(m, ...) + return m.option(...) + end, +}) + +return M diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 66ec4bca..22b70e4b 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -1,3 +1,4 @@ +---@class lazyvim.util.ui local M = {} ---@alias Sign {name:string, text:string, texthl:string, priority:number} @@ -119,4 +120,13 @@ function M.statuscolumn() }, "") end +function M.fg(name) + ---@type {foreground?:number}? + ---@diagnostic disable-next-line: deprecated + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) + ---@diagnostic disable-next-line: undefined-field + local fg = hl and (hl.fg or hl.foreground) + return fg and { fg = string.format("#%06x", fg) } or nil +end + return M From f1a8f24a361d0de198f6b1458168652a6835c932 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 19:31:08 +0200 Subject: [PATCH 208/362] feat(format): new LazyVim formatter with integrations for lsp/none-ls/conform/eslint/... --- lua/lazyvim/config/keymaps.lua | 5 +- lua/lazyvim/config/options.lua | 3 + .../plugins/extras/formatting/conform.lua | 17 +- lua/lazyvim/plugins/extras/linting/eslint.lua | 35 +++-- lua/lazyvim/plugins/lsp/format.lua | 126 --------------- lua/lazyvim/plugins/lsp/init.lua | 40 ++++- lua/lazyvim/util/format.lua | 147 ++++++++++++++++++ 7 files changed, 225 insertions(+), 148 deletions(-) delete mode 100644 lua/lazyvim/plugins/lsp/format.lua create mode 100644 lua/lazyvim/util/format.lua diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index b60aa43e..ced9cdf7 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -95,13 +95,14 @@ end -- formatting map({ "n", "v" }, "cf", function() - require("lazyvim.plugins.lsp.format").format({ force = true }) + Util.format({ force = true }) end, { desc = "Format" }) -- stylua: ignore start -- toggle options -map("n", "uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "Toggle format on Save" }) +map("n", "uf", function() Util.format.toggle() end, { desc = "Toggle auto format (global)" }) +map("n", "uF", function() Util.format.toggle(true) end, { desc = "Toggle auto format (buffer)" }) map("n", "us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) map("n", "uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index e2ae9485..1649896b 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -2,6 +2,9 @@ vim.g.mapleader = " " vim.g.maplocalleader = "\\" +-- Enable LazyVim auto format +vim.g.autoformat = true + local opt = vim.opt opt.autowrite = true -- Enable auto write diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/extras/formatting/conform.lua index 601967c5..855e356e 100644 --- a/lua/lazyvim/plugins/extras/formatting/conform.lua +++ b/lua/lazyvim/plugins/extras/formatting/conform.lua @@ -18,9 +18,20 @@ return { vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" -- Install the conform formatter on VeryLazy require("lazyvim.util").on_very_lazy(function() - require("lazyvim.plugins.lsp.format").custom_format = function(buf) - return require("conform").format({ bufnr = buf }) - end + require("lazyvim.util").format.register({ + name = "conform.nvim", + priority = 100, + primary = true, + format = function(buf) + require("conform").format({ bufnr = buf }) + end, + sources = function(buf) + local ret = require("conform").list_formatters(buf) + return vim.tbl_map(function(v) + return v.name + end, ret) + end, + }) end) end, opts = { diff --git a/lua/lazyvim/plugins/extras/linting/eslint.lua b/lua/lazyvim/plugins/extras/linting/eslint.lua index 1fea3c8c..9537303d 100644 --- a/lua/lazyvim/plugins/extras/linting/eslint.lua +++ b/lua/lazyvim/plugins/extras/linting/eslint.lua @@ -14,22 +14,37 @@ return { }, setup = { eslint = function() - vim.api.nvim_create_autocmd("BufWritePre", { - callback = function(event) - if not require("lazyvim.plugins.lsp.format").enabled() then - -- exit early if autoformat is not enabled - return - end + local function get_client(buf) + return require("lazyvim.util").lsp.get_clients({ name = "eslint", bufnr = buf })[1] + end - local client = require("lazyvim.util").get_clients({ bufnr = event.buf, name = "eslint" })[1] + local formatter = require("lazyvim.util").lsp.formatter({ + name = "eslint: lsp", + primary = false, + priority = 200, + filter = "eslint", + }) + + -- Use EslintFixAll on Neovim < 0.10.0 + if not pcall(require, "vim.lsp._dynamic") then + formatter.name = "eslint: EslintFixAll" + formatter.sources = function(buf) + local client = get_client(buf) + return client and { "eslint" } or {} + end + formatter.format = function(buf) + local client = get_client(buf) if client then - local diag = vim.diagnostic.get(event.buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) }) + local diag = vim.diagnostic.get(buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) }) if #diag > 0 then vim.cmd("EslintFixAll") end end - end, - }) + end + end + + -- register the formatter with LazyVim + require("lazyvim.util").format.register(formatter) end, }, }, diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua deleted file mode 100644 index f507a38a..00000000 --- a/lua/lazyvim/plugins/lsp/format.lua +++ /dev/null @@ -1,126 +0,0 @@ -local Util = require("lazy.core.util") - -local M = {} - ----@type PluginLspOpts -M.opts = nil - --- Allow plugins to set a custom formatter for a buffer. --- See the conform extra for an example. ----@type fun(bufnr:number):boolean -M.custom_format = nil - -function M.enabled() - return M.opts.autoformat -end - -function M.toggle() - if vim.b.autoformat == false then - vim.b.autoformat = nil - M.opts.autoformat = true - else - M.opts.autoformat = not M.opts.autoformat - end - if M.opts.autoformat then - Util.info("Enabled format on save", { title = "Format" }) - else - Util.warn("Disabled format on save", { title = "Format" }) - end -end - ----@param opts? {force?:boolean} -function M.format(opts) - local buf = vim.api.nvim_get_current_buf() - if vim.b.autoformat == false and not (opts and opts.force) then - return - end - - if - M.custom_format - and Util.try(function() - return M.custom_format(buf) - end, { msg = "Custom formatter failed" }) - then - return - end - - local formatters = M.get_formatters(buf) - local client_ids = vim.tbl_map(function(client) - return client.id - end, formatters.active) - - if #client_ids == 0 then - if opts and opts.force then - Util.warn("No formatter available", { title = "LazyVim" }) - end - return - end - - vim.lsp.buf.format(vim.tbl_deep_extend("force", { - bufnr = buf, - filter = function(client) - return vim.tbl_contains(client_ids, client.id) - end, - }, require("lazyvim.util").opts("nvim-lspconfig").format or {})) -end - --- Gets all lsp clients that support formatting. --- When a null-ls formatter is available for the current filetype, --- only null-ls formatters are returned. -function M.get_formatters(bufnr) - local ft = vim.bo[bufnr].filetype - -- check if we have any null-ls formatters for the current filetype - local null_ls = package.loaded["null-ls"] and require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") or {} - - ---@class LazyVimFormatters - local ret = { - ---@type lsp.Client[] - active = {}, - ---@type lsp.Client[] - available = {}, - null_ls = null_ls, - } - - ---@type lsp.Client[] - local clients = require("lazyvim.util").get_clients({ bufnr = bufnr }) - for _, client in ipairs(clients) do - if M.supports_format(client) then - if (#null_ls > 0 and client.name == "null-ls") or #null_ls == 0 then - table.insert(ret.active, client) - else - table.insert(ret.available, client) - end - end - end - - return ret -end - --- Gets all lsp clients that support formatting --- and have not disabled it in their client config ----@param client lsp.Client -function M.supports_format(client) - if - client.config - and client.config.capabilities - and client.config.capabilities.documentFormattingProvider == false - then - return false - end - return client.supports_method("textDocument/formatting") or client.supports_method("textDocument/rangeFormatting") -end - ----@param opts PluginLspOpts -function M.setup(opts) - M.opts = opts - vim.api.nvim_create_autocmd("BufWritePre", { - group = vim.api.nvim_create_augroup("LazyVimFormat", {}), - callback = function() - if M.opts.autoformat then - M.format() - end - end, - }) -end - -return M diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index f18eed4f..b9e38e8b 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -35,8 +35,6 @@ return { }, -- add any global capabilities here capabilities = {}, - -- Automatically format on save - autoformat = true, -- options for vim.lsp.buf.format -- `bufnr` and `filter` is handled by the LazyVim formatter, -- but can be also overridden when specified @@ -80,16 +78,20 @@ return { }, ---@param opts PluginLspOpts config = function(_, opts) - local Util = require("lazyvim.util") - if Util.has("neoconf.nvim") then local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"] require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false)) end + -- setup autoformat - require("lazyvim.plugins.lsp.format").setup(opts) - -- setup formatting and keymaps - Util.on_attach(function(client, buffer) + Util.format.register(Util.lsp.formatter()) + + -- deprectaed options + if opts.autoformat ~= nil then + vim.g.autoformat = opts.autoformat + Util.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat") + end + -- setup keymaps Util.lsp.on_attach(function(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) @@ -215,6 +217,30 @@ return { }, } end, + config = function(_, opts) + require("null-ls").setup(opts) + + -- register the formatter with LazyVim + require("lazyvim.util").format.register({ + name = "none-ls.nvim", + priority = 50, + primary = true, + format = function(buf) + return Util.lsp.format({ + bufnr = buf, + filter = function(client) + return client.name == "null-ls" + end, + }) + end, + sources = function(buf) + local ret = require("null-ls.sources").get_available(vim.bo[buf].filetype, "NULL_LS_FORMATTING") or {} + return vim.tbl_map(function(source) + return source.name + end, ret) + end, + }) + end, }, -- cmdline tools and lsp servers diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua new file mode 100644 index 00000000..05f5f5fd --- /dev/null +++ b/lua/lazyvim/util/format.lua @@ -0,0 +1,147 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.format +---@overload fun(opts?: {force?:boolean}) +local M = setmetatable({}, { + __call = function(m, ...) + return m.format(...) + end, +}) + +---@class LazyFormatter +---@field name string +---@field primary? boolean +---@field format fun(bufnr:number) +---@field sources fun(bufnr:number):string[] +---@field priority number + +M.formatters = {} ---@type LazyFormatter[] + +---@param formatter LazyFormatter +function M.register(formatter) + M.formatters[#M.formatters + 1] = formatter + table.sort(M.formatters, function(a, b) + return a.priority > b.priority + end) +end + +---@param buf? number +---@return (LazyFormatter|{active:boolean,resolved:string[]})[] +function M.resolve(buf) + buf = buf or vim.api.nvim_get_current_buf() + local have_primary = false + ---@param formatter LazyFormatter + return vim.tbl_map(function(formatter) + local sources = formatter.sources(buf) + local active = #sources > 0 and (not formatter.primary or not have_primary) + have_primary = have_primary or (active and formatter.primary) or false + return setmetatable({ + active = active, + resolved = sources, + }, { __index = formatter }) + end, M.formatters) +end + +---@param buf? number +function M.info(buf) + buf = buf or vim.api.nvim_get_current_buf() + local gaf = vim.g.autoformat == nil or vim.g.autoformat + local baf = vim.b[buf].autoformat + local enabled = M.enabled(buf) + local lines = { + "# Status", + ("- [%s] global **%s**"):format(gaf and "x" or " ", gaf and "enabled" or "disabled"), + ("- [%s] buffer **%s**"):format( + enabled and "x" or " ", + baf == nil and "inherit" or baf and "enabled" or "disabled" + ), + } + local have = false + for _, formatter in ipairs(M.resolve(buf)) do + if #formatter.resolved > 0 then + have = true + lines[#lines + 1] = "\n# " .. formatter.name .. (formatter.active and " ***(active)***" or "") + for _, line in ipairs(formatter.resolved) do + lines[#lines + 1] = ("- [%s] **%s**"):format(formatter.active and "x" or " ", line) + end + end + end + if not have then + lines = { "\nNo formatters available for this buffer" } + end + Util[enabled and "info" or "warn"]( + table.concat(lines, "\n"), + { title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" } + ) +end + +---@param buf? number +function M.enabled(buf) + buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf + local gaf = vim.g.autoformat + local baf = vim.b[buf].autoformat + + -- If the buffer has a local value, use that + if baf ~= nil then + return baf + end + + -- Otherwise use the global value if set, or true by default + return gaf == nil or gaf +end + +---@param buf? boolean +function M.toggle(buf) + if buf then + vim.b.autoformat = not M.enabled() + else + vim.g.autoformat = not M.enabled() + vim.b.autoformat = nil + end + M.info() +end + +---@param opts? {force?:boolean, buf?:number} +function M.format(opts) + opts = opts or {} + local buf = opts.buf or vim.api.nvim_get_current_buf() + if not ((opts and opts.force) or M.enabled(buf)) then + return + end + + local done = false + for _, formatter in ipairs(M.resolve(buf)) do + if formatter.active then + done = true + Util.try(function() + return formatter.format(buf) + end, { msg = "Formatter `" .. formatter.name .. "` failed" }) + end + end + + if not done and opts and opts.force then + Util.warn("No formatter available", { title = "LazyVim" }) + end +end + +function M.setup() + -- Autoformat autocmd + vim.api.nvim_create_autocmd("BufWritePre", { + group = vim.api.nvim_create_augroup("LazyFormat", {}), + callback = function(event) + M.format({ buf = event.buf }) + end, + }) + + -- Manual format + vim.api.nvim_create_user_command("LazyFormat", function() + M.format({ force = true }) + end, { desc = "Format selection or buffer" }) + + -- Format info + vim.api.nvim_create_user_command("LazyFormatInfo", function() + M.info() + end, { desc = "Show info about the formatters for the current buffer" }) +end + +return M From 70f91956e7f03e740b51cbc14c87df6a6f74538f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 21:51:09 +0200 Subject: [PATCH 209/362] perf(plugin): move all lazy.nvim related code to `lazyvim.util.plugin` --- lua/lazyvim/config/init.lua | 202 +++++------------------------------ lua/lazyvim/plugins/init.lua | 10 ++ lua/lazyvim/util/init.lua | 1 + lua/lazyvim/util/plugin.lua | 148 +++++++++++++++++++++++++ 4 files changed, 183 insertions(+), 178 deletions(-) create mode 100644 lua/lazyvim/util/plugin.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 23ca90d4..201629fa 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,10 +3,6 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.lazy_version = ">=10.8.0" -M.use_lazy_file = true -M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" } - ---@class LazyVimOptions local defaults = { -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme @@ -85,61 +81,13 @@ local defaults = { }, } -M.renames = { - ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", - ["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim", - ["null-ls.nvim"] = "none-ls.nvim", -} - ---@type LazyVimOptions local options ----@param lines {[1]:string, [2]:string}[] -function M.msg(lines) - vim.cmd([[clear]]) - vim.api.nvim_echo(lines, true, {}) - vim.fn.getchar() -end - ---@param opts? LazyVimOptions function M.setup(opts) options = vim.tbl_deep_extend("force", defaults, opts or {}) or {} - if vim.fn.has("nvim-0.9.0") == 0 then - M.msg({ - { - "LazyVim requires Neovim >= 0.9.0\n", - "ErrorMsg", - }, - { "Press any key to exit", "MoreMsg" }, - }) - vim.cmd([[quit]]) - return - end - - if not M.has() then - M.msg({ - { - "LazyVim requires lazy.nvim " .. M.lazy_version .. "\n", - "WarningMsg", - }, - { "Press any key to attempt an upgrade", "MoreMsg" }, - }) - - vim.api.nvim_create_autocmd("User", { - pattern = "LazyVimStarted", - callback = function() - require("lazy").update({ plugins = { "lazy.nvim" }, wait = true }) - M.msg({ - { - "**lazy.nvim** has been upgraded.\nPlease restart **Neovim**", - "WarningMsg", - }, - }) - end, - }) - end - -- autocmds can be loaded lazily when not opening a file local lazy_autocmds = vim.fn.argc(-1) == 0 if not lazy_autocmds then @@ -159,10 +107,6 @@ function M.setup(opts) end, }) - if M.use_lazy_file then - M.lazy_file() - end - Util.track("colorscheme") Util.try(function() if type(M.colorscheme) == "function" then @@ -180,64 +124,6 @@ function M.setup(opts) Util.track() end --- Properly load file based plugins without blocking the UI -function M.lazy_file() - local events = {} ---@type {event: string, buf: number, data?: any}[] - - local function load() - if #events == 0 then - return - end - local Event = require("lazy.core.handler.event") - vim.api.nvim_del_augroup_by_name("lazy_file") - - Util.track({ event = "LazyVim.lazy_file" }) - - ---@type table - local skips = {} - for _, event in ipairs(events) do - skips[event.event] = skips[event.event] or Event.get_augroups(event.event) - end - - vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) - for _, event in ipairs(events) do - Event.trigger({ - event = event.event, - exclude = skips[event.event], - data = event.data, - buf = event.buf, - }) - if vim.bo[event.buf].filetype then - Event.trigger({ - event = "FileType", - buf = event.buf, - }) - end - end - vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) - events = {} - Util.track() - end - - -- schedule wrap so that nested autocmds are executed - -- and the UI can continue rendering without blocking - load = vim.schedule_wrap(load) - - vim.api.nvim_create_autocmd(M.lazy_file_events, { - group = vim.api.nvim_create_augroup("lazy_file", { clear = true }), - callback = function(event) - table.insert(events, event) - load() - end, - }) -end - ----@param range? string -function M.has(range) - local Semver = require("lazy.manage.semver") - return Semver.range(range or M.lazy_version):matches(require("lazy.core.config").version or "0.0.0") -end - ---@param name "autocmds" | "options" | "keymaps" function M.load(name) local function _load(mod) @@ -262,71 +148,31 @@ end M.did_init = false function M.init() - if not M.did_init then - M.did_init = true - local plugin = require("lazy.core.config").spec.plugins.LazyVim - if plugin then - vim.opt.rtp:append(plugin.dir) - end - - package.preload["lazyvim.plugins.lsp.format"] = function() - Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) - return Util.format - end - - M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 - ---@diagnostic disable-next-line: undefined-field - M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil - - -- delay notifications till vim.notify was replaced or after 500ms - require("lazyvim.util").lazy_notify() - - -- load options here, before lazy init while sourcing plugin modules - -- this is needed to make sure options will be correctly applied - -- after installing missing plugins - M.load("options") - local Plugin = require("lazy.core.plugin") - local add = Plugin.Spec.add - ---@diagnostic disable-next-line: duplicate-set-field - Plugin.Spec.add = function(self, plugin, ...) - if type(plugin) == "table" then - if M.renames[plugin[1]] then - Util.warn( - ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( - plugin[1], - M.renames[plugin[1]], - self.importing or "LazyVim" - ), - { title = "LazyVim" } - ) - plugin[1] = M.renames[plugin[1]] - end - if not M.use_lazy_file and plugin.event then - if plugin.event == "LazyFile" then - plugin.event = M.lazy_file_events - elseif type(plugin.event) == "table" then - local events = {} ---@type string[] - for _, event in ipairs(plugin.event) do - if event == "LazyFile" then - vim.list_extend(events, M.lazy_file_events) - else - events[#events + 1] = event - end - end - end - end - end - return add(self, plugin, ...) - end - - -- Add support for the LazyFile event - local Event = require("lazy.core.handler.event") - local _event = Event._event - ---@diagnostic disable-next-line: duplicate-set-field - Event._event = function(self, value) - return value == "LazyFile" and "User LazyFile" or _event(self, value) - end + if M.did_init then + return end + M.did_init = true + local plugin = require("lazy.core.config").spec.plugins.LazyVim + if plugin then + vim.opt.rtp:append(plugin.dir) + end + + package.preload["lazyvim.plugins.lsp.format"] = function() + Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) + return Util.format + end + + -- delay notifications till vim.notify was replaced or after 500ms + require("lazyvim.util").lazy_notify() + + -- load options here, before lazy init while sourcing plugin modules + -- this is needed to make sure options will be correctly applied + -- after installing missing plugins + M.load("options") + + Util.plugin.fix_imports() + Util.plugin.fix_renames() + Util.plugin.lazy_file() end setmetatable(M, { diff --git a/lua/lazyvim/plugins/init.lua b/lua/lazyvim/plugins/init.lua index 847d8470..8c7b5fa1 100644 --- a/lua/lazyvim/plugins/init.lua +++ b/lua/lazyvim/plugins/init.lua @@ -1,3 +1,13 @@ +if vim.fn.has("nvim-0.9.0") == 0 then + vim.api.nvim_echo({ + { "LazyVim requires Neovim >= 0.9.0\n", "ErrorMsg" }, + { "Press any key to exit", "MoreMsg" }, + }, true, {}) + vim.fn.getchar() + vim.cmd([[quit]]) + return {} +end + require("lazyvim.config").init() return { diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 146e73e2..c46ac22e 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -8,6 +8,7 @@ local LazyUtil = require("lazy.core.util") ---@field terminal lazyvim.util.terminal ---@field toggle lazyvim.util.toggle ---@field format lazyvim.util.format +---@field plugin lazyvim.util.plugin local M = {} ---@type table diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua new file mode 100644 index 00000000..a9d6ccd2 --- /dev/null +++ b/lua/lazyvim/util/plugin.lua @@ -0,0 +1,148 @@ +local Plugin = require("lazy.core.plugin") +local Util = require("lazyvim.util") + +---@class lazyvim.util.plugin +local M = {} + +M.use_lazy_file = true +M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" } + +---@type table +M.deprecated_extras = { + ["lazyvim.plugins.extras.formatting.conform"] = "`conform.nvim` is now the default **LazyVim** formatter.", + ["lazyvim.plugins.extras.linting.nvim-lint"] = "`nvim-lint` is now the default **LazyVim** linter.", +} + +---@type table +M.renames = { + ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", + ["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim", + ["null-ls.nvim"] = "none-ls.nvim", +} + +-- Properly load file based plugins without blocking the UI +function M.lazy_file() + M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 + ---@diagnostic disable-next-line: undefined-field + M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil + M.use_lazy_file = false + + M.fix_lazy_file() + + if not M.use_lazy_file then + return + end + + local events = {} ---@type {event: string, buf: number, data?: any}[] + + local function load() + if #events == 0 then + return + end + local Event = require("lazy.core.handler.event") + vim.api.nvim_del_augroup_by_name("lazy_file") + + Util.track({ event = "LazyVim.lazy_file" }) + + ---@type table + local skips = {} + for _, event in ipairs(events) do + skips[event.event] = skips[event.event] or Event.get_augroups(event.event) + end + + vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) + for _, event in ipairs(events) do + Event.trigger({ + event = event.event, + exclude = skips[event.event], + data = event.data, + buf = event.buf, + }) + if vim.bo[event.buf].filetype then + Event.trigger({ + event = "FileType", + buf = event.buf, + }) + end + end + vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) + events = {} + Util.track() + end + + -- schedule wrap so that nested autocmds are executed + -- and the UI can continue rendering without blocking + load = vim.schedule_wrap(load) + + vim.api.nvim_create_autocmd(M.lazy_file_events, { + group = vim.api.nvim_create_augroup("lazy_file", { clear = true }), + callback = function(event) + table.insert(events, event) + load() + end, + }) +end + +function M.fix_imports() + local import = Plugin.Spec.import + ---@diagnostic disable-next-line: duplicate-set-field + function Plugin.Spec:import(spec) + local dep = M.deprecated_extras[spec and spec.import] + if dep then + dep = dep .. "\n" .. "Please remove the extra to hide this warning." + Util.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 }) + return + end + return import(self, spec) + end +end + +function M.fix_renames() + local add = Plugin.Spec.add + ---@diagnostic disable-next-line: duplicate-set-field + Plugin.Spec.add = function(self, plugin, ...) + if type(plugin) == "table" then + if M.renames[plugin[1]] then + Util.warn( + ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( + plugin[1], + M.renames[plugin[1]], + self.importing or "LazyVim" + ), + { title = "LazyVim" } + ) + plugin[1] = M.renames[plugin[1]] + end + end + return add(self, plugin, ...) + end +end + +function M.fix_lazy_file() + local Config = require("lazyvim.config") + -- Add support for the LazyFile event + local Handler = require("lazy.core.handler") + local Event = require("lazy.core.handler.event") + if M.use_lazy_file then + local _event = Event._event + ---@diagnostic disable-next-line: duplicate-set-field + Event._event = function(self, value) + return value == "LazyFile" and "User LazyFile" or _event(self, value) + end + else + ---@param plugin LazyPlugin + function Event:values(plugin) + local ret = Handler.values(self, plugin) + if ret["LazyFile"] or ret["User LazyFile"] then + for _, event in ipairs(M.lazy_file_events) do + ret[event] = event + end + ret["LazyFile"] = nil + ret["User LazyFile"] = nil + end + return ret + end + end +end + +return M From 14c091b1fc6b0dc0b22ac49ccac69f8a02e3844c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 22:12:33 +0200 Subject: [PATCH 210/362] feat!: make `conform.nvim` and `nvim-lint` the default formatters/linters --- .../plugins/extras/formatting/black.lua | 1 + .../plugins/extras/formatting/prettier.lua | 1 + lua/lazyvim/plugins/extras/lang/cmake.lua | 3 +- lua/lazyvim/plugins/extras/lang/docker.lua | 3 +- lua/lazyvim/plugins/extras/lang/elixir.lua | 3 +- lua/lazyvim/plugins/extras/lang/go.lua | 14 ++-- lua/lazyvim/plugins/extras/lang/omnisharp.lua | 1 + lua/lazyvim/plugins/extras/lang/terraform.lua | 12 ++-- lua/lazyvim/plugins/extras/lsp/none-ls.lua | 45 +++++++++++++ .../formatting/conform.lua => formatting.lua} | 0 lua/lazyvim/plugins/linting.lua | 67 +++++++++++++++++++ lua/lazyvim/plugins/lsp/init.lua | 43 ------------ lua/lazyvim/util/format.lua | 19 ++++++ 13 files changed, 148 insertions(+), 64 deletions(-) create mode 100644 lua/lazyvim/plugins/extras/lsp/none-ls.lua rename lua/lazyvim/plugins/{extras/formatting/conform.lua => formatting.lua} (100%) create mode 100644 lua/lazyvim/plugins/linting.lua diff --git a/lua/lazyvim/plugins/extras/formatting/black.lua b/lua/lazyvim/plugins/extras/formatting/black.lua index bfa383a8..769c3009 100644 --- a/lua/lazyvim/plugins/extras/formatting/black.lua +++ b/lua/lazyvim/plugins/extras/formatting/black.lua @@ -10,6 +10,7 @@ return { optional = true, opts = function(_, opts) local nls = require("null-ls") + opts.sources = opts.sources or {} table.insert(opts.sources, nls.builtins.formatting.black) end, }, diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 81fc1939..6f1f3b58 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -10,6 +10,7 @@ return { optional = true, opts = function(_, opts) local nls = require("null-ls") + opts.sources = opts.sources or {} table.insert(opts.sources, nls.builtins.formatting.prettierd) end, }, diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index bc7b235a..404a072a 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -12,8 +12,7 @@ return { optional = true, opts = function(_, opts) local nls = require("null-ls") - opts.sources = opts.sources or {} - vim.list_extend(opts.sources, { + opts.sources = vim.list_extend(opts.sources or {}, { nls.builtins.diagnostics.cmake_lint, }) end, diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index 86c7175b..da9605ec 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -19,8 +19,7 @@ return { optional = true, opts = function(_, opts) local nls = require("null-ls") - opts.sources = opts.sources or {} - vim.list_extend(opts.sources, { + opts.sources = vim.list_extend(opts.sources or {}, { nls.builtins.diagnostics.hadolint, }) end, diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua index 53454c37..f60dc18e 100644 --- a/lua/lazyvim/plugins/extras/lang/elixir.lua +++ b/lua/lazyvim/plugins/extras/lang/elixir.lua @@ -37,8 +37,7 @@ return { return end local nls = require("null-ls") - opts.sources = opts.sources or {} - vim.list_extend(opts.sources, { + opts.sources = vim.list_extend(opts.sources or {}, { nls.builtins.diagnostics.credo, }) end, diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index 39410353..7e87678b 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -86,14 +86,12 @@ return { "nvimtools/none-ls.nvim", optional = true, opts = function(_, opts) - if type(opts.sources) == "table" then - local nls = require("null-ls") - vim.list_extend(opts.sources, { - nls.builtins.code_actions.gomodifytags, - nls.builtins.code_actions.impl, - nls.builtins.formatting.goimports, - }) - end + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.code_actions.gomodifytags, + nls.builtins.code_actions.impl, + nls.builtins.formatting.goimports, + }) end, }, { diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index d244fd77..31162e0c 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -13,6 +13,7 @@ return { optional = true, opts = function(_, opts) local nls = require("null-ls") + opts.sources = opts.sources or {} table.insert(opts.sources, nls.builtins.formatting.csharpier) end, }, diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index 6e368ff3..ea7bd5de 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -28,13 +28,11 @@ return { "nvimtools/none-ls.nvim", optional = true, opts = function(_, opts) - if type(opts.sources) == "table" then - local null_ls = require("null-ls") - vim.list_extend(opts.sources, { - null_ls.builtins.formatting.terraform_fmt, - null_ls.builtins.diagnostics.terraform_validate, - }) - end + local null_ls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + null_ls.builtins.formatting.terraform_fmt, + null_ls.builtins.diagnostics.terraform_validate, + }) end, }, { diff --git a/lua/lazyvim/plugins/extras/lsp/none-ls.lua b/lua/lazyvim/plugins/extras/lsp/none-ls.lua new file mode 100644 index 00000000..aa907b8e --- /dev/null +++ b/lua/lazyvim/plugins/extras/lsp/none-ls.lua @@ -0,0 +1,45 @@ +local Util = require("lazyvim.util") + +return { + -- none-ls + { + "nvimtools/none-ls.nvim", + event = "LazyFile", + dependencies = { "mason.nvim" }, + init = function() + Util.on_very_lazy(function() + -- register the formatter with LazyVim + require("lazyvim.util").format.register({ + name = "none-ls.nvim", + priority = 200, -- set higher than conform, the builtin formatter + primary = true, + format = function(buf) + return Util.lsp.format({ + bufnr = buf, + filter = function(client) + return client.name == "null-ls" + end, + }) + end, + sources = function(buf) + local ret = require("null-ls.sources").get_available(vim.bo[buf].filetype, "NULL_LS_FORMATTING") or {} + return vim.tbl_map(function(source) + return source.name + end, ret) + end, + }) + end) + end, + opts = function(_, opts) + local nls = require("null-ls") + opts.root_dir = opts.root_dir + or require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.formatting.fish_indent, + nls.builtins.diagnostics.fish, + nls.builtins.formatting.stylua, + nls.builtins.formatting.shfmt, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/formatting/conform.lua b/lua/lazyvim/plugins/formatting.lua similarity index 100% rename from lua/lazyvim/plugins/extras/formatting/conform.lua rename to lua/lazyvim/plugins/formatting.lua diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua new file mode 100644 index 00000000..1fb7ab5d --- /dev/null +++ b/lua/lazyvim/plugins/linting.lua @@ -0,0 +1,67 @@ +return { + { + "mfussenegger/nvim-lint", + event = "LazyFile", + opts = { + -- Event to trigger linters + events = { "BufWritePost", "BufReadPost", "InsertLeave" }, + linters_by_ft = { + fish = { "fish" }, + }, + -- LazyVim extension to easily override linter options + -- or add custom linters. + ---@type table + linters = { + -- -- Example of using selene only when a selene.toml file is present + -- selene = { + -- -- `condition` is another LazyVim extension that allows you to + -- -- dynamically enable/disable linters based on the context. + -- condition = function(ctx) + -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + }, + }, + config = function(_, opts) + local M = {} + + local lint = require("lint") + for name, linter in pairs(opts.linters) do + if type(linter) == "table" and type(lint.linters) == "table" then + lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + end + end + lint.linters_by_ft = opts.linters_by_ft + + function M.debounce(ms, fn) + local timer = vim.loop.new_timer() + return function(...) + local argv = { ... } + timer:start(ms, 0, function() + timer:stop() + vim.schedule_wrap(fn)(unpack(argv)) + end) + end + end + + function M.lint() + local names = lint.linters_by_ft[vim.bo.filetype] or {} + local ctx = { filename = vim.api.nvim_buf_get_name(0) } + ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") + names = vim.tbl_filter(function(name) + local linter = lint.linters[name] + return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) + end, names) + + if #names > 0 then + lint.try_lint(names) + end + end + + vim.api.nvim_create_autocmd(opts.events, { + group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), + callback = M.debounce(100, M.lint), + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index b9e38e8b..165367bf 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -200,49 +200,6 @@ return { end, }, - -- formatters - { - "nvimtools/none-ls.nvim", - event = "LazyFile", - dependencies = { "mason.nvim" }, - opts = function() - local nls = require("null-ls") - return { - root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), - sources = { - nls.builtins.formatting.fish_indent, - nls.builtins.diagnostics.fish, - nls.builtins.formatting.stylua, - nls.builtins.formatting.shfmt, - }, - } - end, - config = function(_, opts) - require("null-ls").setup(opts) - - -- register the formatter with LazyVim - require("lazyvim.util").format.register({ - name = "none-ls.nvim", - priority = 50, - primary = true, - format = function(buf) - return Util.lsp.format({ - bufnr = buf, - filter = function(client) - return client.name == "null-ls" - end, - }) - end, - sources = function(buf) - local ret = require("null-ls.sources").get_available(vim.bo[buf].filetype, "NULL_LS_FORMATTING") or {} - return vim.tbl_map(function(source) - return source.name - end, ret) - end, - }) - end, - }, - -- cmdline tools and lsp servers { diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index 05f5f5fd..b9822a95 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -124,7 +124,26 @@ function M.format(opts) end end +function M.health() + local Config = require("lazy.core.config") + local has_plugin = Config.spec.plugins["none-ls.nvim"] + local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls") + if has_plugin and not has_extra then + Util.warn({ + "`conform.nvim` and `nvim-lint` are now the default forrmatters and linters in LazyVim.", + "", + "You can use those plugins together with `none-ls.nvim`,", + "but you need to enable the `lazyvim.plugins.extras.lsp.none-ls` extra,", + "for formatting to work correctly.", + "", + "In case you no longer want to use `none-ls.nvim`, just remove the spec from your config.", + }) + end +end + function M.setup() + M.health() + -- Autoformat autocmd vim.api.nvim_create_autocmd("BufWritePre", { group = vim.api.nvim_create_augroup("LazyFormat", {}), From 4cbe42cd247c72dfc70c3fcddfa3fb6b5e6485e0 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 22:41:34 +0200 Subject: [PATCH 211/362] feat(starter)!: `dashboard.nvim` is now the default starter. To keep using `alpha.nvim`, enable the extra. --- lua/lazyvim/plugins/extras/ui/alpha.lua | 77 ++++++++++ lua/lazyvim/plugins/extras/ui/dashboard.lua | 64 --------- lua/lazyvim/plugins/ui.lua | 151 ++++++++++---------- lua/lazyvim/util/plugin.lua | 1 + 4 files changed, 157 insertions(+), 136 deletions(-) create mode 100644 lua/lazyvim/plugins/extras/ui/alpha.lua delete mode 100644 lua/lazyvim/plugins/extras/ui/dashboard.lua diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua new file mode 100644 index 00000000..38019498 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -0,0 +1,77 @@ +return { + + { "glepnir/dashboard-nvim", enabled = false }, + { "echasnovski/mini.starter", enabled = false }, + -- Dashboard. This runs when neovim starts, and is what displays + -- the "LAZYVIM" banner. + { + "goolord/alpha-nvim", + event = "VimEnter", + enabled = true, + init = false, + opts = function() + local dashboard = require("alpha.themes.dashboard") + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + dashboard.section.header.val = vim.split(logo, "\n") + dashboard.section.buttons.val = { + dashboard.button("f", " " .. " Find file", " Telescope find_files "), + dashboard.button("n", " " .. " New file", " ene startinsert "), + dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", " Telescope live_grep "), + dashboard.button("c", " " .. " Config", " e $MYVIMRC "), + dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), + } + for _, button in ipairs(dashboard.section.buttons.val) do + button.opts.hl = "AlphaButtons" + button.opts.hl_shortcut = "AlphaShortcut" + end + dashboard.section.header.opts.hl = "AlphaHeader" + dashboard.section.buttons.opts.hl = "AlphaButtons" + dashboard.section.footer.opts.hl = "AlphaFooter" + dashboard.opts.layout[1].val = 8 + return dashboard + end, + config = function(_, dashboard) + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + once = true, + pattern = "AlphaReady", + callback = function() + require("lazy").show() + end, + }) + end + + require("alpha").setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + once = true, + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + dashboard.section.footer.val = "⚡ Neovim loaded " + .. stats.loaded + .. "/" + .. stats.count + .. " plugins in " + .. ms + .. "ms" + pcall(vim.cmd.AlphaRedraw) + end, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/dashboard.lua b/lua/lazyvim/plugins/extras/ui/dashboard.lua deleted file mode 100644 index 2c678f36..00000000 --- a/lua/lazyvim/plugins/extras/ui/dashboard.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - { "goolord/alpha-nvim", enabled = false }, - { "echasnovski/mini.starter", enabled = false }, - { - "glepnir/dashboard-nvim", - event = "VimEnter", - opts = function() - local logo = [[ - ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z - ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z - ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z - ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - logo = string.rep("\n", 8) .. logo .. "\n\n" - - local opts = { - theme = "doom", - hide = { - -- this is taken care of by lualine - -- enabling this messes up the actual laststatus setting after loading a file - statusline = false, - }, - config = { - header = vim.split(logo, "\n"), - center = { - { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, - { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, - { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, - { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, - { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, - }, - footer = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } - end, - }, - } - - for _, button in ipairs(opts.config.center) do - button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - end - - -- close Lazy and re-open when the dashboard is ready - if vim.o.filetype == "lazy" then - vim.cmd.close() - vim.api.nvim_create_autocmd("User", { - pattern = "DashboardLoaded", - callback = function() - require("lazy").show() - end, - }) - end - - return opts - end, - }, -} diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index f1bac031..9cb5237b 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -155,7 +155,11 @@ return { cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, color = Util.ui.fg("Debug"), }, - { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.ui.fg("Special") }, + { + require("lazy.status").updates, + cond = require("lazy.status").has_updates, + color = Util.ui.fg("Special"), + }, { "diff", symbols = { @@ -295,77 +299,6 @@ return { }, }, - -- Dashboard. This runs when neovim starts, and is what displays - -- the "LAZYVIM" banner. - { - "goolord/alpha-nvim", - event = "VimEnter", - opts = function() - local dashboard = require("alpha.themes.dashboard") - local logo = [[ - ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z - ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z - ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z - ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ - ]] - - dashboard.section.header.val = vim.split(logo, "\n") - dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", " Telescope find_files "), - dashboard.button("n", " " .. " New file", " ene startinsert "), - dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", " Telescope live_grep "), - dashboard.button("c", " " .. " Config", " e $MYVIMRC "), - dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), - dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), - dashboard.button("q", " " .. " Quit", " qa "), - } - for _, button in ipairs(dashboard.section.buttons.val) do - button.opts.hl = "AlphaButtons" - button.opts.hl_shortcut = "AlphaShortcut" - end - dashboard.section.header.opts.hl = "AlphaHeader" - dashboard.section.buttons.opts.hl = "AlphaButtons" - dashboard.section.footer.opts.hl = "AlphaFooter" - dashboard.opts.layout[1].val = 8 - return dashboard - end, - config = function(_, dashboard) - -- close Lazy and re-open when the dashboard is ready - if vim.o.filetype == "lazy" then - vim.cmd.close() - vim.api.nvim_create_autocmd("User", { - once = true, - pattern = "AlphaReady", - callback = function() - require("lazy").show() - end, - }) - end - - require("alpha").setup(dashboard.opts) - - vim.api.nvim_create_autocmd("User", { - once = true, - pattern = "LazyVimStarted", - callback = function() - local stats = require("lazy").stats() - local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) - dashboard.section.footer.val = "⚡ Neovim loaded " - .. stats.loaded - .. "/" - .. stats.count - .. " plugins in " - .. ms - .. "ms" - pcall(vim.cmd.AlphaRedraw) - end, - }) - end, - }, - -- lsp symbol navigation for lualine. This shows where -- in the code structure you are - within functions, classes, -- etc - in the statusline. @@ -396,4 +329,78 @@ return { -- ui components { "MunifTanjim/nui.nvim", lazy = true }, + + { + "goolord/alpha-nvim", + optional = true, + enabled = function() + require("lazyvim.util").warn({ + "`dashboard.nvim` is now the default LazyVim starter plugin.", + "", + "To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.", + "Or to hide this message, remove the alpha spec from your config.", + }) + return false + end, + }, + { + "glepnir/dashboard-nvim", + event = "VimEnter", + opts = function() + local logo = [[ + ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z + ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z + ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z + ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]] + + logo = string.rep("\n", 8) .. logo .. "\n\n" + + local opts = { + theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, + config = { + header = vim.split(logo, "\n"), + center = { + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, + }, + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } + end, + }, + } + + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + end + + -- close Lazy and re-open when the dashboard is ready + if vim.o.filetype == "lazy" then + vim.cmd.close() + vim.api.nvim_create_autocmd("User", { + pattern = "DashboardLoaded", + callback = function() + require("lazy").show() + end, + }) + end + + return opts + end, + }, } diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index a9d6ccd2..ca6a162b 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -11,6 +11,7 @@ M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" } M.deprecated_extras = { ["lazyvim.plugins.extras.formatting.conform"] = "`conform.nvim` is now the default **LazyVim** formatter.", ["lazyvim.plugins.extras.linting.nvim-lint"] = "`nvim-lint` is now the default **LazyVim** linter.", + ["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.", } ---@type table From e6d294df6fbd973644d4b7f9691d5f48cc5efdde Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 10 Oct 2023 23:02:59 +0200 Subject: [PATCH 212/362] fix(ui): dont show left signs on virtual line numbers (wrap). Fixes #1654 --- lua/lazyvim/util/ui.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 22b70e4b..6c5a3c1f 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -101,6 +101,10 @@ function M.statuscolumn() end end + if vim.v.virtnum ~= 0 then + left = nil + end + vim.api.nvim_win_call(win, function() if vim.fn.foldclosed(vim.v.lnum) >= 0 then fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } From a2d604928b5629d14797437a26022065f7385216 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 08:59:18 +0200 Subject: [PATCH 213/362] feat(root): customizable root detection and `:LazyRoot` command --- lua/lazyvim/config/init.lua | 1 + lua/lazyvim/config/keymaps.lua | 4 +- lua/lazyvim/config/options.lua | 4 + lua/lazyvim/plugins/editor.lua | 2 +- lua/lazyvim/util/root.lua | 151 +++++++++++++++++++++++++-------- lua/lazyvim/util/telescope.lua | 2 +- 6 files changed, 126 insertions(+), 38 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 201629fa..9319a67d 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -104,6 +104,7 @@ function M.setup(opts) end M.load("keymaps") Util.format.setup() + Util.root.setup() end, }) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index ced9cdf7..79c0ee06 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -115,7 +115,7 @@ if vim.lsp.inlay_hint then end -- lazygit -map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root.get(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) +map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) -- quit @@ -128,7 +128,7 @@ map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) map("n", "L", Util.changelog, {desc = "LazyVim Changelog"}) -- floating terminal -local lazyterm = function() Util.terminal(nil, { cwd = Util.root.get() }) end +local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end map("n", "ft", lazyterm, { desc = "Terminal (root dir)" }) map("n", "fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) map("n", "", lazyterm, { desc = "Terminal (root dir)" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 1649896b..630fce42 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -5,6 +5,10 @@ vim.g.maplocalleader = "\\" -- Enable LazyVim auto format vim.g.autoformat = true +-- LazyVim root dir detection +-- Each entry can be a detector function like `lsp` or `cwd`, or a pattern like `.git` or `lua`. +vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } + local opt = vim.opt opt.autowrite = true -- Enable auto write diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 0fb63944..dabcb8de 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -11,7 +11,7 @@ return { { "fe", function() - require("neo-tree.command").execute({ toggle = true, dir = Util.root.get() }) + require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) end, desc = "Explorer NeoTree (root dir)", }, diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 296e045b..c97ecf88 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -1,9 +1,122 @@ local Util = require("lazyvim.util") ---@class lazyvim.util.root -local M = {} +---@overload fun(): string +local M = setmetatable({}, { + __call = function(m) + return m.get() + end, +}) -M.patterns = { ".git", "lua" } +---@class LazyRoot +---@field paths string[] +---@field spec LazyRootSpec + +---@alias LazyRootSpec string|string[] + +---@type LazyRootSpec[] +M.spec = { "lsp", { ".git", "lua" }, "cwd" } + +M.detectors = {} + +function M.detectors.cwd() + return { vim.loop.cwd() } +end + +function M.detectors.lsp(buf) + if not M.bufpath(buf) then + return {} + end + local roots = {} ---@type string[] + for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do + local workspace = client.config.workspace_folders + for _, ws in pairs(workspace or {}) do + roots[#roots + 1] = vim.uri_to_fname(ws.uri) + end + if client.config.root_dir then + roots[#roots + 1] = client.config.root_dir + end + end + return roots +end + +---@param patterns string[]|string +function M.detectors.pattern(buf, patterns) + patterns = type(patterns) == "string" and { patterns } or patterns + local path = M.bufpath(buf) or vim.loop.cwd() + local pattern = vim.fs.find(patterns, { path = path, upward = true })[1] + return pattern and { vim.fs.dirname(pattern) } or {} +end + +function M.bufpath(buf) + return M.realpath(vim.api.nvim_buf_get_name(assert(buf))) +end + +function M.realpath(path) + if path == "" or path == nil then + return nil + end + path = vim.loop.fs_realpath(path) or path + return Util.norm(path) +end + +---@param opts? { buf?: number, spec?: LazyRootSpec[], all?: boolean } +function M.detect(opts) + opts = opts or {} + opts.spec = opts.spec or type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec + opts.buf = (opts.buf == nil or opts.buf == 0) and vim.api.nvim_get_current_buf() or opts.buf + + local ret = {} ---@type LazyRoot[] + for _, spec in ipairs(opts.spec) do + local paths = M.detectors[spec] and M.detectors[spec](opts.buf) or M.detectors.pattern(opts.buf, spec) + local roots = {} ---@type string[] + for _, p in ipairs(paths) do + local pp = M.realpath(p) + if pp and not vim.tbl_contains(roots, pp) then + roots[#roots + 1] = pp + end + end + table.sort(roots, function(a, b) + return #a > #b + end) + if #roots > 0 then + ret[#ret + 1] = { spec = spec, paths = roots } + if opts.all == false then + break + end + end + end + return ret +end + +function M.setup() + vim.api.nvim_create_user_command("LazyRoot", function() + M.info() + end, { desc = "LazyVim roots for the current buffer" }) +end + +function M.info() + local spec = type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec + + local roots = M.detect({ all = true }) + local lines = {} ---@type string[] + local first = true + for _, root in ipairs(roots) do + for _, path in ipairs(root.paths) do + lines[#lines + 1] = ("- [%s] `%s` **(%s)**"):format( + first and "x" or " ", + path, + type(root.spec) == "table" and table.concat(root.spec, ", ") or root.spec + ) + first = false + end + end + lines[#lines + 1] = "```lua" + lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec) + lines[#lines + 1] = "```" + require("lazyvim.util").info(lines, { title = "LazyVim Roots" }) + return roots[1] and roots[1].paths[1] or vim.loop.cwd() +end -- returns the root directory based on: -- * lsp workspace folders @@ -12,38 +125,8 @@ M.patterns = { ".git", "lua" } -- * root pattern of cwd ---@return string function M.get() - ---@type string? - local path = vim.api.nvim_buf_get_name(0) - path = path ~= "" and vim.loop.fs_realpath(path) or nil - ---@type string[] - local roots = {} - if path then - for _, client in pairs(Util.lsp.get_clients({ bufnr = 0 })) do - local workspace = client.config.workspace_folders - local paths = workspace and vim.tbl_map(function(ws) - return vim.uri_to_fname(ws.uri) - end, workspace) or client.config.root_dir and { client.config.root_dir } or {} - for _, p in ipairs(paths) do - local r = vim.loop.fs_realpath(p) - if path:find(r, 1, true) then - roots[#roots + 1] = r - end - end - end - end - table.sort(roots, function(a, b) - return #a > #b - end) - ---@type string? - local root = roots[1] - if not root then - path = path and vim.fs.dirname(path) or vim.loop.cwd() - ---@type string? - root = vim.fs.find(M.patterns, { path = path, upward = true })[1] - root = root and vim.fs.dirname(root) or vim.loop.cwd() - end - ---@cast root string - return root + local roots = M.detect({ all = false }) + return roots[1] and roots[1].paths[1] or vim.loop.cwd() end return M diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua index 2aae403d..68916341 100644 --- a/lua/lazyvim/util/telescope.lua +++ b/lua/lazyvim/util/telescope.lua @@ -22,7 +22,7 @@ function M.telescope(builtin, opts) return function() builtin = params.builtin opts = params.opts - opts = vim.tbl_deep_extend("force", { cwd = Util.root.get() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] + opts = vim.tbl_deep_extend("force", { cwd = Util.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]] if builtin == "files" then if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then opts.show_untracked = true From f59cdff4d9f04ff349cefdee0b363d573954ce0d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 09:15:50 +0200 Subject: [PATCH 214/362] fix(plugin): enable lazy_file --- lua/lazyvim/util/plugin.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index ca6a162b..d22e7cb0 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -26,7 +26,6 @@ function M.lazy_file() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 ---@diagnostic disable-next-line: undefined-field M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil - M.use_lazy_file = false M.fix_lazy_file() From c33e7489ecdaef7295a63079410f2f24a1cbc9b6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 09:38:34 +0200 Subject: [PATCH 215/362] feat(root): allow custom functions as part of `vim.g.root_spec` --- lua/lazyvim/config/options.lua | 5 ++++- lua/lazyvim/util/root.lua | 21 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 630fce42..5a071a15 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -6,7 +6,10 @@ vim.g.maplocalleader = "\\" vim.g.autoformat = true -- LazyVim root dir detection --- Each entry can be a detector function like `lsp` or `cwd`, or a pattern like `.git` or `lua`. +-- Each entry can be: +-- * the name of a detector function like `lsp` or `cwd` +-- * a pattern or array of patterns like `.git` or `lua`. +-- * a function with signature `function(buf) -> string|string[]` vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } local opt = vim.opt diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index c97ecf88..fe263a7c 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -12,7 +12,9 @@ local M = setmetatable({}, { ---@field paths string[] ---@field spec LazyRootSpec ----@alias LazyRootSpec string|string[] +---@alias LazyRootFn fun(buf: number): (string|string[]) + +---@alias LazyRootSpec string|string[]|LazyRootFn ---@type LazyRootSpec[] M.spec = { "lsp", { ".git", "lua" }, "cwd" } @@ -60,6 +62,19 @@ function M.realpath(path) return Util.norm(path) end +---@param spec LazyRootSpec +---@return LazyRootFn +function M.resolve(spec) + if M.detectors[spec] then + return M.detectors[spec] + elseif type(spec) == "function" then + return spec + end + return function(buf) + return M.detectors.pattern(buf, spec) + end +end + ---@param opts? { buf?: number, spec?: LazyRootSpec[], all?: boolean } function M.detect(opts) opts = opts or {} @@ -68,7 +83,9 @@ function M.detect(opts) local ret = {} ---@type LazyRoot[] for _, spec in ipairs(opts.spec) do - local paths = M.detectors[spec] and M.detectors[spec](opts.buf) or M.detectors.pattern(opts.buf, spec) + local paths = M.resolve(spec)(opts.buf) + paths = paths or {} + paths = type(paths) == "table" and paths or { paths } local roots = {} ---@type string[] for _, p in ipairs(paths) do local pp = M.realpath(p) From a4abbdc89bd1d49378ac5873db1279e7e5398927 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 09:51:12 +0200 Subject: [PATCH 216/362] fix(format): always show formatter status even when no sources available --- lua/lazyvim/util/format.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index b9822a95..af64a6f5 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -67,7 +67,7 @@ function M.info(buf) end end if not have then - lines = { "\nNo formatters available for this buffer" } + lines[#lines+1] = "\n***No formatters available for this buffer.***" end Util[enabled and "info" or "warn"]( table.concat(lines, "\n"), From 83734675b0f93fbd11a350ee0662c09995836b59 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 14:26:16 +0200 Subject: [PATCH 217/362] fix(lualine): when opening nvim with a file, show an empty statusline till lualine loads --- lua/lazyvim/plugins/ui.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 9cb5237b..3259b4eb 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -101,7 +101,13 @@ return { event = "VeryLazy", init = function() vim.g.lualine_laststatus = vim.o.laststatus - vim.o.laststatus = 0 + if vim.fn.argc(-1) > 0 then + -- set an empty statusline till lualine loads + vim.o.statusline = " " + else + -- hide the statusline on the starter page + vim.o.laststatus = 0 + end end, opts = function() local icons = require("lazyvim.config").icons From 4ea1c6865e6d877207de8626e11a5a863950ae55 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 14:27:10 +0200 Subject: [PATCH 218/362] feat(config): use lazy's new custom events (`Event.mappings`) for a better `LazyFile` --- lua/lazyvim/util/plugin.lua | 45 +++++++++---------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index d22e7cb0..b3650eaa 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -24,12 +24,18 @@ M.renames = { -- Properly load file based plugins without blocking the UI function M.lazy_file() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 - ---@diagnostic disable-next-line: undefined-field - M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil - M.fix_lazy_file() + -- Add support for the LazyFile event + local Event = require("lazy.core.handler.event") - if not M.use_lazy_file then + if M.use_lazy_file then + -- We'll handle delayed execution of events ourselves + Event.mappings.LazyFile = { id = "LazyFile", event = "User", pattern = "LazyFile" } + Event.mappings["User LazyFile"] = Event.mappings.LazyFile + else + -- Don't delay execution of LazyFile events, but let lazy know about the mapping + Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } } + Event.mappings["User LazyFile"] = Event.mappings.LazyFile return end @@ -39,11 +45,8 @@ function M.lazy_file() if #events == 0 then return end - local Event = require("lazy.core.handler.event") vim.api.nvim_del_augroup_by_name("lazy_file") - Util.track({ event = "LazyVim.lazy_file" }) - ---@type table local skips = {} for _, event in ipairs(events) do @@ -67,7 +70,6 @@ function M.lazy_file() end vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) events = {} - Util.track() end -- schedule wrap so that nested autocmds are executed @@ -118,31 +120,4 @@ function M.fix_renames() end end -function M.fix_lazy_file() - local Config = require("lazyvim.config") - -- Add support for the LazyFile event - local Handler = require("lazy.core.handler") - local Event = require("lazy.core.handler.event") - if M.use_lazy_file then - local _event = Event._event - ---@diagnostic disable-next-line: duplicate-set-field - Event._event = function(self, value) - return value == "LazyFile" and "User LazyFile" or _event(self, value) - end - else - ---@param plugin LazyPlugin - function Event:values(plugin) - local ret = Handler.values(self, plugin) - if ret["LazyFile"] or ret["User LazyFile"] then - for _, event in ipairs(M.lazy_file_events) do - ret[event] = event - end - ret["LazyFile"] = nil - ret["User LazyFile"] = nil - end - return ret - end - end -end - return M From 8fbde2c3668960ed085f9225bb4650aca77cc495 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 14:27:41 +0200 Subject: [PATCH 219/362] fix(neo-tree): during init check global argslist instead of window-local --- lua/lazyvim/plugins/editor.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index dabcb8de..e2c08b98 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -29,7 +29,7 @@ return { vim.cmd([[Neotree close]]) end, init = function() - if vim.fn.argc() == 1 then + if vim.fn.argc(-1) == 1 then local stat = vim.loop.fs_stat(vim.fn.argv(0)) if stat and stat.type == "directory" then require("neo-tree") From 54fa9ce584b9d029fb9f016f1e3be5daca29beaa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 15:25:29 +0200 Subject: [PATCH 220/362] ci: let release-please manage the version in the config file --- .github/workflows/ci.yml | 2 ++ lua/lazyvim/config/init.lua | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 964a780f..2ffff686 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,8 @@ jobs: with: release-type: simple package-name: LazyVim + extra-files: | + lua/lazyvim/config/init.lua - uses: actions/checkout@v3 - name: tag stable versions if: ${{ steps.release.outputs.release_created }} diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 9319a67d..5cf7feff 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,6 +3,8 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} +M.version = "10.0.0" -- x-release-please-version + ---@class LazyVimOptions local defaults = { -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme From 7fb79486ed1b251b98b95a44ef50b3742edd708d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 17:39:46 +0200 Subject: [PATCH 221/362] fix(notify): set default zindex=100 --- lua/lazyvim/plugins/ui.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 3259b4eb..c22e0791 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -19,6 +19,9 @@ return { max_width = function() return math.floor(vim.o.columns * 0.75) end, + on_open = function(win) + vim.api.nvim_win_set_config(win, { zindex = 100 }) + end, }, init = function() -- when noice is not enabled, install notify on VeryLazy From 11d66e713467410add9ad5a7a68a3bca0aa24082 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 17:47:16 +0200 Subject: [PATCH 222/362] feat(config): load/save some data in lazyvim.json --- lua/lazyvim/config/init.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 5cf7feff..92bd1f69 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -83,6 +83,35 @@ local defaults = { }, } +M.json = { + data = { + version = nil, ---@type string? + extras = {}, ---@type string[] + }, +} + +function M.json.load() + local path = vim.fn.stdpath("config") .. "/lazyvim.json" + local f = io.open(path, "r") + if f then + local data = f:read("*a") + f:close() + local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } }) + if ok then + M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {}) + end + end +end + +function M.json.save() + local path = vim.fn.stdpath("config") .. "/lazyvim.json" + local f = io.open(path, "w") + if f then + f:write(vim.json.encode(M.json.data)) + f:close() + end +end + ---@type LazyVimOptions local options @@ -176,6 +205,7 @@ function M.init() Util.plugin.fix_imports() Util.plugin.fix_renames() Util.plugin.lazy_file() + M.json.load() end setmetatable(M, { From c4e55e4d67a7195b7aa9160cd8ece3ddc2f6cb51 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 17:48:40 +0200 Subject: [PATCH 223/362] feat(ui): added `:LazyExtras` to manage enabled extras in LazyVim --- lua/lazyvim/config/init.lua | 10 +- .../plugins/extras/linting/nvim-lint.lua | 67 ------ lua/lazyvim/plugins/xtras.lua | 6 + lua/lazyvim/util/extras.lua | 202 ++++++++++++++++++ lua/lazyvim/util/init.lua | 1 + lua/lazyvim/util/root.lua | 6 - 6 files changed, 218 insertions(+), 74 deletions(-) delete mode 100644 lua/lazyvim/plugins/extras/linting/nvim-lint.lua create mode 100644 lua/lazyvim/plugins/xtras.lua create mode 100644 lua/lazyvim/util/extras.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 92bd1f69..076a003e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -134,8 +134,16 @@ function M.setup(opts) M.load("autocmds") end M.load("keymaps") + Util.format.setup() - Util.root.setup() + + vim.api.nvim_create_user_command("LazyRoot", function() + Util.root.info() + end, { desc = "LazyVim roots for the current buffer" }) + + vim.api.nvim_create_user_command("LazyExtras", function() + Util.extras.show() + end, { desc = "Manage LazyVim extras" }) end, }) diff --git a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua b/lua/lazyvim/plugins/extras/linting/nvim-lint.lua deleted file mode 100644 index 1fb7ab5d..00000000 --- a/lua/lazyvim/plugins/extras/linting/nvim-lint.lua +++ /dev/null @@ -1,67 +0,0 @@ -return { - { - "mfussenegger/nvim-lint", - event = "LazyFile", - opts = { - -- Event to trigger linters - events = { "BufWritePost", "BufReadPost", "InsertLeave" }, - linters_by_ft = { - fish = { "fish" }, - }, - -- LazyVim extension to easily override linter options - -- or add custom linters. - ---@type table - linters = { - -- -- Example of using selene only when a selene.toml file is present - -- selene = { - -- -- `condition` is another LazyVim extension that allows you to - -- -- dynamically enable/disable linters based on the context. - -- condition = function(ctx) - -- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1] - -- end, - -- }, - }, - }, - config = function(_, opts) - local M = {} - - local lint = require("lint") - for name, linter in pairs(opts.linters) do - if type(linter) == "table" and type(lint.linters) == "table" then - lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) - end - end - lint.linters_by_ft = opts.linters_by_ft - - function M.debounce(ms, fn) - local timer = vim.loop.new_timer() - return function(...) - local argv = { ... } - timer:start(ms, 0, function() - timer:stop() - vim.schedule_wrap(fn)(unpack(argv)) - end) - end - end - - function M.lint() - local names = lint.linters_by_ft[vim.bo.filetype] or {} - local ctx = { filename = vim.api.nvim_buf_get_name(0) } - ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") - names = vim.tbl_filter(function(name) - local linter = lint.linters[name] - return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) - end, names) - - if #names > 0 then - lint.try_lint(names) - end - end - - vim.api.nvim_create_autocmd(opts.events, { - group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }), - callback = M.debounce(100, M.lint), - }) - end, - }, -} diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua new file mode 100644 index 00000000..0a6ed614 --- /dev/null +++ b/lua/lazyvim/plugins/xtras.lua @@ -0,0 +1,6 @@ +local Config = require("lazyvim.config") + +---@param extra string +return vim.tbl_map(function(extra) + return { import = "lazyvim.plugins.extras." .. extra } +end, Config.json.data.extras) diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua new file mode 100644 index 00000000..6e7bb742 --- /dev/null +++ b/lua/lazyvim/util/extras.lua @@ -0,0 +1,202 @@ +local Config = require("lazyvim.config") +local Float = require("lazy.view.float") +local LazyConfig = require("lazy.core.config") +local Plugin = require("lazy.core.plugin") +local Text = require("lazy.view.text") +local Util = require("lazyvim.util") + +---@class LazyExtra +---@field name string +---@field enabled boolean +---@field managed boolean +---@field row? number +---@field plugins string[] + +---@class lazyvim.util.extras +local M = {} + +M.prios = { + ["editor.aerial"] = 100, + ["test.core"] = 1, + ["dap.core"] = 1, +} + +M.ns = vim.api.nvim_create_namespace("lazyvim.extras") +---@type string[] +M.state = nil + +---@return LazyExtra[] +function M.get() + M.state = M.state or LazyConfig.spec.modules + local root = LazyConfig.plugins.LazyVim.dir .. "/lua/lazyvim/plugins/extras" + local extras = {} ---@type string[] + + Util.walk(root, function(path, name, type) + if type == "file" and name:match("%.lua$") then + local extra = path:sub(#root + 2, -5):gsub("/", ".") + extras[#extras + 1] = extra + end + end) + table.sort(extras) + + ---@param extra string + return vim.tbl_map(function(extra) + local modname = "lazyvim.plugins.extras." .. extra + local enabled = vim.tbl_contains(M.state, modname) + local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = false }) + return { + name = extra, + enabled = enabled, + managed = vim.tbl_contains(Config.json.data.extras, extra) or not enabled, + plugins = vim.tbl_keys(spec.plugins), + } + end, extras) +end + +---@class LazyExtraView +---@field float LazyFloat +---@field text Text +---@field extras LazyExtra[] +---@field diag LazyDiagnostic[] +local X = {} + +---@return LazyExtraView +function X.new() + local self = setmetatable({}, { __index = X }) + self.float = Float.new({ title = "LazyVim Extras" }) + self.float:on_key("x", function() + self:toggle() + end, "Toggle extra") + self.diag = {} + self:update() + return self +end + +---@param diag LazyDiagnostic +function X:diagnostic(diag) + diag.row = diag.row or self.text:row() + diag.severity = diag.severity or vim.diagnostic.severity.INFO + table.insert(self.diag, diag) +end + +function X:toggle() + local pos = vim.api.nvim_win_get_cursor(self.float.win) + for _, extra in ipairs(self.extras) do + if extra.row == pos[1] then + if not extra.managed then + Util.error( + "Not managed by LazyExtras. Remove from your config to enable/disable here.", + { title = "LazyExtras" } + ) + return + end + extra.enabled = not extra.enabled + Config.json.data.extras = vim.tbl_filter(function(name) + return name ~= extra.name + end, Config.json.data.extras) + M.state = vim.tbl_filter(function(name) + return name ~= "lazyvim.plugins.extras." .. extra.name + end, M.state) + if extra.enabled then + table.insert(Config.json.data.extras, extra.name) + M.state[#M.state + 1] = "lazyvim.plugins.extras." .. extra.name + end + table.sort(Config.json.data.extras, function(a, b) + local pa = M.prios[a] or 10 + local pb = M.prios[b] or 10 + if pa == pb then + return a < b + end + return pa < pb + end) + Config.json.save() + Util.info( + "`" + .. extra.name + .. "`" + .. " " + .. (extra.enabled and "**enabled**" or "**disabled**") + .. "\nPlease restart LazyVim to apply the changes.", + { title = "LazyExtras" } + ) + self:update() + return + end + end +end + +function X:update() + self.diag = {} + self.extras = M.get() + self.text = Text.new() + self.text.padding = 2 + self:render() + self.text:trim() + vim.bo[self.float.buf].modifiable = true + self.text:render(self.float.buf) + vim.bo[self.float.buf].modifiable = false + vim.diagnostic.set( + M.ns, + self.float.buf, + ---@param diag LazyDiagnostic + vim.tbl_map(function(diag) + diag.col = 0 + diag.lnum = diag.row - 1 + return diag + end, self.diag), + { signs = false, virtual_text = true } + ) +end + +function X:render() + self.text:nl():nl():append("LazyVim Extras", "LazyH1"):nl():nl() + self.text + :append("Enable/disable extras with the ", "LazyComment") + :append("", "LazySpecial") + :append(" key", "LazyComment") + :nl() + self:section({ enabled = true, title = "Enabled" }) + self:section({ enabled = false, title = "Disabled" }) +end + +---@param extra LazyExtra +function X:extra(extra) + if not extra.managed then + self:diagnostic({ + message = "Not managed by LazyExtras (config)", + severity = vim.diagnostic.severity.WARN, + }) + end + extra.row = self.text:row() + local hl = extra.managed and "LazySpecial" or "LazyLocal" + if extra.enabled then + self.text:append(" " .. LazyConfig.options.ui.icons.loaded .. " ", hl) + else + self.text:append(" " .. LazyConfig.options.ui.icons.not_loaded .. " ", hl) + end + self.text:append(extra.name) + for _, plugin in ipairs(extra.plugins) do + self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin") + end + self.text:nl() +end + +---@param opts {enabled?:boolean, title?:string} +function X:section(opts) + opts = opts or {} + ---@type LazyExtra[] + local extras = vim.tbl_filter(function(extra) + return opts.enabled == nil or extra.enabled == opts.enabled + end, self.extras) + + self.text:nl():append(opts.title .. ":", "LazyH2"):append(" (" .. #extras .. ")", "LazyComment"):nl() + for _, extra in ipairs(extras) do + self:extra(extra) + end +end + +function M.show() + return X.new() +end + +return M diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index c46ac22e..90f9a89e 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -9,6 +9,7 @@ local LazyUtil = require("lazy.core.util") ---@field toggle lazyvim.util.toggle ---@field format lazyvim.util.format ---@field plugin lazyvim.util.plugin +---@field extras lazyvim.util.extras local M = {} ---@type table diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index fe263a7c..707ba5f8 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -106,12 +106,6 @@ function M.detect(opts) return ret end -function M.setup() - vim.api.nvim_create_user_command("LazyRoot", function() - M.info() - end, { desc = "LazyVim roots for the current buffer" }) -end - function M.info() local spec = type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec From 5bb74205a06a89f048902ba142473dd679b228b8 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 18:10:04 +0200 Subject: [PATCH 224/362] feat(dashboard): added LazyExtras shortcut to dashboard/alpha --- lua/lazyvim/plugins/extras/ui/alpha.lua | 1 + lua/lazyvim/plugins/ui.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua index 38019498..8778ab35 100644 --- a/lua/lazyvim/plugins/extras/ui/alpha.lua +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -28,6 +28,7 @@ return { dashboard.button("g", " " .. " Find text", " Telescope live_grep "), dashboard.button("c", " " .. " Config", " e $MYVIMRC "), dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("e", " " .. " LazyExtras", " LazyExtras "), dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), dashboard.button("q", " " .. " Quit", " qa "), } diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index c22e0791..3fff8082 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -383,6 +383,7 @@ return { { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "LazyExtras", desc = " LazyExtras", icon = " ", key = "e" }, { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, { action = "qa", desc = " Quit", icon = " ", key = "q" }, }, From 592f3b03bb3cd01df42ee5db4cd6ba43937f067e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 18:38:29 +0200 Subject: [PATCH 225/362] fix(root): only use workspace folders that contain the buffer --- lua/lazyvim/util/root.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 707ba5f8..54f44169 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -26,7 +26,8 @@ function M.detectors.cwd() end function M.detectors.lsp(buf) - if not M.bufpath(buf) then + local bufpath = M.bufpath(buf) + if not bufpath then return {} end local roots = {} ---@type string[] @@ -39,7 +40,10 @@ function M.detectors.lsp(buf) roots[#roots + 1] = client.config.root_dir end end - return roots + return vim.tbl_filter(function(path) + path = Util.norm(path) + return path and bufpath:find(path, 1, true) == 1 + end, roots) end ---@param patterns string[]|string From 305e82f2cacd5d0074027ea545a87a41379afc88 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 22:36:45 +0200 Subject: [PATCH 226/362] feat(navic): moved navic to extras --- lua/lazyvim/plugins/extras/editor/navic.lua | 42 +++++++++++++++++++++ lua/lazyvim/plugins/ui.lua | 27 ------------- 2 files changed, 42 insertions(+), 27 deletions(-) create mode 100644 lua/lazyvim/plugins/extras/editor/navic.lua diff --git a/lua/lazyvim/plugins/extras/editor/navic.lua b/lua/lazyvim/plugins/extras/editor/navic.lua new file mode 100644 index 00000000..359c42d4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/navic.lua @@ -0,0 +1,42 @@ +return { + -- lsp symbol navigation for lualine. This shows where + -- in the code structure you are - within functions, classes, + -- etc - in the statusline. + { + "SmiteshP/nvim-navic", + lazy = true, + init = function() + vim.g.navic_silence = true + require("lazyvim.util").lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/documentSymbol") then + require("nvim-navic").attach(client, buffer) + end + end) + end, + opts = function() + return { + separator = " ", + highlight = true, + depth_limit = 5, + icons = require("lazyvim.config").icons.kinds, + lazy_update_context = true, + } + end, + }, + + -- lualine integration + { + "nvim-lualine/lualine.nvim", + optional = true, + opts = function(_, opts) + table.insert(opts.sections.lualine_c, { + function() + return require("nvim-navic").get_location() + end, + cond = function() + return package.loaded["nvim-navic"] and require("nvim-navic").is_available() + end, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 3fff8082..4ab461fa 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -141,8 +141,6 @@ return { { "filename", path = 1, symbols = { modified = "  ", readonly = "", unnamed = "" } }, -- stylua: ignore { - function() return require("nvim-navic").get_location() end, - cond = function() return package.loaded["nvim-navic"] and require("nvim-navic").is_available() end, }, }, lualine_x = { @@ -308,31 +306,6 @@ return { }, }, - -- lsp symbol navigation for lualine. This shows where - -- in the code structure you are - within functions, classes, - -- etc - in the statusline. - { - "SmiteshP/nvim-navic", - lazy = true, - init = function() - vim.g.navic_silence = true - require("lazyvim.util").lsp.on_attach(function(client, buffer) - if client.supports_method("textDocument/documentSymbol") then - require("nvim-navic").attach(client, buffer) - end - end) - end, - opts = function() - return { - separator = " ", - highlight = true, - depth_limit = 5, - icons = require("lazyvim.config").icons.kinds, - lazy_update_context = true, - } - end, - }, - -- icons { "nvim-tree/nvim-web-devicons", lazy = true }, From 8d7361c4602993a7ea119cb7ce78d421b6787dfb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 22:37:28 +0200 Subject: [PATCH 227/362] feat(root): cached pretty path function for statuslines --- lua/lazyvim/plugins/ui.lua | 5 +++-- lua/lazyvim/util/root.lua | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 4ab461fa..a364d460 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -138,9 +138,10 @@ return { }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { "filename", path = 1, symbols = { modified = "  ", readonly = "", unnamed = "" } }, - -- stylua: ignore { + function() + return Util.root.pretty_path() + end, }, }, lualine_x = { diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 54f44169..d799fe44 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -144,4 +144,38 @@ function M.get() return roots[1] and roots[1].paths[1] or vim.loop.cwd() end +M.pretty_cache = {} ---@type table +function M.pretty_path() + local path = vim.fn.expand("%:p") --[[@as string]] + if path == "" then + return "" + end + + path = Util.norm(path) + if M.pretty_cache[path] then + return M.pretty_cache[path] + end + local cache_key = path + local cwd = M.realpath(vim.loop.cwd()) or "" + + if path:find(cwd, 1, true) == 1 then + path = path:sub(#cwd + 2) + else + local roots = M.detect({ spec = { ".git" } }) + local root = roots[1] and roots[1].paths[1] or nil + if root then + path = path:sub(#vim.fs.dirname(root) + 2) + end + end + + local sep = package.config:sub(1, 1) + local parts = vim.split(path, "[\\/]") + if #parts > 3 then + parts = { parts[1], "…", parts[#parts - 1], parts[#parts] } + end + local ret = table.concat(parts, sep) + M.pretty_cache[cache_key] = ret + return ret +end + return M From e239235cd34ac9c286eac1e620670784566ef673 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 22:38:10 +0200 Subject: [PATCH 228/362] feat(util): inject module --- lua/lazyvim/config/init.lua | 4 +--- lua/lazyvim/util/init.lua | 1 + lua/lazyvim/util/inject.lua | 20 ++++++++++++++++++++ lua/lazyvim/util/plugin.lua | 22 +++++++++++----------- 4 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 lua/lazyvim/util/inject.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 076a003e..04c43f05 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -210,9 +210,7 @@ function M.init() -- after installing missing plugins M.load("options") - Util.plugin.fix_imports() - Util.plugin.fix_renames() - Util.plugin.lazy_file() + Util.plugin.setup() M.json.load() end diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 90f9a89e..5cfd4e77 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -10,6 +10,7 @@ local LazyUtil = require("lazy.core.util") ---@field format lazyvim.util.format ---@field plugin lazyvim.util.plugin ---@field extras lazyvim.util.extras +---@field inject lazyvim.util.inject local M = {} ---@type table diff --git a/lua/lazyvim/util/inject.lua b/lua/lazyvim/util/inject.lua new file mode 100644 index 00000000..bf0d11f3 --- /dev/null +++ b/lua/lazyvim/util/inject.lua @@ -0,0 +1,20 @@ +---@class lazyvim.util.inject +local M = {} + +---@generic A: any +---@generic B: any +---@generic C: any +---@generic F: function +---@param fn F|fun(a:A, b:B, c:C) +---@param wrapper fun(a:A, b:B, c:C): boolean? +---@return F +function M.args(fn, wrapper) + return function(...) + if wrapper(...) == false then + return + end + return fn(...) + end +end + +return M diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index b3650eaa..7491ca7d 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -21,6 +21,12 @@ M.renames = { ["null-ls.nvim"] = "none-ls.nvim", } +function M.setup() + M.fix_imports() + M.fix_renames() + M.lazy_file() +end + -- Properly load file based plugins without blocking the UI function M.lazy_file() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 @@ -86,23 +92,18 @@ function M.lazy_file() end function M.fix_imports() - local import = Plugin.Spec.import - ---@diagnostic disable-next-line: duplicate-set-field - function Plugin.Spec:import(spec) + Plugin.Spec.import = Util.inject.args(Plugin.Spec.import, function(_, spec) local dep = M.deprecated_extras[spec and spec.import] if dep then dep = dep .. "\n" .. "Please remove the extra to hide this warning." Util.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 }) - return + return false end - return import(self, spec) - end + end) end function M.fix_renames() - local add = Plugin.Spec.add - ---@diagnostic disable-next-line: duplicate-set-field - Plugin.Spec.add = function(self, plugin, ...) + Plugin.Spec.add = Util.inject.args(Plugin.Spec.add, function(self, plugin) if type(plugin) == "table" then if M.renames[plugin[1]] then Util.warn( @@ -116,8 +117,7 @@ function M.fix_renames() plugin[1] = M.renames[plugin[1]] end end - return add(self, plugin, ...) - end + end) end return M From d8250910bdc4fce7ede914811f786d75ca028b48 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 22:38:38 +0200 Subject: [PATCH 229/362] style(config): mini.align icons --- lua/lazyvim/config/init.lua | 91 +++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 04c43f05..b3146eef 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -20,65 +20,68 @@ local defaults = { -- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua }, -- icons used by other plugins + -- stylua: ignore icons = { misc = { dots = "󰇘", }, dap = { - Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, - Breakpoint = " ", + Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", BreakpointCondition = " ", - BreakpointRejected = { " ", "DiagnosticError" }, - LogPoint = ".>", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", }, diagnostics = { Error = " ", - Warn = " ", - Hint = " ", - Info = " ", + Warn = " ", + Hint = " ", + Info = " ", }, git = { - added = " ", + added = " ", modified = " ", - removed = " ", + removed = " ", }, kinds = { - Array = " ", - Boolean = " ", - Class = " ", - Codeium = "󰘦 ", - Color = " ", - Constant = " ", - Constructor = " ", - Copilot = " ", - Enum = " ", - EnumMember = " ", - Event = " ", - Field = " ", - File = " ", - Folder = " ", - Function = " ", - Interface = " ", - Key = " ", - Keyword = " ", - Method = " ", - Module = " ", - Namespace = " ", - Null = " ", - Number = " ", - Object = " ", - Operator = " ", - Package = " ", - Property = " ", - Reference = " ", - Snippet = " ", - String = " ", - Struct = " ", - Text = " ", + Array = " ", + Boolean = "󰨙 ", + Class = " ", + Codeium = "󰘦 ", + Color = " ", + Control = " ", + Collapsed = " ", + Constant = "󰏿 ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = "󰊕 ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = "󰊕 ", + Module = " ", + Namespace = "󰦮 ", + Null = " ", + Number = "󰎠 ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = "󰆼 ", + Text = " ", TypeParameter = " ", - Unit = " ", - Value = " ", - Variable = " ", + Unit = " ", + Value = " ", + Variable = "󰀫 ", }, }, } From cb7f5aca7a04cf2d1d06397e9a80fe078d17976b Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 11 Oct 2023 22:39:24 +0200 Subject: [PATCH 230/362] feat(treesitter): install nvim-ts-autotag by default --- lua/lazyvim/plugins/treesitter.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 47e58f1d..e4b50966 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -103,4 +103,10 @@ return { require("nvim-treesitter.configs").setup(opts) end, }, + -- Automatically add closing tags for HTML and JSX + { + "windwp/nvim-ts-autotag", + event = "InsertEnter", + opts = {}, + }, } From eb7a7d7a8e586d30ed6839f4a621e0f019d32410 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 00:09:04 +0200 Subject: [PATCH 231/362] feat(config): make kind filter configurable for telescope/aerial/... --- lua/lazyvim/config/init.lua | 31 +++++++++++++++++++++++++ lua/lazyvim/plugins/editor.lua | 42 ++++++++-------------------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index b3146eef..217f0d53 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -84,6 +84,26 @@ local defaults = { Variable = "󰀫 ", }, }, + ---@type table? + kind_filter = { + default = { + "Class", + "Constructor", + "Enum", + "Field", + "Function", + "Interface", + "Method", + "Module", + "Property", + "Struct", + "Trait", + }, + -- you can specify a different filter for each filetype + -- lua = { + -- "Function", + -- }, + }, } M.json = { @@ -167,6 +187,17 @@ function M.setup(opts) Util.track() end +---@param buf? number +---@return string[]? +function M.get_kind_filter(buf) + buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf + local ft = vim.bo[buf].filetype + if M.kind_filter == false then + return + end + return M.kind_filter[ft] or M.kind_filter.default +end + ---@param name "autocmds" | "options" | "keymaps" function M.load(name) local function _load(mod) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index e2c08b98..6e1d63b6 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -150,42 +150,20 @@ return { { "uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "ss", - Util.telescope("lsp_document_symbols", { - symbols = { - "Class", - "Function", - "Method", - "Constructor", - "Interface", - "Module", - "Struct", - "Trait", - "Field", - "Property", - "Enum", - "Constant", - }, - }), + function() + require("telescope.builtin").lsp_document_symbols({ + symbols = require("lazyvim.config").get_kind_filter(), + }) + end, desc = "Goto Symbol", }, { "sS", - Util.telescope("lsp_dynamic_workspace_symbols", { - symbols = { - "Class", - "Function", - "Method", - "Constructor", - "Interface", - "Module", - "Struct", - "Trait", - "Field", - "Property", - "Enum", - "Constant", - }, - }), + function() + require("telescope.builtin").lsp_dynamic_workspace_symbols({ + symbols = require("lazyvim.config").get_kind_filter(), + }) + end, desc = "Goto Symbol (Workspace)", }, }, From 13dbe4ad55a4e4b9a3dd345521b359411cdc5879 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 00:09:38 +0200 Subject: [PATCH 232/362] perf(lualine): get rid of lualine's weird lualine_require --- lua/lazyvim/plugins/ui.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index a364d460..bef741ec 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -113,6 +113,10 @@ return { end end, opts = function() + -- PERF: we don't need this lualine require madness 🤷 + local lualine_require = require("lualine_require") + lualine_require.require = require + local icons = require("lazyvim.config").icons local Util = require("lazyvim.util") From 7b2c31740782fb0754ce715be6ea128083e48c4f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 00:11:12 +0200 Subject: [PATCH 233/362] feat(treesitter): add nvim-treesitter-context by default --- lua/lazyvim/plugins/treesitter.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index e4b50966..c833a707 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -103,6 +103,15 @@ return { require("nvim-treesitter.configs").setup(opts) end, }, + + -- Show context of the current function + { + "nvim-treesitter/nvim-treesitter-context", + event = "LazyFile", + enabled = true, + opts = { mode = "cursor" }, + }, + -- Automatically add closing tags for HTML and JSX { "windwp/nvim-ts-autotag", From b43c57d943b2a13460d45f01a288e98cb54f2c1f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 00:11:33 +0200 Subject: [PATCH 234/362] feat: added aerial extra with integrations for edgy, telescope and lualine --- lua/lazyvim/plugins/extras/editor/aerial.lua | 133 +++++++++++++++++++ lua/lazyvim/util/plugin.lua | 9 ++ 2 files changed, 142 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/editor/aerial.lua diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua new file mode 100644 index 00000000..2d86d0d0 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -0,0 +1,133 @@ +local Config = require("lazyvim.config") +local Util = require("lazyvim.util") + +return { + { + "stevearc/aerial.nvim", + event = "LazyFile", + opts = function() + ---@diagnostic disable-next-line: no-unknown + local lualine = require("lualine.components.aerial") + + -- Strip trailing spaces from symbols in statusline + ---@param _ any + ---@param symbols {icon?:string}[] + lualine.format_status = Util.inject.args(lualine.format_status, function(_, symbols) + for _, s in ipairs(symbols) do + s.icon = s.icon and s.icon:gsub("%s*$", "") or nil + end + end) + + local icons = vim.deepcopy(Config.icons.kinds) + + -- HACK: fix lua's weird choice for `Package` for control + -- structures like if/else/for/etc. + icons.lua = { Package = icons.Control } + + ---@type table|false + local filter_kind = false + if Config.kind_filter then + filter_kind = assert(vim.deepcopy(Config.kind_filter)) + filter_kind._ = filter_kind.default + filter_kind.default = nil + end + + local opts = { + attach_mode = "global", + backends = { "lsp", "treesitter", "markdown", "man" }, + show_guides = true, + layout = { + resize_to_content = false, + win_opts = { + winhl = "Normal:NormalFloat,FloatBorder:NormalFloat,SignColumn:SignColumnSB", + signcolumn = "yes", + statuscolumn = " ", + }, + }, + icons = icons, + filter_kind = filter_kind, + -- stylua: ignore + guides = { + mid_item = "├╴", + last_item = "└╴", + nested_top = "│ ", + whitespace = " ", + }, + } + return opts + end, + keys = { + { "cs", "SymbolsOutline", desc = "Symbols Outline" }, + }, + }, + + -- Telescope integration + { + "nvim-telescope/telescope.nvim", + opts = function() + Util.on_load("telescope.nvim", function() + require("telescope").load_extension("aerial") + end) + end, + keys = { + { + "ss", + "Telescope aerial", + desc = "Goto Symbol (Aerial)", + }, + }, + }, + + -- edgy integration + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + local edgy_idx = Util.plugin.extra_idx("ui.edgy") + local aerial_idx = Util.plugin.extra_idx("editor.aerial") + + if edgy_idx and edgy_idx > aerial_idx then + Util.warn("The `edgy.nvim` extra must be **imported** before the `aerial.nvim` extra to work properly.", { + title = "LazyVim", + }) + end + + opts.right = opts.right or {} + table.insert(opts.right, { + title = "Aerial", + ft = "aerial", + pinned = true, + open = "AerialOpen", + }) + end, + }, + + -- lualine integration + { + "nvim-lualine/lualine.nvim", + optional = true, + opts = function(_, opts) + table.insert(opts.sections.lualine_c, { + "aerial", + -- The separator to be used to separate symbols in status line. + sep = " ", + + -- The number of symbols to render top-down. In order to render only 'N' last + -- symbols, negative numbers may be supplied. For instance, 'depth = -1' can + -- be used in order to render only current symbol. + depth = 5, + + -- When 'dense' mode is on, icons are not rendered near their symbols. Only + -- a single icon that represents the kind of current symbol is rendered at + -- the beginning of status line. + dense = false, + + -- The separator to be used to separate symbols in dense mode. + dense_sep = ".", + + -- Color the symbol icons. + colored = true, + }) + end, + }, +} diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 7491ca7d..c022758f 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -27,6 +27,15 @@ function M.setup() M.lazy_file() end +function M.extra_idx(name) + local Config = require("lazy.core.config") + for i, extra in ipairs(Config.spec.modules) do + if extra == "lazyvim.plugins.extras." .. name then + return i + end + end +end + -- Properly load file based plugins without blocking the UI function M.lazy_file() M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0 From eedb4a34050443448d0b752e22803d5b1278b419 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 00:20:32 +0200 Subject: [PATCH 235/362] feat(ui): show optional plugins in a different color --- lua/lazyvim/plugins/extras/editor/aerial.lua | 1 + lua/lazyvim/util/extras.lua | 25 ++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index 2d86d0d0..9f0abdcb 100644 --- a/lua/lazyvim/plugins/extras/editor/aerial.lua +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -64,6 +64,7 @@ return { -- Telescope integration { "nvim-telescope/telescope.nvim", + optional = true, opts = function() Util.on_load("telescope.nvim", function() require("telescope").load_extension("aerial") diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index 6e7bb742..c3c2e52b 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -11,6 +11,7 @@ local Util = require("lazyvim.util") ---@field managed boolean ---@field row? number ---@field plugins string[] +---@field optional string[] ---@class lazyvim.util.extras local M = {} @@ -43,12 +44,25 @@ function M.get() return vim.tbl_map(function(extra) local modname = "lazyvim.plugins.extras." .. extra local enabled = vim.tbl_contains(M.state, modname) - local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = false }) + local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = true }) + local plugins = {} ---@type string[] + local optional = {} ---@type string[] + for _, p in pairs(spec.plugins) do + if p.optional then + optional[#optional + 1] = p.name + else + plugins[#plugins + 1] = p.name + end + end + table.sort(plugins) + table.sort(optional) + return { name = extra, enabled = enabled, managed = vim.tbl_contains(Config.json.data.extras, extra) or not enabled, - plugins = vim.tbl_keys(spec.plugins), + plugins = plugins, + optional = optional, } end, extras) end @@ -151,6 +165,10 @@ end function X:render() self.text:nl():nl():append("LazyVim Extras", "LazyH1"):nl():nl() self.text + :append("This is a list of all enabled/disabled LazyVim extras.", "LazyComment") + :nl() + :append("Each extra shows the required and optional plugins it may install.", "LazyComment") + :nl() :append("Enable/disable extras with the ", "LazyComment") :append("", "LazySpecial") :append(" key", "LazyComment") @@ -178,6 +196,9 @@ function X:extra(extra) for _, plugin in ipairs(extra.plugins) do self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin") end + for _, plugin in ipairs(extra.optional) do + self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonRequire") + end self.text:nl() end From 1c34af7f0138323d9f465437d0bcef621a8dbe94 Mon Sep 17 00:00:00 2001 From: Bassam Data <105807570+bassamsdata@users.noreply.github.com> Date: Thu, 12 Oct 2023 01:28:49 -0400 Subject: [PATCH 236/362] feat(mini.starter): adding mini.starter to lualine disabled files (#1667) --- lua/lazyvim/plugins/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index bef741ec..7f8b29c5 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -126,7 +126,7 @@ return { options = { theme = "auto", globalstatus = true, - disabled_filetypes = { statusline = { "dashboard", "alpha" } }, + disabled_filetypes = { statusline = { "dashboard", "alpha", "starter"} }, }, sections = { lualine_a = { "mode" }, From c7720275c3fa8b19c9ad7e05bfb6ed5c510bf2bb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 07:30:40 +0200 Subject: [PATCH 237/362] fix(aerial): keymap --- lua/lazyvim/plugins/extras/editor/aerial.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index 9f0abdcb..d46149b1 100644 --- a/lua/lazyvim/plugins/extras/editor/aerial.lua +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -57,7 +57,7 @@ return { return opts end, keys = { - { "cs", "SymbolsOutline", desc = "Symbols Outline" }, + { "cs", "AerialToggle", desc = "Aerial (Symbols)" }, }, }, From 85215f396b6fd4de24636a202ec1149dafa5f7b5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 09:42:31 +0200 Subject: [PATCH 238/362] fix(nlua): make nlua dap work with regular continue. Fixes #1666 --- lua/lazyvim/plugins/extras/dap/core.lua | 1 - lua/lazyvim/plugins/extras/dap/nlua.lua | 49 +++++++++++++++++++++---- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index 1f079630..72aabded 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -54,7 +54,6 @@ return { opts = { defaults = { ["d"] = { name = "+debug" }, - ["da"] = { name = "+adapters" }, }, }, }, diff --git a/lua/lazyvim/plugins/extras/dap/nlua.lua b/lua/lazyvim/plugins/extras/dap/nlua.lua index 21a9e51d..12bf63ea 100644 --- a/lua/lazyvim/plugins/extras/dap/nlua.lua +++ b/lua/lazyvim/plugins/extras/dap/nlua.lua @@ -1,24 +1,59 @@ +local Util = require("lazyvim.util") + return { "mfussenegger/nvim-dap", + launch = function(host, port) + if vim.g.nlua then + return + end + vim.o.cmdheight = 10 + local osv = require("osv") + osv.launch({ + port = port, + host = host, + args = { "--cmd", "lua vim.g.nlua = true", "--cmd", "set cmdheight=10" }, + }) + vim.defer_fn(function() + vim.cmd([[luafile %]]) + end, 2000) + end, + dependencies = { { "jbyuki/one-small-step-for-vimkind", -- stylua: ignore - keys = { - { "daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server", ft = "lua" }, - { "dal", function() require("osv").run_this() end, desc = "Adapter Lua", ft = "lua" }, - }, config = function() local dap = require("dap") - dap.adapters.nlua = function(callback, config) - callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 }) + dap.adapters.nlua = function(callback, conf) + local adapter = { + type = "server", + host = conf.host or "127.0.0.1", + port = conf.port or 8086, + } + if conf.start_neovim then + local dap_run = dap.run + dap.run = function(c) + adapter.port = c.port + adapter.host = c.host + end + require("osv").run_this() + dap.run = dap_run + end + callback(adapter) end dap.configurations.lua = { { type = "nlua", request = "attach", - name = "Attach to running Neovim instance", + name = "Run this file", + start_neovim = {}, + }, + { + type = "nlua", + request = "attach", + name = "Attach to running Neovim instance (port = 8086)", + port = 8086, }, } end, From 14f3f036e9223315f310ba9d35182690638e7bd7 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 09:42:48 +0200 Subject: [PATCH 239/362] feat(inject): util method to get upvalue --- lua/lazyvim/util/inject.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/lazyvim/util/inject.lua b/lua/lazyvim/util/inject.lua index bf0d11f3..81e0f57a 100644 --- a/lua/lazyvim/util/inject.lua +++ b/lua/lazyvim/util/inject.lua @@ -17,4 +17,18 @@ function M.args(fn, wrapper) end end +function M.get_upvalue(func, name) + local i = 1 + while true do + local n, v = debug.getupvalue(func, i) + if not n then + break + end + if n == name then + return v + end + i = i + 1 + end +end + return M From ba4b8dfecbd79f4498b04a3899a11f948c026244 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 09:43:24 +0200 Subject: [PATCH 240/362] refactor(nlua): cleanup --- lua/lazyvim/plugins/extras/dap/nlua.lua | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/lua/lazyvim/plugins/extras/dap/nlua.lua b/lua/lazyvim/plugins/extras/dap/nlua.lua index 12bf63ea..9cf0e63d 100644 --- a/lua/lazyvim/plugins/extras/dap/nlua.lua +++ b/lua/lazyvim/plugins/extras/dap/nlua.lua @@ -1,24 +1,5 @@ -local Util = require("lazyvim.util") - return { "mfussenegger/nvim-dap", - - launch = function(host, port) - if vim.g.nlua then - return - end - vim.o.cmdheight = 10 - local osv = require("osv") - osv.launch({ - port = port, - host = host, - args = { "--cmd", "lua vim.g.nlua = true", "--cmd", "set cmdheight=10" }, - }) - vim.defer_fn(function() - vim.cmd([[luafile %]]) - end, 2000) - end, - dependencies = { { "jbyuki/one-small-step-for-vimkind", From 72f3cc684bd1e8f19b2d3c56da3f359032b8c5dc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 10:18:50 +0200 Subject: [PATCH 241/362] fix(dap): copy config before overriding args --- lua/lazyvim/plugins/extras/dap/core.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index 72aabded..c9aa291a 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -1,6 +1,7 @@ ---@param config {args?:string[]|fun():string[]?} local function get_args(config) local args = type(config.args) == "function" and (config.args() or {}) or config.args or {} + config = vim.deepcopy(config) ---@cast args string[] config.args = function() local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]] From db5d28b039f656ccb47d3b9f787e8bb482cc6ec1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 10:35:47 +0200 Subject: [PATCH 242/362] fix(plugin): add nvim-treesitter-context rename warning --- lua/lazyvim/util/plugin.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index c022758f..75d49899 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -19,6 +19,7 @@ M.renames = { ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", ["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim", ["null-ls.nvim"] = "none-ls.nvim", + ["romgrk/nvim-treesitter-context"] = "nvim-treesitter/nvim-treesitter-context", } function M.setup() From 3256abda65ae03358ecdbef1c7789782440fe39e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 10:36:15 +0200 Subject: [PATCH 243/362] fix(plugin): show warning of removed core plugin when trying to load them without having the extra --- lua/lazyvim/util/plugin.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 75d49899..f23bec3b 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -14,6 +14,12 @@ M.deprecated_extras = { ["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.", } +M.deprecated_modules = { + ["null-ls"] = "lsp.none-ls", + ["nvim-navic.lib"] = "editor.navic", + ["nvim-navic"] = "editor.navic", +} + ---@type table M.renames = { ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", @@ -26,6 +32,18 @@ function M.setup() M.fix_imports() M.fix_renames() M.lazy_file() + table.insert(package.loaders, function(module) + if M.deprecated_modules[module] then + Util.warn( + ("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it."):format( + module, + M.deprecated_modules[module] + ), + { title = "LazyVim" } + ) + return function() end + end + end) end function M.extra_idx(name) From a4e393154f61b95da5835b6461e211eb94740268 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 11:14:02 +0200 Subject: [PATCH 244/362] fix(extras): make sure we use priorities to import extras in correct order --- lua/lazyvim/plugins/xtras.lua | 17 +++++++++++++++++ lua/lazyvim/util/extras.lua | 15 +-------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 0a6ed614..009bb6fa 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -1,5 +1,22 @@ local Config = require("lazyvim.config") +-- Some extras need to be loaded before others +local prios = { + ["editor.aerial"] = 100, + ["editor.symbols-outline"] = 100, + ["test.core"] = 1, + ["dap.core"] = 1, +} + +table.sort(Config.json.data.extras, function(a, b) + local pa = prios[a] or 10 + local pb = prios[b] or 10 + if pa == pb then + return a < b + end + return pa < pb +end) + ---@param extra string return vim.tbl_map(function(extra) return { import = "lazyvim.plugins.extras." .. extra } diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index c3c2e52b..c71e328c 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -16,12 +16,6 @@ local Util = require("lazyvim.util") ---@class lazyvim.util.extras local M = {} -M.prios = { - ["editor.aerial"] = 100, - ["test.core"] = 1, - ["dap.core"] = 1, -} - M.ns = vim.api.nvim_create_namespace("lazyvim.extras") ---@type string[] M.state = nil @@ -115,14 +109,7 @@ function X:toggle() table.insert(Config.json.data.extras, extra.name) M.state[#M.state + 1] = "lazyvim.plugins.extras." .. extra.name end - table.sort(Config.json.data.extras, function(a, b) - local pa = M.prios[a] or 10 - local pb = M.prios[b] or 10 - if pa == pb then - return a < b - end - return pa < pb - end) + table.sort(Config.json.data.extras) Config.json.save() Util.info( "`" From f64039f54620fe3fc9e8f464e35b184c6834ed6e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 11:14:23 +0200 Subject: [PATCH 245/362] feat(config): better kind filter default for lua to deal with luals weirdness --- lua/lazyvim/config/init.lua | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 217f0d53..2f7e0184 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -95,14 +95,28 @@ local defaults = { "Interface", "Method", "Module", + "Namespace", + "Package", "Property", "Struct", "Trait", }, -- you can specify a different filter for each filetype - -- lua = { - -- "Function", - -- }, + lua = { + "Class", + "Constructor", + "Enum", + "Field", + "Function", + "Interface", + "Method", + "Module", + "Namespace", + -- "Package", -- remove package since luals uses it for control flow structures + "Property", + "Struct", + "Trait", + }, }, } From b4ba5d881dcb801d3c502665f9767d2f75ca1110 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 11:14:44 +0200 Subject: [PATCH 246/362] feat(extras): added extra for `symbols-outline.nvim` --- .../plugins/extras/editor/symbols-outline.lua | 55 +++++++++++++++++++ lua/lazyvim/plugins/extras/ui/edgy.lua | 9 --- 2 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 lua/lazyvim/plugins/extras/editor/symbols-outline.lua diff --git a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua new file mode 100644 index 00000000..f0b0ba92 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua @@ -0,0 +1,55 @@ +local Util = require("lazyvim.util") + +return { + { + "simrat39/symbols-outline.nvim", + keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, + cmd = "SymbolsOutline", + opts = function() + local Config = require("lazyvim.config") + local defaults = require("symbols-outline.config").defaults + local opts = { + symbols = {}, + symbol_blacklist = {}, + } + + for kind, symbol in pairs(defaults.symbols) do + opts.symbols[kind] = { + icon = Config.icons.kinds[kind] or symbol.icon, + hl = symbol.hl, + } + if not vim.tbl_contains(Config.kind_filter.default, kind) then + table.insert(opts.symbol_blacklist, kind) + end + end + return opts + end, + }, + + -- edgy integration + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + local edgy_idx = Util.plugin.extra_idx("ui.edgy") + local symbols_idx = Util.plugin.extra_idx("editor.symbols-outline") + + if edgy_idx and edgy_idx > symbols_idx then + Util.warn( + "The `edgy.nvim` extra must be **imported** before the `symbols-outline.nvim` extra to work properly.", + { + title = "LazyVim", + } + ) + end + + opts.right = opts.right or {} + table.insert(opts.right, { + title = "Symbols Outline", + ft = "Outline", + pinned = true, + open = "SymbolsOutline", + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 8692d481..64e6237a 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -105,15 +105,6 @@ return { end, }, } - local Util = require("lazyvim.util") - if Util.has("symbols-outline.nvim") then - table.insert(opts.left, { - title = "Outline", - ft = "Outline", - pinned = true, - open = "SymbolsOutline", - }) - end return opts end, }, From ce74e28464daa7d694f9ab4e41fae3174e30c8b3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 11:20:46 +0200 Subject: [PATCH 247/362] feat(starter): added Lazy Extras to `mini.starter` --- lua/lazyvim/plugins/extras/ui/alpha.lua | 17 +++++++++-------- .../plugins/extras/ui/mini-starter.lua | 15 ++++++++------- lua/lazyvim/plugins/ui.lua | 19 ++++++++++--------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua index 8778ab35..d05c941c 100644 --- a/lua/lazyvim/plugins/extras/ui/alpha.lua +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -21,16 +21,17 @@ return { ]] dashboard.section.header.val = vim.split(logo, "\n") + -- stylua: ignore dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", " Telescope find_files "), - dashboard.button("n", " " .. " New file", " ene startinsert "), - dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", " Telescope live_grep "), - dashboard.button("c", " " .. " Config", " e $MYVIMRC "), + dashboard.button("f", " " .. " Find file", " Telescope find_files "), + dashboard.button("n", " " .. " New file", " ene startinsert "), + dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", " Telescope live_grep "), + dashboard.button("c", " " .. " Config", " e $MYVIMRC "), dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), - dashboard.button("e", " " .. " LazyExtras", " LazyExtras "), - dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), - dashboard.button("q", " " .. " Quit", " qa "), + dashboard.button("e", " " .. " Lazy Extras", " LazyExtras "), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), } for _, button in ipairs(dashboard.section.buttons.val) do button.opts.hl = "AlphaButtons" diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index 04a578be..6ec0e572 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -29,13 +29,14 @@ return { evaluate_single = true, header = logo, items = { - new_section("Find file", "Telescope find_files", "Telescope"), - new_section("Recent files", "Telescope oldfiles", "Telescope"), - new_section("Grep text", "Telescope live_grep", "Telescope"), - new_section("init.lua", "e $MYVIMRC", "Config"), - new_section("Lazy", "Lazy", "Config"), - new_section("New file", "ene | startinsert", "Built-in"), - new_section("Quit", "qa", "Built-in"), + new_section("Find file", "Telescope find_files", "Telescope"), + new_section("Recent files", "Telescope oldfiles", "Telescope"), + new_section("Grep text", "Telescope live_grep", "Telescope"), + new_section("init.lua", "e $MYVIMRC", "Config"), + new_section("Extras", "LazyExtras", "Config"), + new_section("Lazy", "Lazy", "Config"), + new_section("New file", "ene | startinsert", "Built-in"), + new_section("Quit", "qa", "Built-in"), new_section("Session restore", [[lua require("persistence").load()]], "Session"), }, content_hooks = { diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 7f8b29c5..e821c33e 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -126,7 +126,7 @@ return { options = { theme = "auto", globalstatus = true, - disabled_filetypes = { statusline = { "dashboard", "alpha", "starter"} }, + disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } }, }, sections = { lualine_a = { "mode" }, @@ -354,16 +354,17 @@ return { }, config = { header = vim.split(logo, "\n"), + -- stylua: ignore center = { - { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, - { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, - { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, - { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "LazyExtras", desc = " LazyExtras", icon = " ", key = "e" }, - { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, + { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "e" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, }, footer = function() local stats = require("lazy").stats() From 442077fca3cbca73746909c4bc7e1029d35fecad Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 12 Oct 2023 09:48:46 +0000 Subject: [PATCH 248/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index a950794a..ea9ed565 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 11 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 12 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 73acab16758d37982bd6b2d9b2be37c4ee83cde3 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 14:38:25 +0200 Subject: [PATCH 249/362] feat: added NEWS.md and option to automatically show when changed (enabled by default) --- NEWS.md | 65 ++++++++++++++++++++++++++++ lua/lazyvim/config/init.lua | 9 ++++ lua/lazyvim/config/keymaps.lua | 2 +- lua/lazyvim/util/init.lua | 9 +--- lua/lazyvim/util/news.lua | 77 ++++++++++++++++++++++++++++++++++ 5 files changed, 153 insertions(+), 9 deletions(-) create mode 100644 NEWS.md create mode 100644 lua/lazyvim/util/news.lua diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 00000000..af6fca2f --- /dev/null +++ b/NEWS.md @@ -0,0 +1,65 @@ +# What's new? + +## 10.x + +- `nvim-ts-autotag` is now included by default + +- `nvim-treesitter-context` is now included by default + +- Added extra for `symbols-outline.nvim` + +- Added extra for `aerial.nvim` + +- `nvim-navic` has been removed. If you want to keep using `nvim-navic`, + you can enable the **editor.navic** extra + +- New `:LazyExtras` command for managing **LazyVim** extras + +- Improved **formatting**: + + - **LazyVim** can now work with multiple formatters. Types: + + - **primary**: only one primary formatter can be active at a time. + _(conform, none-ls, LSP)_ + - **secondary**: multiple secondary formatters can be active _(eslint, ...)_ + + - **LazyVim** automatically selects the primary formatter based on the + current available sources and priorities. + + - New `:LazyFormat` command for formatting the current selection or buffer + - New `:LazyFormatInfo` command for displaying the active formatters + for the current buffer + - Auto-formatting can be disabled with: + + ```lua + vim.g.autoformat = false -- globally + vim.b.autoformat = false -- buffer-local + ``` + +- `none-ls.nvim` is no longer installed by default + + - `conform.nvim` is now the default formatter + - `nvim-lint` is now the default linter + - If you want to keep using `none-ls.nvim`, + you can enable the **lsp.none-ls** extra + +- `dashboard.nvim` is the new default dashboard plugin + + - If you want to keep using `alpha.nvim`, you can enable the **ui.alpha** extra + +- Improved **root detection**: + + - New `:LazyRoot` command that shows info about the root dir detection + - Configurable with `vim.g.root_spec` + + ```lua + -- LazyVim root dir detection + -- Each entry can be: + -- * the name of a detector function like `lsp` or `cwd` + -- * a pattern or array of patterns like `.git` or `lua`. + -- * a function with signature `function(buf) -> string|string[]` + vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } + + -- To disable root detection set to just "cwd" + vim.g.root_spec = { "cwd" } + ``` diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 2f7e0184..07bb1ed6 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -19,6 +19,13 @@ local defaults = { -- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup -- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua }, + news = { + -- When enabled, NEWS.md will be shown when changed. + -- This only contains big new features and breaking changes. + lazyvim = true, + -- Same but for Neovim's news.txt + neovim = false, + }, -- icons used by other plugins -- stylua: ignore icons = { @@ -123,6 +130,7 @@ local defaults = { M.json = { data = { version = nil, ---@type string? + hashes = {}, ---@type table extras = {}, ---@type string[] }, } @@ -173,6 +181,7 @@ function M.setup(opts) M.load("keymaps") Util.format.setup() + Util.news.setup() vim.api.nvim_create_user_command("LazyRoot", function() Util.root.info() diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 79c0ee06..bae7b15b 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -125,7 +125,7 @@ map("n", "qq", "qa", { desc = "Quit all" }) map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) -- LazyVim Changelog -map("n", "L", Util.changelog, {desc = "LazyVim Changelog"}) +map("n", "L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) -- floating terminal local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 5cfd4e77..2751e8e6 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -11,6 +11,7 @@ local LazyUtil = require("lazy.core.util") ---@field plugin lazyvim.util.plugin ---@field extras lazyvim.util.extras ---@field inject lazyvim.util.inject +---@field news lazyvim.util.news local M = {} ---@type table @@ -137,14 +138,6 @@ function M.on_load(name, fn) end end -function M.changelog() - local lv = require("lazy.core.config").plugins.LazyVim - local float = require("lazy.util").open(lv.dir .. "/CHANGELOG.md") - vim.wo[float.win].spell = false - vim.wo[float.win].wrap = false - vim.diagnostic.disable(float.buf) -end - -- Wrapper around vim.keymap.set that will -- not create a keymap if a lazy key handler exists. -- It will also set `silent` to true by default. diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua new file mode 100644 index 00000000..4e28148b --- /dev/null +++ b/lua/lazyvim/util/news.lua @@ -0,0 +1,77 @@ +local Config = require("lazyvim.config") +local Util = require("lazyvim.util") + +---@class lazyvim.util.news +local M = {} + +function M.hash(file) + local stat = vim.loop.fs_stat(file) + if not stat then + return + end + return stat.size .. "" +end + +function M.setup() + vim.schedule(function() + if Config.news.lazyvim then + M.lazyvim(true) + end + if Config.news.neovim then + M.neovim(true) + end + end) +end + +function M.changelog() + M.open("CHANGELOG.md", { plugin = "LazyVim" }) +end + +function M.lazyvim(when_changed) + M.open("NEWS.md", { plugin = "LazyVim", when_changed = when_changed }) +end + +function M.neovim(when_changed) + M.open("doc/news.txt", { rtp = true, when_changed = when_changed }) +end + +---@param file string +---@param opts? {plugin?:string, rtp?:boolean, when_changed?:boolean} +function M.open(file, opts) + opts = opts or {} + if opts.plugin then + local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]] + if not plugin then + return Util.error("plugin not found: " .. opts.plugin) + end + file = plugin.dir .. "/" .. file + elseif opts.rtp then + file = vim.api.nvim_get_runtime_file(file, false)[1] + end + + if not file then + return Util.error("File not found") + end + + if opts.when_changed then + local hash = M.hash(file) + if hash == Config.json.data.hashes[file] then + return + end + Config.json.data.hashes[file] = hash + Config.json.save() + end + + local float = require("lazy.util").float({ + file = file, + size = { width = 0.6, height = 0.6 }, + }) + vim.wo[float.win].spell = false + vim.wo[float.win].wrap = false + vim.wo[float.win].signcolumn = "yes" + vim.wo[float.win].statuscolumn = " " + vim.wo[float.win].conceallevel = 3 + vim.diagnostic.disable(float.buf) +end + +return M From 763c0fd9f296ec31119c0e7109b9b73d15553fff Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:49:38 +0200 Subject: [PATCH 250/362] chore(main): release 10.0.0 (#1673) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1136f07..1161066d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,63 @@ # Changelog +## [10.0.0](https://github.com/LazyVim/LazyVim/compare/v9.9.1...v10.0.0) (2023-10-12) + + +### ⚠ BREAKING CHANGES + +* **starter:** `dashboard.nvim` is now the default starter. To keep using `alpha.nvim`, enable the extra. +* make `conform.nvim` and `nvim-lint` the default formatters/linters + +### Features + +* added aerial extra with integrations for edgy, telescope and lualine ([b43c57d](https://github.com/LazyVim/LazyVim/commit/b43c57d943b2a13460d45f01a288e98cb54f2c1f)) +* added NEWS.md and option to automatically show when changed (enabled by default) ([73acab1](https://github.com/LazyVim/LazyVim/commit/73acab16758d37982bd6b2d9b2be37c4ee83cde3)) +* **config:** better kind filter default for lua to deal with luals weirdness ([f64039f](https://github.com/LazyVim/LazyVim/commit/f64039f54620fe3fc9e8f464e35b184c6834ed6e)) +* **config:** load/save some data in lazyvim.json ([11d66e7](https://github.com/LazyVim/LazyVim/commit/11d66e713467410add9ad5a7a68a3bca0aa24082)) +* **config:** make kind filter configurable for telescope/aerial/... ([eb7a7d7](https://github.com/LazyVim/LazyVim/commit/eb7a7d7a8e586d30ed6839f4a621e0f019d32410)) +* **config:** use lazy's new custom events (`Event.mappings`) for a better `LazyFile` ([4ea1c68](https://github.com/LazyVim/LazyVim/commit/4ea1c6865e6d877207de8626e11a5a863950ae55)) +* **dashboard:** added LazyExtras shortcut to dashboard/alpha ([5bb7420](https://github.com/LazyVim/LazyVim/commit/5bb74205a06a89f048902ba142473dd679b228b8)) +* **extras:** added extra for `symbols-outline.nvim` ([b4ba5d8](https://github.com/LazyVim/LazyVim/commit/b4ba5d881dcb801d3c502665f9767d2f75ca1110)) +* **format:** new LazyVim formatter with integrations for lsp/none-ls/conform/eslint/... ([f1a8f24](https://github.com/LazyVim/LazyVim/commit/f1a8f24a361d0de198f6b1458168652a6835c932)) +* **inject:** util method to get upvalue ([14f3f03](https://github.com/LazyVim/LazyVim/commit/14f3f036e9223315f310ba9d35182690638e7bd7)) +* make `conform.nvim` and `nvim-lint` the default formatters/linters ([14c091b](https://github.com/LazyVim/LazyVim/commit/14c091b1fc6b0dc0b22ac49ccac69f8a02e3844c)) +* **mini.starter:** adding mini.starter to lualine disabled files ([#1667](https://github.com/LazyVim/LazyVim/issues/1667)) ([1c34af7](https://github.com/LazyVim/LazyVim/commit/1c34af7f0138323d9f465437d0bcef621a8dbe94)) +* **navic:** moved navic to extras ([305e82f](https://github.com/LazyVim/LazyVim/commit/305e82f2cacd5d0074027ea545a87a41379afc88)) +* **root:** allow custom functions as part of `vim.g.root_spec` ([c33e748](https://github.com/LazyVim/LazyVim/commit/c33e7489ecdaef7295a63079410f2f24a1cbc9b6)) +* **root:** cached pretty path function for statuslines ([8d7361c](https://github.com/LazyVim/LazyVim/commit/8d7361c4602993a7ea119cb7ce78d421b6787dfb)) +* **root:** customizable root detection and `:LazyRoot` command ([a2d6049](https://github.com/LazyVim/LazyVim/commit/a2d604928b5629d14797437a26022065f7385216)) +* **starter:** `dashboard.nvim` is now the default starter. To keep using `alpha.nvim`, enable the extra. ([4cbe42c](https://github.com/LazyVim/LazyVim/commit/4cbe42cd247c72dfc70c3fcddfa3fb6b5e6485e0)) +* **starter:** added Lazy Extras to `mini.starter` ([ce74e28](https://github.com/LazyVim/LazyVim/commit/ce74e28464daa7d694f9ab4e41fae3174e30c8b3)) +* **treesitter:** add nvim-treesitter-context by default ([7b2c317](https://github.com/LazyVim/LazyVim/commit/7b2c31740782fb0754ce715be6ea128083e48c4f)) +* **treesitter:** install nvim-ts-autotag by default ([cb7f5ac](https://github.com/LazyVim/LazyVim/commit/cb7f5aca7a04cf2d1d06397e9a80fe078d17976b)) +* **ui:** added `:LazyExtras` to manage enabled extras in LazyVim ([c4e55e4](https://github.com/LazyVim/LazyVim/commit/c4e55e4d67a7195b7aa9160cd8ece3ddc2f6cb51)) +* **ui:** show optional plugins in a different color ([eedb4a3](https://github.com/LazyVim/LazyVim/commit/eedb4a34050443448d0b752e22803d5b1278b419)) +* **util:** inject module ([e239235](https://github.com/LazyVim/LazyVim/commit/e239235cd34ac9c286eac1e620670784566ef673)) + + +### Bug Fixes + +* **aerial:** keymap ([c772027](https://github.com/LazyVim/LazyVim/commit/c7720275c3fa8b19c9ad7e05bfb6ed5c510bf2bb)) +* **dap:** copy config before overriding args ([72f3cc6](https://github.com/LazyVim/LazyVim/commit/72f3cc684bd1e8f19b2d3c56da3f359032b8c5dc)) +* **extras:** make sure we use priorities to import extras in correct order ([a4e3931](https://github.com/LazyVim/LazyVim/commit/a4e393154f61b95da5835b6461e211eb94740268)) +* **format:** always show formatter status even when no sources available ([a4abbdc](https://github.com/LazyVim/LazyVim/commit/a4abbdc89bd1d49378ac5873db1279e7e5398927)) +* **lualine:** when opening nvim with a file, show an empty statusline till lualine loads ([8373467](https://github.com/LazyVim/LazyVim/commit/83734675b0f93fbd11a350ee0662c09995836b59)) +* **neo-tree:** during init check global argslist instead of window-local ([8fbde2c](https://github.com/LazyVim/LazyVim/commit/8fbde2c3668960ed085f9225bb4650aca77cc495)) +* **nlua:** make nlua dap work with regular continue. Fixes [#1666](https://github.com/LazyVim/LazyVim/issues/1666) ([85215f3](https://github.com/LazyVim/LazyVim/commit/85215f396b6fd4de24636a202ec1149dafa5f7b5)) +* **notify:** set default zindex=100 ([7fb7948](https://github.com/LazyVim/LazyVim/commit/7fb79486ed1b251b98b95a44ef50b3742edd708d)) +* **plugin:** add nvim-treesitter-context rename warning ([db5d28b](https://github.com/LazyVim/LazyVim/commit/db5d28b039f656ccb47d3b9f787e8bb482cc6ec1)) +* **plugin:** enable lazy_file ([f59cdff](https://github.com/LazyVim/LazyVim/commit/f59cdff4d9f04ff349cefdee0b363d573954ce0d)) +* **plugin:** show warning of removed core plugin when trying to load them without having the extra ([3256abd](https://github.com/LazyVim/LazyVim/commit/3256abda65ae03358ecdbef1c7789782440fe39e)) +* **root:** only use workspace folders that contain the buffer ([592f3b0](https://github.com/LazyVim/LazyVim/commit/592f3b03bb3cd01df42ee5db4cd6ba43937f067e)) +* **ui:** dont show left signs on virtual line numbers (wrap). Fixes [#1654](https://github.com/LazyVim/LazyVim/issues/1654) ([e6d294d](https://github.com/LazyVim/LazyVim/commit/e6d294df6fbd973644d4b7f9691d5f48cc5efdde)) + + +### Performance Improvements + +* **lualine:** get rid of lualine's weird lualine_require ([13dbe4a](https://github.com/LazyVim/LazyVim/commit/13dbe4ad55a4e4b9a3dd345521b359411cdc5879)) +* **plugin:** move all lazy.nvim related code to `lazyvim.util.plugin` ([70f9195](https://github.com/LazyVim/LazyVim/commit/70f91956e7f03e740b51cbc14c87df6a6f74538f)) +* **util:** split lazyvim.util in smaller separate modules ([c8c929c](https://github.com/LazyVim/LazyVim/commit/c8c929c9fdc44cc69cb034c47bd89d2bc4e4a429)) + ## [9.9.1](https://github.com/LazyVim/LazyVim/compare/v9.9.0...v9.9.1) (2023-10-11) From 7d9a3955651ba3f59389596e869affcedccaa489 Mon Sep 17 00:00:00 2001 From: Sergey Kochetkov Date: Thu, 12 Oct 2023 15:10:26 +0200 Subject: [PATCH 251/362] style(format): Fix typo (#1675) --- lua/lazyvim/util/format.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index af64a6f5..2a5ef5ac 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -130,7 +130,7 @@ function M.health() local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls") if has_plugin and not has_extra then Util.warn({ - "`conform.nvim` and `nvim-lint` are now the default forrmatters and linters in LazyVim.", + "`conform.nvim` and `nvim-lint` are now the default formatters and linters in LazyVim.", "", "You can use those plugins together with `none-ls.nvim`,", "but you need to enable the `lazyvim.plugins.extras.lsp.none-ls` extra,", From 2a0b7a88ba4b4562361dd5abb4a071547d004e59 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 17:48:49 +0200 Subject: [PATCH 252/362] fix(config): make lazyvim.json idempotent, pretty-printed and remove full paths --- lua/lazyvim/config/init.lua | 9 +++++-- lua/lazyvim/util/init.lua | 1 + lua/lazyvim/util/json.lua | 48 +++++++++++++++++++++++++++++++++++++ lua/lazyvim/util/news.lua | 5 ++-- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 lua/lazyvim/util/json.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 07bb1ed6..4a9a0f22 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -130,7 +130,7 @@ local defaults = { M.json = { data = { version = nil, ---@type string? - hashes = {}, ---@type table + news = {}, ---@type table extras = {}, ---@type string[] }, } @@ -144,6 +144,11 @@ function M.json.load() local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } }) if ok then M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {}) + if M.json.data.hashes then + ---@diagnostic disable-next-line: no-unknown + M.json.data.hashes = nil + M.json.save() + end end end end @@ -152,7 +157,7 @@ function M.json.save() local path = vim.fn.stdpath("config") .. "/lazyvim.json" local f = io.open(path, "w") if f then - f:write(vim.json.encode(M.json.data)) + f:write(Util.json.encode(M.json.data)) f:close() end end diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 2751e8e6..ac2b4055 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -12,6 +12,7 @@ local LazyUtil = require("lazy.core.util") ---@field extras lazyvim.util.extras ---@field inject lazyvim.util.inject ---@field news lazyvim.util.news +---@field json lazyvim.util.json local M = {} ---@type table diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua new file mode 100644 index 00000000..73c4fb15 --- /dev/null +++ b/lua/lazyvim/util/json.lua @@ -0,0 +1,48 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.json +local M = {} + +---@param value any +---@param indent string +local function encode(value, indent) + local t = type(value) + + if t == "string" then + return string.format("%q", value) + elseif t == "number" or t == "boolean" then + return tostring(value) + elseif t == "table" then + local is_list = Util.is_list(value) + local parts = {} + local next_indent = indent .. " " + + if is_list then + ---@diagnostic disable-next-line: no-unknown + for _, v in ipairs(value) do + local e = encode(v, next_indent) + if e then + table.insert(parts, next_indent .. e) + end + end + return "[\n" .. table.concat(parts, ",\n") .. "\n" .. indent .. "]" + else + local keys = vim.tbl_keys(value) + table.sort(keys) + ---@diagnostic disable-next-line: no-unknown + for _, k in ipairs(keys) do + local e = encode(value[k], next_indent) + if e then + table.insert(parts, next_indent .. string.format("%q", k) .. ": " .. e) + end + end + return "{\n" .. table.concat(parts, ",\n") .. "\n" .. indent .. "}" + end + end +end + +function M.encode(value) + return encode(value, "") +end + +return M diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua index 4e28148b..a4517bf5 100644 --- a/lua/lazyvim/util/news.lua +++ b/lua/lazyvim/util/news.lua @@ -38,6 +38,7 @@ end ---@param file string ---@param opts? {plugin?:string, rtp?:boolean, when_changed?:boolean} function M.open(file, opts) + local ref = file opts = opts or {} if opts.plugin then local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]] @@ -55,10 +56,10 @@ function M.open(file, opts) if opts.when_changed then local hash = M.hash(file) - if hash == Config.json.data.hashes[file] then + if hash == Config.json.data.news[ref] then return end - Config.json.data.hashes[file] = hash + Config.json.data.news[ref] = hash Config.json.save() end From 7c7b4be8dbec5c5e888d02ebdaae944fecf99407 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 17:59:48 +0200 Subject: [PATCH 253/362] fix(toggle): dont show incorrect deprecation warning for toggle. Fixes #1679 --- lua/lazyvim/util/init.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index ac2b4055..ddfa55f8 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -23,7 +23,6 @@ local deprecated = { root_patterns = { "root", "patterns" }, get_root = { "root", "get" }, float_term = { "terminal", "open" }, - toggle = { "toggle", "option" }, toggle_diagnostics = { "toggle", "diagnostics" }, toggle_number = { "toggle", "number" }, fg = "ui", From 666a69e6e0eb3db17810a426b884081d1cc4ad3d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 18:07:04 +0200 Subject: [PATCH 254/362] chore(main): release 10.0.1 (#1680) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1161066d..318e04e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [10.0.1](https://github.com/LazyVim/LazyVim/compare/v10.0.0...v10.0.1) (2023-10-12) + + +### Bug Fixes + +* **config:** make lazyvim.json idempotent, pretty-printed and remove full paths ([2a0b7a8](https://github.com/LazyVim/LazyVim/commit/2a0b7a88ba4b4562361dd5abb4a071547d004e59)) +* **toggle:** dont show incorrect deprecation warning for toggle. Fixes [#1679](https://github.com/LazyVim/LazyVim/issues/1679) ([7c7b4be](https://github.com/LazyVim/LazyVim/commit/7c7b4be8dbec5c5e888d02ebdaae944fecf99407)) + ## [10.0.0](https://github.com/LazyVim/LazyVim/compare/v9.9.1...v10.0.0) (2023-10-12) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 4a9a0f22..3f84e91a 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.0.0" -- x-release-please-version +M.version = "10.0.1" -- x-release-please-version ---@class LazyVimOptions local defaults = { From cdae38ddd44edbf5e124129fc94e9d1038592760 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 20:28:56 +0200 Subject: [PATCH 255/362] fix(nvim-lint): check on linter name instead of linter. Fixes #1685 --- lua/lazyvim/plugins/linting.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua index 1fb7ab5d..52ff9bee 100644 --- a/lua/lazyvim/plugins/linting.lua +++ b/lua/lazyvim/plugins/linting.lua @@ -27,7 +27,7 @@ return { local lint = require("lint") for name, linter in pairs(opts.linters) do - if type(linter) == "table" and type(lint.linters) == "table" then + if type(linter) == "table" and type(lint.linters[name]) == "table" then lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) end end From 8e71968c2bd9e59e535cdac0a99e667f8f120322 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 20:43:11 +0200 Subject: [PATCH 256/362] fix(nvim-lint): make sure to set custom linters. Fixes #1687 --- lua/lazyvim/plugins/linting.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua index 52ff9bee..db9fe9c3 100644 --- a/lua/lazyvim/plugins/linting.lua +++ b/lua/lazyvim/plugins/linting.lua @@ -29,6 +29,8 @@ return { for name, linter in pairs(opts.linters) do if type(linter) == "table" and type(lint.linters[name]) == "table" then lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter) + else + lint.linters[name] = linter end end lint.linters_by_ft = opts.linters_by_ft From c9892652d271663f52edd7b0d88d2565d8f65a52 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 21:45:32 +0200 Subject: [PATCH 257/362] feat(config): `lazyvim.json` is now versioned and migrates to a newer version when needed --- lua/lazyvim/config/init.lua | 16 +++------------- lua/lazyvim/util/json.lua | 30 ++++++++++++++++++++++++++++++ lua/lazyvim/util/news.lua | 2 +- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 3f84e91a..69561c1d 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -128,6 +128,7 @@ local defaults = { } M.json = { + version = 1, data = { version = nil, ---@type string? news = {}, ---@type table @@ -144,24 +145,13 @@ function M.json.load() local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } }) if ok then M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {}) - if M.json.data.hashes then - ---@diagnostic disable-next-line: no-unknown - M.json.data.hashes = nil - M.json.save() + if M.json.data.version ~= M.json.version then + Util.json.migrate() end end end end -function M.json.save() - local path = vim.fn.stdpath("config") .. "/lazyvim.json" - local f = io.open(path, "w") - if f then - f:write(Util.json.encode(M.json.data)) - f:close() - end -end - ---@type LazyVimOptions local options diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index 73c4fb15..b8428add 100644 --- a/lua/lazyvim/util/json.lua +++ b/lua/lazyvim/util/json.lua @@ -1,3 +1,4 @@ +local Config = require("lazyvim.config") local Util = require("lazyvim.util") ---@class lazyvim.util.json @@ -45,4 +46,33 @@ function M.encode(value) return encode(value, "") end +function M.save() + local path = vim.fn.stdpath("config") .. "/lazyvim.json" + local f = io.open(path, "w") + if f then + f:write(Util.json.encode(Config.json.data)) + f:close() + end +end + +function M.migrate() + Util.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`") + local json = Config.json + + -- v0 + if not json.data.version then + if json.data.hashes then + ---@diagnostic disable-next-line: no-unknown + json.data.hashes = nil + end + json.data.extras = vim.tbl_map(function(extra) + return "lazyvim.plugins.extras." .. extra + end, json.data.extras or {}) + end + + json.data.version = Config.json.version + + M.save() +end + return M diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua index a4517bf5..11707155 100644 --- a/lua/lazyvim/util/news.lua +++ b/lua/lazyvim/util/news.lua @@ -60,7 +60,7 @@ function M.open(file, opts) return end Config.json.data.news[ref] = hash - Config.json.save() + Util.json.save() end local float = require("lazy.util").float({ From 1bcf6b9a282bc839d4fde92a94b800185ad58118 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 12 Oct 2023 21:47:31 +0200 Subject: [PATCH 258/362] feat(extras): LazyExtras can now manage user extras `lua/plugins/extras`. Fixes #1681 --- NEWS.md | 3 + lua/lazyvim/plugins/xtras.lua | 10 ++-- lua/lazyvim/util/extras.lua | 102 ++++++++++++++++++++++------------ 3 files changed, 74 insertions(+), 41 deletions(-) diff --git a/NEWS.md b/NEWS.md index af6fca2f..50b72da3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,9 @@ ## 10.x +- User extras under `lua/plugins/extras` can now also be managed + with **LazyExtras** + - `nvim-ts-autotag` is now included by default - `nvim-treesitter-context` is now included by default diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 009bb6fa..4eb73804 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -2,10 +2,10 @@ local Config = require("lazyvim.config") -- Some extras need to be loaded before others local prios = { - ["editor.aerial"] = 100, - ["editor.symbols-outline"] = 100, - ["test.core"] = 1, - ["dap.core"] = 1, + ["lazyvim.plugins.extras.editor.aerial"] = 100, + ["lazyvim.plugins.extras.editor.symbols-outline"] = 100, + ["lazyvim.plugins.extras.test.core"] = 1, + ["lazyvim.plugins.extras.dap.core"] = 1, } table.sort(Config.json.data.extras, function(a, b) @@ -19,5 +19,5 @@ end) ---@param extra string return vim.tbl_map(function(extra) - return { import = "lazyvim.plugins.extras." .. extra } + return { import = extra } end, Config.json.data.extras) diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index c71e328c..0417b81e 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -5,8 +5,16 @@ local Plugin = require("lazy.core.plugin") local Text = require("lazy.view.text") local Util = require("lazyvim.util") +---@class LazyExtraSource +---@field name string +---@field desc? string +---@field module string + ---@class LazyExtra ---@field name string +---@field source LazyExtraSource +---@field module string +---@field desc? string ---@field enabled boolean ---@field managed boolean ---@field row? number @@ -16,6 +24,12 @@ local Util = require("lazyvim.util") ---@class lazyvim.util.extras local M = {} +---@type LazyExtraSource[] +M.sources = { + { name = "LazyVim", desc = "LazyVim extras", module = "lazyvim.plugins.extras" }, + { name = "User", desc = "User extras", module = "plugins.extras" }, +} + M.ns = vim.api.nvim_create_namespace("lazyvim.extras") ---@type string[] M.state = nil @@ -23,42 +37,52 @@ M.state = nil ---@return LazyExtra[] function M.get() M.state = M.state or LazyConfig.spec.modules - local root = LazyConfig.plugins.LazyVim.dir .. "/lua/lazyvim/plugins/extras" - local extras = {} ---@type string[] - - Util.walk(root, function(path, name, type) - if type == "file" and name:match("%.lua$") then - local extra = path:sub(#root + 2, -5):gsub("/", ".") - extras[#extras + 1] = extra + local extras = {} ---@type LazyExtra[] + for _, source in ipairs(M.sources) do + local root = Util.find_root(source.module) + if root then + Util.walk(root, function(path, name, type) + if type == "file" and name:match("%.lua$") then + name = path:sub(#root + 2, -5):gsub("/", ".") + extras[#extras + 1] = M.get_extra(source, source.module .. "." .. name) + end + end) end + end + table.sort(extras, function(a, b) + return a.name < b.name end) - table.sort(extras) + return extras +end - ---@param extra string - return vim.tbl_map(function(extra) - local modname = "lazyvim.plugins.extras." .. extra - local enabled = vim.tbl_contains(M.state, modname) - local spec = Plugin.Spec.new({ import = "lazyvim.plugins.extras." .. extra }, { optional = true }) - local plugins = {} ---@type string[] - local optional = {} ---@type string[] - for _, p in pairs(spec.plugins) do - if p.optional then - optional[#optional + 1] = p.name - else - plugins[#plugins + 1] = p.name - end +---@param modname string +---@param source LazyExtraSource +function M.get_extra(source, modname) + local enabled = vim.tbl_contains(M.state, modname) + local spec = Plugin.Spec.new({ import = modname }, { optional = true }) + local plugins = {} ---@type string[] + local optional = {} ---@type string[] + for _, p in pairs(spec.plugins) do + if p.optional then + optional[#optional + 1] = p.name + else + plugins[#plugins + 1] = p.name end - table.sort(plugins) - table.sort(optional) + end + table.sort(plugins) + table.sort(optional) - return { - name = extra, - enabled = enabled, - managed = vim.tbl_contains(Config.json.data.extras, extra) or not enabled, - plugins = plugins, - optional = optional, - } - end, extras) + ---@type LazyExtra + return { + source = source, + name = modname:sub(#source.module + 2), + module = modname, + enabled = enabled, + desc = require(modname).desc, + managed = vim.tbl_contains(Config.json.data.extras, modname) or not enabled, + plugins = plugins, + optional = optional, + } end ---@class LazyExtraView @@ -100,17 +124,17 @@ function X:toggle() end extra.enabled = not extra.enabled Config.json.data.extras = vim.tbl_filter(function(name) - return name ~= extra.name + return name ~= extra.module end, Config.json.data.extras) M.state = vim.tbl_filter(function(name) - return name ~= "lazyvim.plugins.extras." .. extra.name + return name ~= extra.module end, M.state) if extra.enabled then - table.insert(Config.json.data.extras, extra.name) - M.state[#M.state + 1] = "lazyvim.plugins.extras." .. extra.name + table.insert(Config.json.data.extras, extra.module) + M.state[#M.state + 1] = extra.module end table.sort(Config.json.data.extras) - Config.json.save() + Util.json.save() Util.info( "`" .. extra.name @@ -180,12 +204,18 @@ function X:extra(extra) self.text:append(" " .. LazyConfig.options.ui.icons.not_loaded .. " ", hl) end self.text:append(extra.name) + if extra.source.name ~= "LazyVim" then + self.text:append(" "):append(LazyConfig.options.ui.icons.event .. " " .. extra.source.name, "LazyReasonEvent") + end for _, plugin in ipairs(extra.plugins) do self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin") end for _, plugin in ipairs(extra.optional) do self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonRequire") end + if extra.desc then + self.text:nl():append(" " .. extra.desc, "LazyComment") + end self.text:nl() end From b31d71da9d6ca6c290a8ee7e7cc7ad5ccb3cc0bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BAc=20H=2E=20L=C3=AA=20Kh=E1=BA=AFc?= Date: Thu, 12 Oct 2023 21:52:19 +0200 Subject: [PATCH 259/362] feat(neot-ree): add keymaps to toggle git & buffer (#1339) --- lua/lazyvim/plugins/editor.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 6e1d63b6..63a8e1b1 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -24,6 +24,20 @@ return { }, { "e", "fe", desc = "Explorer NeoTree (root dir)", remap = true }, { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, + { + "ge", + function() + require("neo-tree.command").execute({ source = "git_status", toggle = true }) + end, + desc = "Git explorer", + }, + { + "be", + function() + require("neo-tree.command").execute({ source = "buffers", toggle = true }) + end, + desc = "Buffer explorer", + }, }, deactivate = function() vim.cmd([[Neotree close]]) From 1e7924878693be1570c91811fd5c55bb53c8c4d0 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 12 Oct 2023 21:56:56 +0200 Subject: [PATCH 260/362] chore(main): release 10.1.0 (#1686) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 15 +++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 318e04e5..1639dea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [10.1.0](https://github.com/LazyVim/LazyVim/compare/v10.0.1...v10.1.0) (2023-10-12) + + +### Features + +* **config:** `lazyvim.json` is now versioned and migrates to a newer version when needed ([c989265](https://github.com/LazyVim/LazyVim/commit/c9892652d271663f52edd7b0d88d2565d8f65a52)) +* **extras:** LazyExtras can now manage user extras `lua/plugins/extras`. Fixes [#1681](https://github.com/LazyVim/LazyVim/issues/1681) ([1bcf6b9](https://github.com/LazyVim/LazyVim/commit/1bcf6b9a282bc839d4fde92a94b800185ad58118)) +* **neot-ree:** add keymaps to toggle git & buffer ([#1339](https://github.com/LazyVim/LazyVim/issues/1339)) ([b31d71d](https://github.com/LazyVim/LazyVim/commit/b31d71da9d6ca6c290a8ee7e7cc7ad5ccb3cc0bd)) + + +### Bug Fixes + +* **nvim-lint:** check on linter name instead of linter. Fixes [#1685](https://github.com/LazyVim/LazyVim/issues/1685) ([cdae38d](https://github.com/LazyVim/LazyVim/commit/cdae38ddd44edbf5e124129fc94e9d1038592760)) +* **nvim-lint:** make sure to set custom linters. Fixes [#1687](https://github.com/LazyVim/LazyVim/issues/1687) ([8e71968](https://github.com/LazyVim/LazyVim/commit/8e71968c2bd9e59e535cdac0a99e667f8f120322)) + ## [10.0.1](https://github.com/LazyVim/LazyVim/compare/v10.0.0...v10.0.1) (2023-10-12) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 69561c1d..774cb7ca 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.0.1" -- x-release-please-version +M.version = "10.1.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From bd1928ba597d777ca79f9f2f4b14217de4c291bc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 07:28:02 +0200 Subject: [PATCH 261/362] fix(aerial): use new sep_icon option for aerial lualine component --- lua/lazyvim/plugins/extras/editor/aerial.lua | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index d46149b1..440c9fda 100644 --- a/lua/lazyvim/plugins/extras/editor/aerial.lua +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -2,22 +2,11 @@ local Config = require("lazyvim.config") local Util = require("lazyvim.util") return { + desc = "Aerial Symbol Browser", { "stevearc/aerial.nvim", event = "LazyFile", opts = function() - ---@diagnostic disable-next-line: no-unknown - local lualine = require("lualine.components.aerial") - - -- Strip trailing spaces from symbols in statusline - ---@param _ any - ---@param symbols {icon?:string}[] - lualine.format_status = Util.inject.args(lualine.format_status, function(_, symbols) - for _, s in ipairs(symbols) do - s.icon = s.icon and s.icon:gsub("%s*$", "") or nil - end - end) - local icons = vim.deepcopy(Config.icons.kinds) -- HACK: fix lua's weird choice for `Package` for control @@ -110,8 +99,8 @@ return { opts = function(_, opts) table.insert(opts.sections.lualine_c, { "aerial", - -- The separator to be used to separate symbols in status line. - sep = " ", + sep = " ", -- separator between symbols + sep_icon = "", -- separator between icon and symbol -- The number of symbols to render top-down. In order to render only 'N' last -- symbols, negative numbers may be supplied. For instance, 'depth = -1' can From 01dbd070738a9448ffbdc63602ed9eb5421158da Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 07:35:24 +0200 Subject: [PATCH 262/362] fix(json): always write version to prevent spurious migrations. Fixes #1692 --- lua/lazyvim/config/init.lua | 2 +- lua/lazyvim/util/json.lua | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 774cb7ca..af31f163 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -128,7 +128,7 @@ local defaults = { } M.json = { - version = 1, + version = 2, data = { version = nil, ---@type string? news = {}, ---@type table diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index b8428add..d98d0382 100644 --- a/lua/lazyvim/util/json.lua +++ b/lua/lazyvim/util/json.lua @@ -47,6 +47,7 @@ function M.encode(value) end function M.save() + Config.json.data.version = Config.json.version local path = vim.fn.stdpath("config") .. "/lazyvim.json" local f = io.open(path, "w") if f then @@ -68,10 +69,13 @@ function M.migrate() json.data.extras = vim.tbl_map(function(extra) return "lazyvim.plugins.extras." .. extra end, json.data.extras or {}) + elseif json.data.version == 1 then + json.data.extras = vim.tbl_map(function(extra) + -- replace double extras module name + return extra:gsub("^lazyvim%.plugins%.extras%.lazyvim%.plugins%.extras%.", "lazyvim.plugins.extras.") + end, json.data.extras or {}) end - json.data.version = Config.json.version - M.save() end From 66f0d55beb6604abc07110edbfc483f69660625b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 13 Oct 2023 05:36:45 +0000 Subject: [PATCH 263/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index ea9ed565..49d339b6 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 12 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 13 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 1b1d9a16ee96b73090ca1906204c41550f6528e6 Mon Sep 17 00:00:00 2001 From: Susheel Thapa <83917129+SusheelThapa@users.noreply.github.com> Date: Fri, 13 Oct 2023 11:22:07 +0545 Subject: [PATCH 264/362] docs: typos fixed in CHANGELOG.md (#1693) --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1639dea3..4573b18d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -259,7 +259,7 @@ ### Bug Fixes -* **dasboard:** disable alpha only once ([d6b56c0](https://github.com/LazyVim/LazyVim/commit/d6b56c075e88ce12e9e16fb2eeeea38fb7853600)) +* **dashboard:** disable alpha only once ([d6b56c0](https://github.com/LazyVim/LazyVim/commit/d6b56c075e88ce12e9e16fb2eeeea38fb7853600)) * **options:** set default laststatus=3 and set it to 0 before loading dashboard to prevent flickering ([1eb0192](https://github.com/LazyVim/LazyVim/commit/1eb019274b5564e66ac6c7e119c140bae262e10c)) * **tailwind:** allow overriding filetypes. Fixes [#1590](https://github.com/LazyVim/LazyVim/issues/1590) ([d3e7f77](https://github.com/LazyVim/LazyVim/commit/d3e7f7717e960bb883b35e9a75badfd5b938cace)) @@ -300,7 +300,7 @@ ### Bug Fixes -* **autocmds:** retore last location for correct buffer ([afc8e7f](https://github.com/LazyVim/LazyVim/commit/afc8e7f8cac06335efd12ec5f71cabb1f38a09b0)) +* **autocmds:** restore last location for correct buffer ([afc8e7f](https://github.com/LazyVim/LazyVim/commit/afc8e7f8cac06335efd12ec5f71cabb1f38a09b0)) * **conform:** dont try merging function formatters. Fixes [#1582](https://github.com/LazyVim/LazyVim/issues/1582) ([f475085](https://github.com/LazyVim/LazyVim/commit/f4750859f2c2c9a41b3974ac05962ce9648d6c16)) * **conform:** dont try to merge formatter functions ([9f034ab](https://github.com/LazyVim/LazyVim/commit/9f034ab10650e306e178d5189ee9214a52f2e8e5)) * **nvim-lint:** dont try merging function linters ([79010ae](https://github.com/LazyVim/LazyVim/commit/79010ae671035d8ed0040ce51df4fb59ec3962f8)) @@ -1023,7 +1023,7 @@ * **hipatterns:** default options ([3082436](https://github.com/LazyVim/LazyVim/commit/30824369c2c58647df170566766ea1dbda2730cc)) * **neotest:** added some additional filetypes to close with q ([1288f0d](https://github.com/LazyVim/LazyVim/commit/1288f0d5a5cc5f5279678cc3c3d99abe20a1e052)) -* **neotest:** support neotest adapaters that use `setup()` for custom setup ([2a3bac7](https://github.com/LazyVim/LazyVim/commit/2a3bac769045abac76395fcabb36b17b68bc42fc)) +* **neotest:** support neotest adapters that use `setup()` for custom setup ([2a3bac7](https://github.com/LazyVim/LazyVim/commit/2a3bac769045abac76395fcabb36b17b68bc42fc)) ## [4.2.0](https://github.com/LazyVim/LazyVim/compare/v4.1.1...v4.2.0) (2023-05-26) @@ -1630,7 +1630,7 @@ ### Bug Fixes -* **illuminate:** always set refernce keymaps on the buffer as well to properly overwrite ftplugin mappings. Fixes [#292](https://github.com/LazyVim/LazyVim/issues/292) ([a0cf00c](https://github.com/LazyVim/LazyVim/commit/a0cf00c81b3a4a352cdc26c94112d9a5827881e1)) +* **illuminate:** always set reference keymaps on the buffer as well to properly overwrite ftplugin mappings. Fixes [#292](https://github.com/LazyVim/LazyVim/issues/292) ([a0cf00c](https://github.com/LazyVim/LazyVim/commit/a0cf00c81b3a4a352cdc26c94112d9a5827881e1)) * **mini.surround:** don't create empty keymaps. Fixes [#296](https://github.com/LazyVim/LazyVim/issues/296) ([8e84dcf](https://github.com/LazyVim/LazyVim/commit/8e84dcf85c8a73ebcf6ade6b7b77544f468f1dfa)) * **treesitter:** disable indent only for python right now ([de6a28b](https://github.com/LazyVim/LazyVim/commit/de6a28b781e8a06e4f70c913539c97260392131a)) * **treesitter:** disable treesitter indent by default, since it has too many issues. See [#297](https://github.com/LazyVim/LazyVim/issues/297) ([329a2da](https://github.com/LazyVim/LazyVim/commit/329a2daff493abd2bd5c8fedbf0dfa13039d3931)) @@ -1774,7 +1774,7 @@ ### Bug Fixes -* **mini.ai:** load ai on VeryLazy. Keymaps interfer with which-key. [#155](https://github.com/LazyVim/LazyVim/issues/155) ([3b5f363](https://github.com/LazyVim/LazyVim/commit/3b5f36307438ad05beae6796ca005f6b56d6a360)) +* **mini.ai:** load ai on VeryLazy. Keymaps interfere with which-key. [#155](https://github.com/LazyVim/LazyVim/issues/155) ([3b5f363](https://github.com/LazyVim/LazyVim/commit/3b5f36307438ad05beae6796ca005f6b56d6a360)) * **noice:** scroll doc window in normal, insert and select mode ([c5b22c0](https://github.com/LazyVim/LazyVim/commit/c5b22c0832603198f571ff68b6fb9d0c17f73d33)) * **nvim-navic:** use kinds icons for navic. Fixes [#164](https://github.com/LazyVim/LazyVim/issues/164) ([b81ecf9](https://github.com/LazyVim/LazyVim/commit/b81ecf9f7ac78e3f87a4d9b305fa0d3cfd6decf2)) @@ -1949,7 +1949,7 @@ * **lsp:** allow overriding options for vim.lsp.buf.format. Fixes [#51](https://github.com/LazyVim/LazyVim/issues/51) ([40d363c](https://github.com/LazyVim/LazyVim/commit/40d363cf3f468a1cc4ea482eaabbd5c7e224f397)) * **lsp:** make diagnostics configurable with `{"neovim/nvim-lspconfig", opts = {diagnostics = {}}}`. Fixes [#55](https://github.com/LazyVim/LazyVim/issues/55) ([1efc925](https://github.com/LazyVim/LazyVim/commit/1efc925d16b57659cbb9af5a1579cb1b9ee9643f)) * **neo-tree:** added `<leader>e` and `E` to toggle neo-tree ([542920f](https://github.com/LazyVim/LazyVim/commit/542920fb8249d45d1e9ddbf6517a8f8539769eda)) -* **neo-tree:** load neo-tree when specifying a direcory on the cmdline ([81d798f](https://github.com/LazyVim/LazyVim/commit/81d798fdaa5bf49737969e0f15af4a90621a0a61)) +* **neo-tree:** load neo-tree when specifying a directory on the cmdline ([81d798f](https://github.com/LazyVim/LazyVim/commit/81d798fdaa5bf49737969e0f15af4a90621a0a61)) * **notify:** delay notifs till replaced or at most 500ms to prevent more prompts ([701337f](https://github.com/LazyVim/LazyVim/commit/701337fac8cb1de0f3e31400cef30b053762320f)) * **notify:** lazy-load nvim-notify to show proper notifs before Noice loads ([7406313](https://github.com/LazyVim/LazyVim/commit/74063135d838b0ed9fe1a8d0e777c8cfe83ae28f)) * **util:** use lazy's notify instead of `vim.notify` ([48d1e8d](https://github.com/LazyVim/LazyVim/commit/48d1e8df12795cf559f704223b63e76259998582)) From ea4174d46016dd191de48c03bdf23462483f9f6a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Oct 2023 07:39:24 +0200 Subject: [PATCH 265/362] chore(main): release 10.1.1 (#1694) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4573b18d..80f25f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [10.1.1](https://github.com/LazyVim/LazyVim/compare/v10.1.0...v10.1.1) (2023-10-13) + + +### Bug Fixes + +* **aerial:** use new sep_icon option for aerial lualine component ([bd1928b](https://github.com/LazyVim/LazyVim/commit/bd1928ba597d777ca79f9f2f4b14217de4c291bc)) +* **json:** always write version to prevent spurious migrations. Fixes [#1692](https://github.com/LazyVim/LazyVim/issues/1692) ([01dbd07](https://github.com/LazyVim/LazyVim/commit/01dbd070738a9448ffbdc63602ed9eb5421158da)) + ## [10.1.0](https://github.com/LazyVim/LazyVim/compare/v10.0.1...v10.1.0) (2023-10-12) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index af31f163..4a5abf17 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.1.0" -- x-release-please-version +M.version = "10.1.1" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 4584410e76bf8a6ba426270bef8eca5a100d4cce Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 09:45:35 +0200 Subject: [PATCH 266/362] feat(format): use conform as lsp formatter since it has better format diffs --- lua/lazyvim/util/lsp.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index d5903cd8..7060c7a5 100644 --- a/lua/lazyvim/util/lsp.lua +++ b/lua/lazyvim/util/lsp.lua @@ -104,9 +104,17 @@ end ---@param opts? {filter?: lsp.Client.filter, bufnr?: number} function M.format(opts) - vim.lsp.buf.format( - vim.tbl_deep_extend("force", opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {}) - ) + opts = vim.tbl_deep_extend("force", {}, opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {}) + local ok, conform = pcall(require, "conform") + -- use conform for formatting with LSP when available, + -- since it has better format diffing + if ok then + opts.formatters = {} + opts.lsp_fallback = true + conform.format(opts) + else + vim.lsp.buf.format(opts) + end end return M From 3f1bf70b144f098f427b47d44d42d87945778328 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 12:20:55 +0200 Subject: [PATCH 267/362] refactor(util.lsp): easier lsp client filters --- lua/lazyvim/util/lsp.lua | 59 ++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index 7060c7a5..b34a2afe 100644 --- a/lua/lazyvim/util/lsp.lua +++ b/lua/lazyvim/util/lsp.lua @@ -1,10 +1,26 @@ +local Util = require("lazyvim.util") + ---@class lazyvim.util.lsp local M = {} -function M.get_clients(...) - ---@diagnostic disable-next-line: deprecated - local fn = vim.lsp.get_clients or vim.lsp.get_active_clients - return fn(...) +---@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: lsp.Client):boolean} + +---@param opts? lsp.Client.filter +function M.get_clients(opts) + local ret = {} ---@type lsp.Client[] + if vim.lsp.get_clients then + ret = vim.lsp.get_clients(opts) + else + ---@diagnostic disable-next-line: deprecated + ret = vim.lsp.get_active_clients(opts) + if opts and opts.method then + ---@param client lsp.Client + ret = vim.tbl_filter(function(client) + return client.supports_method(opts.method, { bufnr = opts.bufnr }) + end, ret) + end + end + return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret end ---@param on_attach fun(client, buffer) @@ -59,39 +75,26 @@ function M.disable(server, cond) end) end ----@alias lsp.Client.filter fun(client: lsp.Client): boolean - ----@param name string ----@return lsp.Client.filter -function M.filter(name) - return function(client) - return client.name == name - end -end - ----@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter), bufnr?: number} +---@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)} function M.formatter(opts) opts = opts or {} - local filter = opts.filter - filter = type(filter) == "string" and M.filter(filter) or filter - ---@cast filter lsp.Client.filter? + local filter = opts.filter or {} + filter = type(filter) == "string" and { name = filter } or filter + ---@cast filter lsp.Client.filter ---@type LazyFormatter local ret = { name = "LSP", primary = true, priority = 1, format = function(buf) - M.format({ bufnr = buf, filter = filter }) + M.format(Util.merge(filter, { bufnr = buf })) end, sources = function(buf) - local clients = M.get_clients({ bufnr = buf }) + local clients = M.get_clients(Util.merge(filter, { bufnr = buf })) ---@param client lsp.Client local ret = vim.tbl_filter(function(client) - return (not filter or filter(client)) - and ( - client.supports_method("textDocument/formatting") - or client.supports_method("textDocument/rangeFormatting") - ) + return client.supports_method("textDocument/formatting") + or client.supports_method("textDocument/rangeFormatting") end, clients) ---@param client lsp.Client return vim.tbl_map(function(client) @@ -99,10 +102,12 @@ function M.formatter(opts) end, ret) end, } - return vim.tbl_deep_extend("force", ret, opts) --[[@as LazyFormatter]] + return Util.merge(ret, opts) --[[@as LazyFormatter]] end ----@param opts? {filter?: lsp.Client.filter, bufnr?: number} +---@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter + +---@param opts? lsp.Client.format function M.format(opts) opts = vim.tbl_deep_extend("force", {}, opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {}) local ok, conform = pcall(require, "conform") From 6fd66f486e210e35b4c375691fbfd61a611b6027 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 12:21:38 +0200 Subject: [PATCH 268/362] feat(conform): use conform.nvim `opts.format` options for formatting with conform --- lua/lazyvim/plugins/formatting.lua | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 855e356e..b40245ea 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -1,3 +1,8 @@ +local Util = require("lazyvim.util") + +---@type ConformOpts +local format_opts = {} + return { { "stevearc/conform.nvim", @@ -23,7 +28,7 @@ return { priority = 100, primary = true, format = function(buf) - require("conform").format({ bufnr = buf }) + require("conform").format(Util.merge(format_opts, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) @@ -34,7 +39,12 @@ return { }) end) end, + ---@class ConformOpts opts = { + -- LazyVim will use these options when formatting with the conform.nvim formatter + format = { + timeout_ms = 1000, + }, formatters_by_ft = { lua = { "stylua" }, fish = { "fish_indent" }, @@ -53,6 +63,7 @@ return { -- }, }, }, + ---@param opts ConformOpts config = function(_, opts) opts.formatters = opts.formatters or {} for name, formatter in pairs(opts.formatters) do @@ -63,6 +74,17 @@ return { end end end + for _, key in ipairs({ "format_on_save", "format_after_save" }) do + if opts[key] then + Util.warn( + ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format( + key + ) + ) + opts[key] = nil + end + end + format_opts = opts.format require("conform").setup(opts) end, }, From c7244d9d47d617e68fe603a1e45b8701b08cf0ca Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 12:31:32 +0200 Subject: [PATCH 269/362] style(dot): make enabled a function for doc gen --- lua/lazyvim/plugins/extras/util/dot.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index 6dda53d3..2424589d 100644 --- a/lua/lazyvim/plugins/extras/util/dot.lua +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -11,7 +11,9 @@ return { -- Add Hyprland Parser { "luckasRanarison/tree-sitter-hypr", - enabled = have("hypr"), + enabled = function() + return have("hypr") + end, event = "BufRead */hypr/*.conf", build = ":TSUpdate hypr", config = function() From 385c99dbb7ccdcf53276086892cceee65b85fa21 Mon Sep 17 00:00:00 2001 From: Juan Cruz De La Torre Date: Fri, 13 Oct 2023 07:43:51 -0300 Subject: [PATCH 270/362] feat(go): add gofumpt formatter with conform/none-ls (#1683) * feat(go): only install required packages * fix: add gofumpt formatter using conform/none-ls * fix: add mason.nvim as dependency of none-ls --- lua/lazyvim/plugins/extras/lang/go.lua | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index 7e87678b..aaad0128 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -82,15 +82,32 @@ return { }, }, -- Ensure Go tools are installed + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" }) + end, + }, { "nvimtools/none-ls.nvim", optional = true, + dependencies = { + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl" }) + end, + }, + }, opts = function(_, opts) local nls = require("null-ls") opts.sources = vim.list_extend(opts.sources or {}, { nls.builtins.code_actions.gomodifytags, nls.builtins.code_actions.impl, nls.builtins.formatting.goimports, + nls.builtins.formatting.gofumpt, }) end, }, @@ -99,7 +116,7 @@ return { optional = true, opts = { formatters_by_ft = { - go = { "goimports" }, + go = { "goimports", "gofumpt" }, }, }, }, @@ -108,10 +125,10 @@ return { optional = true, dependencies = { { - "mason.nvim", + "williamboman/mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "goimports", "delve" }) + vim.list_extend(opts.ensure_installed, { "delve" }) end, }, { From 873ff892843898033be0b59cee8130c6b1b29d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BAc=20H=2E=20L=C3=AA=20Kh=E1=BA=AFc?= Date: Fri, 13 Oct 2023 16:53:55 +0200 Subject: [PATCH 271/362] fix(keymaps): no diagnostic keymaps w/o lsp attached (#1698) --- lua/lazyvim/config/keymaps.lua | 16 ++++++++++++++++ lua/lazyvim/plugins/lsp/keymaps.lua | 15 --------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index bae7b15b..85517a65 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -98,6 +98,22 @@ map({ "n", "v" }, "cf", function() Util.format({ force = true }) end, { desc = "Format" }) +-- diagnostic +local diagnostic_goto = function(next, severity) + local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev + severity = severity and vim.diagnostic.severity[severity] or nil + return function() + go({ severity = severity }) + end +end +map("n", "cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" }) +map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" }) +map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" }) +map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" }) +map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" }) +map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" }) +map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) + -- stylua: ignore start -- toggle options diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index 7b9c2189..10e5d86f 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -13,7 +13,6 @@ function M.get() end -- stylua: ignore M._keys = { - { "cd", vim.diagnostic.open_float, desc = "Line Diagnostics" }, { "cl", "LspInfo", desc = "Lsp Info" }, { "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" }, { "gr", "Telescope lsp_references", desc = "References" }, @@ -23,12 +22,6 @@ function M.get() { "K", vim.lsp.buf.hover, desc = "Hover" }, { "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" }, { "", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" }, - { "]d", M.diagnostic_goto(true), desc = "Next Diagnostic" }, - { "[d", M.diagnostic_goto(false), desc = "Prev Diagnostic" }, - { "]e", M.diagnostic_goto(true, "ERROR"), desc = "Next Error" }, - { "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" }, - { "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" }, - { "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" }, { "ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, { "cA", @@ -106,12 +99,4 @@ function M.on_attach(_, buffer) end end -function M.diagnostic_goto(next, severity) - local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev - severity = severity and vim.diagnostic.severity[severity] or nil - return function() - go({ severity = severity }) - end -end - return M From 3eb91c64b5960ccd84bd8e6a3318a1ee79cb85c5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 18:03:40 +0200 Subject: [PATCH 272/362] feat(conform): make it easier to add `extra_args` --- lua/lazyvim/plugins/formatting.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index b40245ea..2053d1a5 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -61,10 +61,14 @@ return { -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] -- end, -- }, + shfmt = { + extra_args = { "-i", "2", "-ci" }, + }, }, }, ---@param opts ConformOpts config = function(_, opts) + local util = require("conform.util") opts.formatters = opts.formatters or {} for name, formatter in pairs(opts.formatters) do if type(formatter) == "table" then @@ -72,8 +76,13 @@ return { if ok and type(defaults) == "table" then opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) end + if opts.formatters[name].extra_args then + opts.formatters[name].args = + util.extend_args(opts.formatters[name].args or {}, opts.formatters[name].extra_args) + end end end + for _, key in ipairs({ "format_on_save", "format_after_save" }) do if opts[key] then Util.warn( From b6e68fa2bf829753be86ba8cc56baafd47b7da67 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 13 Oct 2023 18:20:41 +0200 Subject: [PATCH 273/362] feat(conform): show error when user overwrites conform config function --- lua/lazyvim/plugins/formatting.lua | 126 ++++++++++++++++------------- 1 file changed, 71 insertions(+), 55 deletions(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 2053d1a5..5042f076 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -1,8 +1,41 @@ local Util = require("lazyvim.util") +local M = {} + ---@type ConformOpts local format_opts = {} +---@param opts ConformOpts +function M.setup(plugin, opts) + local util = require("conform.util") + opts.formatters = opts.formatters or {} + for name, formatter in pairs(opts.formatters) do + if type(formatter) == "table" then + local ok, defaults = pcall(require, "conform.formatters." .. name) + if ok and type(defaults) == "table" then + opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) + end + if opts.formatters[name].extra_args then + opts.formatters[name].args = + util.extend_args(opts.formatters[name].args or {}, opts.formatters[name].extra_args) + end + end + end + + for _, key in ipairs({ "format_on_save", "format_after_save" }) do + if opts[key] then + Util.warn( + ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format( + key + ) + ) + opts[key] = nil + end + end + format_opts = opts.format + require("conform").setup(opts) +end + return { { "stevearc/conform.nvim", @@ -39,62 +72,45 @@ return { }) end) end, - ---@class ConformOpts - opts = { - -- LazyVim will use these options when formatting with the conform.nvim formatter - format = { - timeout_ms = 1000, - }, - formatters_by_ft = { - lua = { "stylua" }, - fish = { "fish_indent" }, - sh = { "shfmt" }, - }, - -- LazyVim will merge the options you set here with builtin formatters. - -- You can also define any custom formatters here. - ---@type table - formatters = { - injected = { options = { ignore_errors = true } }, - -- -- Example of using dprint only when a dprint.json file is present - -- dprint = { - -- condition = function(ctx) - -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] - -- end, - -- }, - shfmt = { - extra_args = { "-i", "2", "-ci" }, + opts = function() + local plugin = require("lazy.core.config").plugins["conform.nvim"] + if plugin.config ~= M.setup then + Util.error({ + "Don't set `plugin.config` for `conform.nvim`.\n", + "This will break **LazyVim** formatting.\n", + "Please refer to the docs at https://www.lazyvim.org/plugins/formatting", + }, { title = "LazyVim" }) + end + ---@class ConformOpts + return { + -- LazyVim will use these options when formatting with the conform.nvim formatter + format = { + timeout_ms = 1000, }, - }, - }, - ---@param opts ConformOpts - config = function(_, opts) - local util = require("conform.util") - opts.formatters = opts.formatters or {} - for name, formatter in pairs(opts.formatters) do - if type(formatter) == "table" then - local ok, defaults = pcall(require, "conform.formatters." .. name) - if ok and type(defaults) == "table" then - opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) - end - if opts.formatters[name].extra_args then - opts.formatters[name].args = - util.extend_args(opts.formatters[name].args or {}, opts.formatters[name].extra_args) - end - end - end - - for _, key in ipairs({ "format_on_save", "format_after_save" }) do - if opts[key] then - Util.warn( - ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format( - key - ) - ) - opts[key] = nil - end - end - format_opts = opts.format - require("conform").setup(opts) + formatters_by_ft = { + lua = { "stylua" }, + fish = { "fish_indent" }, + sh = { "shfmt" }, + }, + -- LazyVim will merge the options you set here with builtin formatters. + -- You can also define any custom formatters here. + ---@type table + formatters = { + injected = { options = { ignore_errors = true } }, + -- # Example of using dprint only when a dprint.json file is present + -- dprint = { + -- condition = function(ctx) + -- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1] + -- end, + -- }, + -- + -- # Example of using shfmt with extra args + -- shfmt = { + -- extra_args = { "-i", "2", "-ci" }, + -- }, + }, + } end, + config = M.setup, }, } From 7fe68d9f055fd34d95f19a8711e281ab40629482 Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Fri, 13 Oct 2023 11:17:50 -0600 Subject: [PATCH 274/362] fix(spectre): add title to Spectre panel in edgy (#1703) --- lua/lazyvim/plugins/extras/ui/edgy.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 64e6237a..6cabd24d 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -49,7 +49,7 @@ return { return vim.bo[buf].buftype == "help" end, }, - { ft = "spectre_panel", size = { height = 0.4 } }, + { title = "Spectre", ft = "spectre_panel", size = { height = 0.4 } }, { title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } }, }, left = { From ff9bf005b6957bb46a5541188925f32a1d86365d Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sat, 14 Oct 2023 13:21:30 +0200 Subject: [PATCH 275/362] fix(dashboard-nvim): repository has moved to nvimdev/dashboard-nvim (#1715) * fix(dashboard-nvim) repository has moved to nvimdev/dashboard-nvim * fix(dashboard): automatically rename dashboard.nvim --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/extras/ui/alpha.lua | 2 +- lua/lazyvim/plugins/extras/ui/mini-starter.lua | 2 +- lua/lazyvim/plugins/extras/util/project.lua | 2 +- lua/lazyvim/plugins/ui.lua | 2 +- lua/lazyvim/util/plugin.lua | 1 + 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua index d05c941c..875c11c8 100644 --- a/lua/lazyvim/plugins/extras/ui/alpha.lua +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -1,6 +1,6 @@ return { - { "glepnir/dashboard-nvim", enabled = false }, + { "nvimdev/dashboard-nvim", enabled = false }, { "echasnovski/mini.starter", enabled = false }, -- Dashboard. This runs when neovim starts, and is what displays -- the "LAZYVIM" banner. diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index 6ec0e572..887db7ef 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -2,7 +2,7 @@ return { -- disable alpha { "goolord/alpha-nvim", enabled = false }, - { "glepnir/dashboard-nvim", enabled = false }, + { "nvimdev/dashboard-nvim", enabled = false }, -- enable mini.starter { diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 0800e5d5..8164d19f 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -45,7 +45,7 @@ return { end, }, { - "glepnir/dashboard-nvim", + "nvimdev/dashboard-nvim", optional = true, opts = function(_, opts) local projects = { diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index e821c33e..abba7d44 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -331,7 +331,7 @@ return { end, }, { - "glepnir/dashboard-nvim", + "nvimdev/dashboard-nvim", event = "VimEnter", opts = function() local logo = [[ diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index f23bec3b..9ff2c986 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -26,6 +26,7 @@ M.renames = { ["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim", ["null-ls.nvim"] = "none-ls.nvim", ["romgrk/nvim-treesitter-context"] = "nvim-treesitter/nvim-treesitter-context", + ["glepnir/dashboard-nvim"] = "nvimdev/dashboard-nvim", } function M.setup() From f724eae2e3d1065f406baa22fc4dae30a49be86b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 14 Oct 2023 11:22:06 +0000 Subject: [PATCH 276/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 49d339b6..0347bf2f 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 13 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 14 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 5e1a86d3b257db37c8b443deea6ca1fefcb0b1aa Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Sat, 14 Oct 2023 06:40:25 -0600 Subject: [PATCH 277/362] feat(toggle): add keymap to toggle treesitter context (#1711) * feat: add keymap to toggle treesitter context * fix: get correct enabled state --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/formatting.lua | 2 +- lua/lazyvim/plugins/treesitter.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 5042f076..c98a7252 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -6,7 +6,7 @@ local M = {} local format_opts = {} ---@param opts ConformOpts -function M.setup(plugin, opts) +function M.setup(_, opts) local util = require("conform.util") opts.formatters = opts.formatters or {} for name, formatter in pairs(opts.formatters) do diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index c833a707..1b4debcf 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -110,6 +110,22 @@ return { event = "LazyFile", enabled = true, opts = { mode = "cursor" }, + keys = { + { + "ut", + function() + local Util = require("lazyvim.util") + local tsc = require("treesitter-context") + tsc.toggle() + if Util.inject.get_upvalue(tsc.toggle, "enabled") then + Util.info("Enabled Treesitter Context", { title = "Option" }) + else + Util.warn("Disabled Treesitter Context", { title = "Option" }) + end + end, + desc = "Toggle Treesitter Context", + }, + }, }, -- Automatically add closing tags for HTML and JSX From 5b89bc8cbf990edec201d07c146a3fe28db3302f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 14 Oct 2023 16:56:18 +0200 Subject: [PATCH 278/362] fix(lsp): trigger FileType commands after installing LSP servers --- lua/lazyvim/plugins/lsp/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 165367bf..f0823e46 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -218,6 +218,15 @@ return { config = function(_, opts) require("mason").setup(opts) local mr = require("mason-registry") + mr:on("package:install:success", function() + vim.defer_fn(function() + -- trigger FileType event to possibly load this newly installed LSP server + require("lazy.core.handler.event").trigger({ + event = "FileType", + buf = vim.api.nvim_get_current_buf(), + }) + end, 100) + end) local function ensure_installed() for _, tool in ipairs(opts.ensure_installed) do local p = mr.get_package(tool) From 6b9ee963e2684e7b37120b86bab5049918e14899 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 14 Oct 2023 16:56:48 +0200 Subject: [PATCH 279/362] fix(news): dont show news when it has never been viewed (new install) --- lua/lazyvim/util/news.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua index 11707155..4c212470 100644 --- a/lua/lazyvim/util/news.lua +++ b/lua/lazyvim/util/news.lua @@ -15,6 +15,9 @@ end function M.setup() vim.schedule(function() if Config.news.lazyvim then + if not Config.json.data.news["NEWS.md"] then + M.welcome() + end M.lazyvim(true) end if Config.news.neovim then @@ -23,6 +26,10 @@ function M.setup() end) end +function M.welcome() + Util.info("Welcome to LazyVim!") +end + function M.changelog() M.open("CHANGELOG.md", { plugin = "LazyVim" }) end @@ -55,23 +62,28 @@ function M.open(file, opts) end if opts.when_changed then + local is_new = not Config.json.data.news[ref] local hash = M.hash(file) if hash == Config.json.data.news[ref] then return end Config.json.data.news[ref] = hash Util.json.save() + -- don't open if file has never been opened + if is_new then + return + end end local float = require("lazy.util").float({ file = file, size = { width = 0.6, height = 0.6 }, }) - vim.wo[float.win].spell = false - vim.wo[float.win].wrap = false - vim.wo[float.win].signcolumn = "yes" - vim.wo[float.win].statuscolumn = " " - vim.wo[float.win].conceallevel = 3 + vim.opt_local.spell = false + vim.opt_local.wrap = false + vim.opt_local.signcolumn = "yes" + vim.opt_local.statuscolumn = " " + vim.opt_local.conceallevel = 3 vim.diagnostic.disable(float.buf) end From 3a93757bb1ee28c3e1b59c6c47ea5c4e74d8f1b2 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 14 Oct 2023 17:32:06 +0200 Subject: [PATCH 280/362] fix: dont lazy-load on ft. Load on cmd or keys only --- lua/lazyvim/plugins/extras/lang/markdown.lua | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/markdown.lua diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua new file mode 100644 index 00000000..123f92bf --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -0,0 +1,64 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "markdown", "markdown_inline" }) + end + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "markdownlint" }) + end, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.markdownlint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + markdown = { "markdownlint" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + marksman = {}, + }, + }, + }, + + -- Markdown preview + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + desc = "Peek (Markdown Preview)", + }, + }, + config = function() + vim.cmd([[do FileType]]) + end, + }, +} From 121df706047c7c075066ea93b0be389a30644533 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 14 Oct 2023 17:35:13 +0200 Subject: [PATCH 281/362] Revert "fix: dont lazy-load on ft. Load on cmd or keys only" This reverts commit 3a93757bb1ee28c3e1b59c6c47ea5c4e74d8f1b2. --- lua/lazyvim/plugins/extras/lang/markdown.lua | 64 -------------------- 1 file changed, 64 deletions(-) delete mode 100644 lua/lazyvim/plugins/extras/lang/markdown.lua diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua deleted file mode 100644 index 123f92bf..00000000 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ /dev/null @@ -1,64 +0,0 @@ -return { - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "markdown", "markdown_inline" }) - end - end, - }, - { - "williamboman/mason.nvim", - opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "markdownlint" }) - end, - }, - { - "nvimtools/none-ls.nvim", - optional = true, - opts = function(_, opts) - local nls = require("null-ls") - opts.sources = vim.list_extend(opts.sources or {}, { - nls.builtins.diagnostics.markdownlint, - }) - end, - }, - { - "mfussenegger/nvim-lint", - optional = true, - opts = { - linters_by_ft = { - markdown = { "markdownlint" }, - }, - }, - }, - { - "neovim/nvim-lspconfig", - opts = { - servers = { - marksman = {}, - }, - }, - }, - - -- Markdown preview - { - "iamcco/markdown-preview.nvim", - cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, - build = function() - vim.fn["mkdp#util#install"]() - end, - keys = { - { - "cp", - ft = "markdown", - "MarkdownPreviewToggle", - desc = "Peek (Markdown Preview)", - }, - }, - config = function() - vim.cmd([[do FileType]]) - end, - }, -} From b3d46bc0141c23bfd4302718ff42dfa172c6952b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Koz=C5=82owicz?= Date: Sat, 14 Oct 2023 17:42:02 +0200 Subject: [PATCH 282/362] feat(lang): add markdown support (#1718) * feat(lang): add markdown support * feat: use peek.nvim instead of markdown-preview. Disable and show warning when deno is not installed * feat: add markdown-preview back --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/extras/lang/markdown.lua | 64 ++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/lang/markdown.lua diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua new file mode 100644 index 00000000..123f92bf --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -0,0 +1,64 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "markdown", "markdown_inline" }) + end + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "markdownlint" }) + end, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.markdownlint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + markdown = { "markdownlint" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + marksman = {}, + }, + }, + }, + + -- Markdown preview + { + "iamcco/markdown-preview.nvim", + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, + build = function() + vim.fn["mkdp#util#install"]() + end, + keys = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + desc = "Peek (Markdown Preview)", + }, + }, + config = function() + vim.cmd([[do FileType]]) + end, + }, +} From 8f42733ce526b6c866b26824d78a1822730c2852 Mon Sep 17 00:00:00 2001 From: MoetaYuko Date: Sat, 14 Oct 2023 23:49:23 +0800 Subject: [PATCH 283/362] feat(python): add key binding for organize imports (#1670) --- lua/lazyvim/plugins/extras/lang/python.lua | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index 835c9da8..a4783973 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -12,7 +12,23 @@ return { opts = { servers = { pyright = {}, - ruff_lsp = {}, + ruff_lsp = { + keys = { + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, + }, + }, }, setup = { ruff_lsp = function() From 1a4342abaeb468f22009ce0f2e25e746ca18f585 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 14 Oct 2023 18:02:47 +0200 Subject: [PATCH 284/362] refactor: move cmp status lualine component to util --- lua/lazyvim/plugins/extras/coding/codeium.lua | 38 +-------------- lua/lazyvim/util/init.lua | 1 + lua/lazyvim/util/lualine.lua | 46 +++++++++++++++++++ 3 files changed, 48 insertions(+), 37 deletions(-) create mode 100644 lua/lazyvim/util/lualine.lua diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index 457535cd..a9f40624 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -27,43 +27,7 @@ return { optional = true, event = "VeryLazy", opts = function(_, opts) - local started = false - local function status() - if not package.loaded["cmp"] then - return - end - for _, s in ipairs(require("cmp").core.sources) do - if s.name == "codeium" then - if s.source:is_available() then - started = true - else - return started and "error" or nil - end - if s.status == s.SourceStatus.FETCHING then - return "pending" - end - return "ok" - end - end - end - - local Util = require("lazyvim.util") - local colors = { - ok = Util.ui.fg("Special"), - error = Util.ui.fg("DiagnosticError"), - pending = Util.ui.fg("DiagnosticWarn"), - } - table.insert(opts.sections.lualine_x, 2, { - function() - return require("lazyvim.config").icons.kinds.Codeium - end, - cond = function() - return status() ~= nil - end, - color = function() - return colors[status()] or colors.ok - end, - }) + table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("codeium")) end, }, } diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index ddfa55f8..4a98aee4 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -13,6 +13,7 @@ local LazyUtil = require("lazy.core.util") ---@field inject lazyvim.util.inject ---@field news lazyvim.util.news ---@field json lazyvim.util.json +---@field lualine lazyvim.util.lualine local M = {} ---@type table diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua new file mode 100644 index 00000000..8efcf714 --- /dev/null +++ b/lua/lazyvim/util/lualine.lua @@ -0,0 +1,46 @@ +local Util = require("lazyvim.util") + +---@class lazyvim.util.lualine +local M = {} + +function M.cmp_source(name, icon) + local started = false + local function status() + if not package.loaded["cmp"] then + return + end + for _, s in ipairs(require("cmp").core.sources) do + if s.name == name then + if s.source:is_available() then + started = true + else + return started and "error" or nil + end + if s.status == s.SourceStatus.FETCHING then + return "pending" + end + return "ok" + end + end + end + + local colors = { + ok = Util.ui.fg("Special"), + error = Util.ui.fg("DiagnosticError"), + pending = Util.ui.fg("DiagnosticWarn"), + } + + return { + function() + return icon or require("lazyvim.config").icons.kinds[name:sub(1, 1):upper() .. name:sub(2)] + end, + cond = function() + return status() ~= nil + end, + color = function() + return colors[status()] or colors.ok + end, + } +end + +return M From 95ff5aaa6245244d45609916b0a623c5e8c79d16 Mon Sep 17 00:00:00 2001 From: "Dung Duc Huynh (Kaka)" <870029+jellydn@users.noreply.github.com> Date: Sun, 15 Oct 2023 00:25:06 +0800 Subject: [PATCH 285/362] feat(extras): added TabNine (#1651) * feat: add Tabnine Add TabNine plugin for hrsh7th/nvim-cmp * fix: limit to top 3 sources for TabNine * feat: show Tabnine icon on suggestion list * fix: migrate to LazyVim v10 * refactor: tabnine * refactor --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/config/init.lua | 1 + lua/lazyvim/plugins/extras/coding/tabnine.lua | 50 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 lua/lazyvim/plugins/extras/coding/tabnine.lua diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 4a5abf17..170f78bc 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -84,6 +84,7 @@ local defaults = { Snippet = " ", String = " ", Struct = "󰆼 ", + TabNine = "󰏚 ", Text = " ", TypeParameter = " ", Unit = " ", diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua new file mode 100644 index 00000000..57748f5f --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -0,0 +1,50 @@ +local Util = require("lazyvim.util") + +return { + -- Tabnine cmp source + { + "nvim-cmp", + dependencies = { + -- Add TabNine support, make sure you run :CmpTabnineHub after installation. + { + "tzachar/cmp-tabnine", + build = "./install.sh", + dependencies = "hrsh7th/nvim-cmp", + opts = { + max_lines = 1000, + max_num_results = 3, + sort = true, + }, + config = function(_, opts) + local tabnine = require("cmp_tabnine.config") + tabnine:setup(opts) + end, + }, + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + table.insert(opts.sources, 1, { + name = "cmp_tabnine", + group_index = 1, + priority = 100, + }) + + opts.formatting.format = Util.inject.args(opts.formatting.format, function(entry, item) + -- Hide percentage in the menu + if entry.source.name == "cmp_tabnine" then + item.menu = "" + end + end) + end, + }, + -- Show TabNine status in lualine + { + "nvim-lualine/lualine.nvim", + optional = true, + event = "VeryLazy", + opts = function(_, opts) + local icon = require("lazyvim.config").icons.kinds.TabNine + table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("cmp_tabnine", icon)) + end, + }, +} From f29543f2c9323ae84d0979f36598c0fb78ed767a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:30:55 +0200 Subject: [PATCH 286/362] chore(main): release 10.2.0 (#1696) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 25 +++++++++++++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 80f25f8e..7754b28f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,30 @@ # Changelog +## [10.2.0](https://github.com/LazyVim/LazyVim/compare/v10.1.1...v10.2.0) (2023-10-14) + + +### Features + +* **conform:** make it easier to add `extra_args` ([3eb91c6](https://github.com/LazyVim/LazyVim/commit/3eb91c64b5960ccd84bd8e6a3318a1ee79cb85c5)) +* **conform:** show error when user overwrites conform config function ([b6e68fa](https://github.com/LazyVim/LazyVim/commit/b6e68fa2bf829753be86ba8cc56baafd47b7da67)) +* **conform:** use conform.nvim `opts.format` options for formatting with conform ([6fd66f4](https://github.com/LazyVim/LazyVim/commit/6fd66f486e210e35b4c375691fbfd61a611b6027)) +* **extras:** added TabNine ([#1651](https://github.com/LazyVim/LazyVim/issues/1651)) ([95ff5aa](https://github.com/LazyVim/LazyVim/commit/95ff5aaa6245244d45609916b0a623c5e8c79d16)) +* **format:** use conform as lsp formatter since it has better format diffs ([4584410](https://github.com/LazyVim/LazyVim/commit/4584410e76bf8a6ba426270bef8eca5a100d4cce)) +* **go:** add gofumpt formatter with conform/none-ls ([#1683](https://github.com/LazyVim/LazyVim/issues/1683)) ([385c99d](https://github.com/LazyVim/LazyVim/commit/385c99dbb7ccdcf53276086892cceee65b85fa21)) +* **lang:** add markdown support ([#1718](https://github.com/LazyVim/LazyVim/issues/1718)) ([b3d46bc](https://github.com/LazyVim/LazyVim/commit/b3d46bc0141c23bfd4302718ff42dfa172c6952b)) +* **python:** add key binding for organize imports ([#1670](https://github.com/LazyVim/LazyVim/issues/1670)) ([8f42733](https://github.com/LazyVim/LazyVim/commit/8f42733ce526b6c866b26824d78a1822730c2852)) +* **toggle:** add keymap to toggle treesitter context ([#1711](https://github.com/LazyVim/LazyVim/issues/1711)) ([5e1a86d](https://github.com/LazyVim/LazyVim/commit/5e1a86d3b257db37c8b443deea6ca1fefcb0b1aa)) + + +### Bug Fixes + +* **dashboard-nvim:** repository has moved to nvimdev/dashboard-nvim ([#1715](https://github.com/LazyVim/LazyVim/issues/1715)) ([ff9bf00](https://github.com/LazyVim/LazyVim/commit/ff9bf005b6957bb46a5541188925f32a1d86365d)) +* dont lazy-load on ft. Load on cmd or keys only ([3a93757](https://github.com/LazyVim/LazyVim/commit/3a93757bb1ee28c3e1b59c6c47ea5c4e74d8f1b2)) +* **keymaps:** no diagnostic keymaps w/o lsp attached ([#1698](https://github.com/LazyVim/LazyVim/issues/1698)) ([873ff89](https://github.com/LazyVim/LazyVim/commit/873ff892843898033be0b59cee8130c6b1b29d85)) +* **lsp:** trigger FileType commands after installing LSP servers ([5b89bc8](https://github.com/LazyVim/LazyVim/commit/5b89bc8cbf990edec201d07c146a3fe28db3302f)) +* **news:** dont show news when it has never been viewed (new install) ([6b9ee96](https://github.com/LazyVim/LazyVim/commit/6b9ee963e2684e7b37120b86bab5049918e14899)) +* **spectre:** add title to Spectre panel in edgy ([#1703](https://github.com/LazyVim/LazyVim/issues/1703)) ([7fe68d9](https://github.com/LazyVim/LazyVim/commit/7fe68d9f055fd34d95f19a8711e281ab40629482)) + ## [10.1.1](https://github.com/LazyVim/LazyVim/compare/v10.1.0...v10.1.1) (2023-10-13) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 170f78bc..84163165 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.1.1" -- x-release-please-version +M.version = "10.2.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 6e0e352fea4cd930ea7fc42a0252c2c70b279bee Mon Sep 17 00:00:00 2001 From: Michael Olson <48652773+m0lson84@users.noreply.github.com> Date: Sun, 15 Oct 2023 01:18:00 -0400 Subject: [PATCH 287/362] feat(linting): ability to configure global and fallback linters (#1727) * feat(linting): ability to configure global and fallback linters * fix: use nvim-lint's logic to get linters --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/linting.lua | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua index db9fe9c3..2d2527c1 100644 --- a/lua/lazyvim/plugins/linting.lua +++ b/lua/lazyvim/plugins/linting.lua @@ -7,6 +7,10 @@ return { events = { "BufWritePost", "BufReadPost", "InsertLeave" }, linters_by_ft = { fish = { "fish" }, + -- Use the "*" filetype to run linters on all filetypes. + -- ['*'] = { 'global linter' }, + -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. + -- ['_'] = { 'fallback linter' }, }, -- LazyVim extension to easily override linter options -- or add custom linters. @@ -23,6 +27,8 @@ return { }, }, config = function(_, opts) + local Util = require("lazyvim.util") + local M = {} local lint = require("lint") @@ -47,14 +53,32 @@ return { end function M.lint() - local names = lint.linters_by_ft[vim.bo.filetype] or {} + -- Use nvim-lint's logic first: + -- * checks if linters exist for the full filetype first + -- * otherwise will split filetype by "." and add all those linters + -- * this differs from conform.nvim which only uses the first filetype that has a formatter + local names = lint._resolve_linter_by_ft(vim.bo.filetype) + + -- Add fallback linters. + if #names == 0 then + vim.list_extend(names, lint.linters_by_ft["_"] or {}) + end + + -- Add global linters. + vim.list_extend(names, lint.linters_by_ft["*"] or {}) + + -- Filter out linters that don't exist or don't match the condition. local ctx = { filename = vim.api.nvim_buf_get_name(0) } ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h") names = vim.tbl_filter(function(name) local linter = lint.linters[name] + if not linter then + Util.warn("Linter not found: " .. name, { title = "nvim-lint" }) + end return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx)) end, names) + -- Run linters. if #names > 0 then lint.try_lint(names) end From 5ea0dd716af0a4b5e732457525cfd8a55fe30e65 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 15 Oct 2023 05:18:51 +0000 Subject: [PATCH 288/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 0347bf2f..ecbf2c58 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 14 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 15 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 7c60431c58a050cf4badced0609f3179bd284137 Mon Sep 17 00:00:00 2001 From: jyuan0 Date: Sun, 15 Oct 2023 01:21:17 -0400 Subject: [PATCH 289/362] fix(python): add `ft` to Python keymaps, and fix "Markdown Preview" toggle description (#1729) * feat(python): add `ft` to keymaps * fix(markdown): fix toggle keymap description --- lua/lazyvim/plugins/extras/lang/markdown.lua | 2 +- lua/lazyvim/plugins/extras/lang/python.lua | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 123f92bf..f57954f1 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -54,7 +54,7 @@ return { "cp", ft = "markdown", "MarkdownPreviewToggle", - desc = "Peek (Markdown Preview)", + desc = "Markdown Preview", }, }, config = function() diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index a4783973..cc9bc52e 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -65,8 +65,8 @@ return { "mfussenegger/nvim-dap-python", -- stylua: ignore keys = { - { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method" }, - { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class" }, + { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" }, + { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, }, config = function() local path = require("mason-registry").get_package("debugpy"):get_install_path() From 53e1637a864cb7e8f21af107b8073bc8b24acd11 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 09:16:52 +0200 Subject: [PATCH 290/362] feat(dashboard): `c` on dahboard now opens telescope for config dir instead of useless `init.lua` --- lua/lazyvim/plugins/editor.lua | 1 + lua/lazyvim/plugins/extras/ui/alpha.lua | 4 ++-- lua/lazyvim/plugins/extras/ui/mini-starter.lua | 18 +++++++++--------- lua/lazyvim/plugins/ui.lua | 8 ++++---- lua/lazyvim/util/telescope.lua | 4 ++++ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 63a8e1b1..9ee3eb03 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -133,6 +133,7 @@ return { { "", Util.telescope("files"), desc = "Find Files (root dir)" }, -- find { "fb", "Telescope buffers", desc = "Buffers" }, + { "fc", Util.telescope.config_files(), desc = "Find Config File" }, { "ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua index 875c11c8..8feee188 100644 --- a/lua/lazyvim/plugins/extras/ui/alpha.lua +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -27,9 +27,9 @@ return { dashboard.button("n", " " .. " New file", " ene startinsert "), dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), dashboard.button("g", " " .. " Find text", " Telescope live_grep "), - dashboard.button("c", " " .. " Config", " e $MYVIMRC "), + dashboard.button("c", " " .. " Config", " lua require('lazyvim.util').telescope.config_files()() "), dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), - dashboard.button("e", " " .. " Lazy Extras", " LazyExtras "), + dashboard.button("x", " " .. " Lazy Extras", " LazyExtras "), dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), dashboard.button("q", " " .. " Quit", " qa "), } diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index 887db7ef..5f5ec9c5 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -29,15 +29,15 @@ return { evaluate_single = true, header = logo, items = { - new_section("Find file", "Telescope find_files", "Telescope"), - new_section("Recent files", "Telescope oldfiles", "Telescope"), - new_section("Grep text", "Telescope live_grep", "Telescope"), - new_section("init.lua", "e $MYVIMRC", "Config"), - new_section("Extras", "LazyExtras", "Config"), - new_section("Lazy", "Lazy", "Config"), - new_section("New file", "ene | startinsert", "Built-in"), - new_section("Quit", "qa", "Built-in"), - new_section("Session restore", [[lua require("persistence").load()]], "Session"), + new_section("Find file", "Telescope find_files", "Telescope"), + new_section("Recent files", "Telescope oldfiles", "Telescope"), + new_section("Grep text", "Telescope live_grep", "Telescope"), + new_section("Config", "lua require('lazyvim.util').telescope.config_files()()", "Config"), + new_section("Extras", "LazyExtras", "Config"), + new_section("Lazy", "Lazy", "Config"), + new_section("New file", "ene | startinsert", "Built-in"), + new_section("Quit", "qa", "Built-in"), + new_section("Session restore", [[lua require("persistence").load()]], "Session"), }, content_hooks = { starter.gen_hook.adding_bullet(pad .. "░ ", false), diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index abba7d44..0707fb5b 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -1,3 +1,5 @@ +local Util = require("lazyvim.util") + return { -- Better `vim.notify()` { @@ -25,7 +27,6 @@ return { }, init = function() -- when noice is not enabled, install notify on VeryLazy - local Util = require("lazyvim.util") if not Util.has("noice.nvim") then Util.on_very_lazy(function() vim.notify = require("notify") @@ -118,7 +119,6 @@ return { lualine_require.require = require local icons = require("lazyvim.config").icons - local Util = require("lazyvim.util") vim.o.laststatus = vim.g.lualine_laststatus @@ -360,9 +360,9 @@ return { { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" }, + { action = Util.telescope.config_files(), desc = " Config", icon = " ", key = "c" }, { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "e" }, + { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, { action = "qa", desc = " Quit", icon = " ", key = "q" }, }, diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua index 68916341..1d816b80 100644 --- a/lua/lazyvim/util/telescope.lua +++ b/lua/lazyvim/util/telescope.lua @@ -50,4 +50,8 @@ function M.telescope(builtin, opts) end end +function M.config_files() + return Util.telescope("find_files", { cwd = vim.fn.stdpath("config") }) +end + return M From 57b504b9e8ae95c294c17e97e7f017f6f802ebbc Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 22:28:56 +0200 Subject: [PATCH 291/362] fix(prettier): use prettier instead of prettierd. Too many people get truncated files. Fixes #712. See #1735 --- .../plugins/extras/formatting/prettier.lua | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index 6f1f3b58..a93f6ecf 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -2,7 +2,7 @@ return { { "williamboman/mason.nvim", opts = function(_, opts) - table.insert(opts.ensure_installed, "prettierd") + table.insert(opts.ensure_installed, "prettier") end, }, { @@ -11,7 +11,7 @@ return { opts = function(_, opts) local nls = require("null-ls") opts.sources = opts.sources or {} - table.insert(opts.sources, nls.builtins.formatting.prettierd) + table.insert(opts.sources, nls.builtins.formatting.prettier) end, }, { @@ -19,22 +19,22 @@ return { optional = true, opts = { formatters_by_ft = { - ["javascript"] = { { "prettierd", "prettier" } }, - ["javascriptreact"] = { { "prettierd", "prettier" } }, - ["typescript"] = { { "prettierd", "prettier" } }, - ["typescriptreact"] = { { "prettierd", "prettier" } }, - ["vue"] = { { "prettierd", "prettier" } }, - ["css"] = { { "prettierd", "prettier" } }, - ["scss"] = { { "prettierd", "prettier" } }, - ["less"] = { { "prettierd", "prettier" } }, - ["html"] = { { "prettierd", "prettier" } }, - ["json"] = { { "prettierd", "prettier" } }, - ["jsonc"] = { { "prettierd", "prettier" } }, - ["yaml"] = { { "prettierd", "prettier" } }, - ["markdown"] = { { "prettierd", "prettier" } }, - ["markdown.mdx"] = { { "prettierd", "prettier" } }, - ["graphql"] = { { "prettierd", "prettier" } }, - ["handlebars"] = { { "prettierd", "prettier" } }, + ["javascript"] = { "prettier" }, + ["javascriptreact"] = { "prettier" }, + ["typescript"] = { "prettier" }, + ["typescriptreact"] = { "prettier" }, + ["vue"] = { "prettier" }, + ["css"] = { "prettier" }, + ["scss"] = { "prettier" }, + ["less"] = { "prettier" }, + ["html"] = { "prettier" }, + ["json"] = { "prettier" }, + ["jsonc"] = { "prettier" }, + ["yaml"] = { "prettier" }, + ["markdown"] = { "prettier" }, + ["markdown.mdx"] = { "prettier" }, + ["graphql"] = { "prettier" }, + ["handlebars"] = { "prettier" }, }, }, }, From 782fe0bef0789c8f090284df80c00799471bc16f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 22:34:42 +0200 Subject: [PATCH 292/362] feat: disable kind_filter for markdown and help --- lua/lazyvim/config/init.lua | 10 ++++++++-- .../plugins/extras/editor/symbols-outline.lua | 20 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 84163165..19686b57 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -92,7 +92,7 @@ local defaults = { Variable = "󰀫 ", }, }, - ---@type table? + ---@type table? kind_filter = { default = { "Class", @@ -109,6 +109,8 @@ local defaults = { "Struct", "Trait", }, + markdown = false, + help = false, -- you can specify a different filter for each filetype lua = { "Class", @@ -214,7 +216,11 @@ function M.get_kind_filter(buf) if M.kind_filter == false then return end - return M.kind_filter[ft] or M.kind_filter.default + if M.kind_filter[ft] == false then + return + end + ---@diagnostic disable-next-line: return-type-mismatch + return type(M.kind_filter) == "table" and type(M.kind_filter.default) == "table" and M.kind_filter.default or nil end ---@param name "autocmds" | "options" | "keymaps" diff --git a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua index f0b0ba92..32cdd17f 100644 --- a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua +++ b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua @@ -12,14 +12,20 @@ return { symbols = {}, symbol_blacklist = {}, } + local filter = Config.kind_filter - for kind, symbol in pairs(defaults.symbols) do - opts.symbols[kind] = { - icon = Config.icons.kinds[kind] or symbol.icon, - hl = symbol.hl, - } - if not vim.tbl_contains(Config.kind_filter.default, kind) then - table.insert(opts.symbol_blacklist, kind) + if type(filter) == "table" then + filter = filter.default + if type(filter) == "table" then + for kind, symbol in pairs(defaults.symbols) do + opts.symbols[kind] = { + icon = Config.icons.kinds[kind] or symbol.icon, + hl = symbol.hl, + } + if not vim.tbl_contains(filter, kind) then + table.insert(opts.symbol_blacklist, kind) + end + end end end return opts From 8af7309c7e31f55125eaade5fe86d04d63133999 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 22:37:49 +0200 Subject: [PATCH 293/362] feat(lualine): pretty_path now highlights file basename when modified --- lua/lazyvim/plugins/ui.lua | 8 ++---- lua/lazyvim/util/init.lua | 4 +++ lua/lazyvim/util/lualine.lua | 55 ++++++++++++++++++++++++++++++++++++ lua/lazyvim/util/root.lua | 39 +++++-------------------- 4 files changed, 69 insertions(+), 37 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 0707fb5b..73a52cdf 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -131,7 +131,9 @@ return { sections = { lualine_a = { "mode" }, lualine_b = { "branch" }, + lualine_c = { + Util.lualine.root_dir(), { "diagnostics", symbols = { @@ -142,11 +144,7 @@ return { }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { - function() - return Util.root.pretty_path() - end, - }, + { Util.lualine.pretty_path() }, }, lualine_x = { -- stylua: ignore diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 4a98aee4..24fd0a1b 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -49,6 +49,10 @@ setmetatable(M, { end, }) +function M.is_win() + return vim.loop.os_uname().sysname:find("Windows") ~= nil +end + ---@param plugin string function M.has(plugin) return require("lazy.core.config").spec.plugins[plugin] ~= nil diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 8efcf714..7eb353bf 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -43,4 +43,59 @@ function M.cmp_source(name, icon) } end +---@param component any +---@param text string +---@param hl_group? string +---@return string +function M.format(component, text, hl_group) + if not hl_group then + return text + end + ---@type table + component.hl_cache = component.hl_cache or {} + local lualine_hl_group = component.hl_cache[hl_group] + if not lualine_hl_group then + local utils = require("lualine.utils.utils") + lualine_hl_group = component:create_hl({ fg = utils.extract_highlight_colors(hl_group, "fg") }, "LV_" .. hl_group) + component.hl_cache[hl_group] = lualine_hl_group + end + return component:format_hl(lualine_hl_group) .. text .. component:get_default_hl() +end + +---@param opts? {relative: "cwd"|"root", modified_hl: string?} +function M.pretty_path(opts) + opts = vim.tbl_extend("force", { + relative = "cwd", + modified_hl = "Constant", + }, opts or {}) + + return function(self) + local path = vim.fn.expand("%:p") --[[@as string]] + + if path == "" then + return "" + end + local root = Util.root.get() + local cwd = Util.root.cwd() + + if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then + path = path:sub(#cwd + 2) + else + path = path:sub(#root + 2) + end + + local sep = package.config:sub(1, 1) + local parts = vim.split(path, "[\\/]") + if #parts > 3 then + parts = { parts[1], "…", parts[#parts - 1], parts[#parts] } + end + + if opts.modified_hl and vim.bo.modified then + parts[#parts] = M.format(self, parts[#parts], opts.modified_hl) + end + + return table.concat(parts, sep) + end +end + return M diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index d799fe44..80aece22 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -58,6 +58,10 @@ function M.bufpath(buf) return M.realpath(vim.api.nvim_buf_get_name(assert(buf))) end +function M.cwd() + return M.realpath(vim.loop.cwd()) or "" +end + function M.realpath(path) if path == "" or path == nil then return nil @@ -144,38 +148,9 @@ function M.get() return roots[1] and roots[1].paths[1] or vim.loop.cwd() end -M.pretty_cache = {} ---@type table -function M.pretty_path() - local path = vim.fn.expand("%:p") --[[@as string]] - if path == "" then - return "" - end - - path = Util.norm(path) - if M.pretty_cache[path] then - return M.pretty_cache[path] - end - local cache_key = path - local cwd = M.realpath(vim.loop.cwd()) or "" - - if path:find(cwd, 1, true) == 1 then - path = path:sub(#cwd + 2) - else - local roots = M.detect({ spec = { ".git" } }) - local root = roots[1] and roots[1].paths[1] or nil - if root then - path = path:sub(#vim.fs.dirname(root) + 2) - end - end - - local sep = package.config:sub(1, 1) - local parts = vim.split(path, "[\\/]") - if #parts > 3 then - parts = { parts[1], "…", parts[#parts - 1], parts[#parts] } - end - local ret = table.concat(parts, sep) - M.pretty_cache[cache_key] = ret - return ret +---@param opts? {hl_last?: string} +function M.pretty_path(opts) + return "" end return M From 6f88b8b36f8d4fd0e958e59b4e37e1a9ed2acb78 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 22:38:15 +0200 Subject: [PATCH 294/362] fix(root): dont use single-file lsps for root detection. use workspaces only --- lua/lazyvim/util/root.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 80aece22..519546e1 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -32,13 +32,12 @@ function M.detectors.lsp(buf) end local roots = {} ---@type string[] for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do + -- only check workspace folders, since we're not interested in clients + -- running in single file mode local workspace = client.config.workspace_folders for _, ws in pairs(workspace or {}) do roots[#roots + 1] = vim.uri_to_fname(ws.uri) end - if client.config.root_dir then - roots[#roots + 1] = client.config.root_dir - end end return vim.tbl_filter(function(path) path = Util.norm(path) From dfdfcad1aab0ee39ac3876e47cbeb727eb4f1e95 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 15 Oct 2023 22:38:44 +0200 Subject: [PATCH 295/362] feat(lualine): new root dir component that only shows when cwd != root_dir --- lua/lazyvim/util/lualine.lua | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 7eb353bf..1ec2cd19 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -98,4 +98,46 @@ function M.pretty_path(opts) end end +---@param opts? {cwd:false, subdirectory: true, parent: true, other: true, icon?:string} +function M.root_dir(opts) + opts = vim.tbl_extend("force", { + cwd = false, + subdirectory = true, + parent = true, + other = true, + icon = "󱉭 ", + color = Util.ui.fg("Special"), + }, opts or {}) + + local function get() + local cwd = Util.root.cwd() + local root = Util.root.get() + local name = vim.fs.basename(root) + + if root == cwd then + -- root is cwd + return opts.cwd and name + elseif root:find(cwd, 1, true) == 1 then + -- root is subdirectory of cwd + return opts.subdirectory and name + elseif cwd:find(root, 1, true) == 1 then + -- root is parent directory of cwd + return opts.parent and name + else + -- root and cwd are not related + return opts.other and name + end + end + + return { + function() + return (opts.icon and opts.icon .. " ") .. get() + end, + cond = function() + return type(get()) == "string" + end, + color = opts.color, + } +end + return M From c8e5501ee5ecd1a7b27ff3aa5f41e54c2e98ff0b Mon Sep 17 00:00:00 2001 From: Edouard Shamis <47914518+edshamis@users.noreply.github.com> Date: Sun, 15 Oct 2023 23:42:38 +0300 Subject: [PATCH 296/362] feat(tabnine): add build cmd for Windows (#1737) * feat(tabnine): add build cmd for Windows * fix(prettier): use prettier instead of prettierd. Too many people get truncated files. Fixes #712. See #1735 * feat: disable kind_filter for markdown and help * feat(lualine): pretty_path now highlights file basename when modified * fix(root): dont use single-file lsps for root detection. use workspaces only * feat(lualine): new root dir component that only shows when cwd != root_dir * refactor --------- Co-authored-by: edshamis Co-authored-by: Folke Lemaitre --- lua/lazyvim/plugins/extras/coding/tabnine.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua index 57748f5f..696103ce 100644 --- a/lua/lazyvim/plugins/extras/coding/tabnine.lua +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -8,7 +8,7 @@ return { -- Add TabNine support, make sure you run :CmpTabnineHub after installation. { "tzachar/cmp-tabnine", - build = "./install.sh", + build = Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", dependencies = "hrsh7th/nvim-cmp", opts = { max_lines = 1000, @@ -16,8 +16,7 @@ return { sort = true, }, config = function(_, opts) - local tabnine = require("cmp_tabnine.config") - tabnine:setup(opts) + require("cmp_tabnine.config"):setup(opts) end, }, }, From e26a127185e9dc86d1d655d17fa0a5e765a8a040 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 15 Oct 2023 22:51:01 +0200 Subject: [PATCH 297/362] chore(main): release 10.3.0 (#1733) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 19 +++++++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7754b28f..d4c3bd78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,24 @@ # Changelog +## [10.3.0](https://github.com/LazyVim/LazyVim/compare/v10.2.0...v10.3.0) (2023-10-15) + + +### Features + +* **dashboard:** `c` on dahboard now opens telescope for config dir instead of useless `init.lua` ([53e1637](https://github.com/LazyVim/LazyVim/commit/53e1637a864cb7e8f21af107b8073bc8b24acd11)) +* disable kind_filter for markdown and help ([782fe0b](https://github.com/LazyVim/LazyVim/commit/782fe0bef0789c8f090284df80c00799471bc16f)) +* **linting:** ability to configure global and fallback linters ([#1727](https://github.com/LazyVim/LazyVim/issues/1727)) ([6e0e352](https://github.com/LazyVim/LazyVim/commit/6e0e352fea4cd930ea7fc42a0252c2c70b279bee)) +* **lualine:** new root dir component that only shows when cwd != root_dir ([dfdfcad](https://github.com/LazyVim/LazyVim/commit/dfdfcad1aab0ee39ac3876e47cbeb727eb4f1e95)) +* **lualine:** pretty_path now highlights file basename when modified ([8af7309](https://github.com/LazyVim/LazyVim/commit/8af7309c7e31f55125eaade5fe86d04d63133999)) +* **tabnine:** add build cmd for Windows ([#1737](https://github.com/LazyVim/LazyVim/issues/1737)) ([c8e5501](https://github.com/LazyVim/LazyVim/commit/c8e5501ee5ecd1a7b27ff3aa5f41e54c2e98ff0b)) + + +### Bug Fixes + +* **prettier:** use prettier instead of prettierd. Too many people get truncated files. Fixes [#712](https://github.com/LazyVim/LazyVim/issues/712). See [#1735](https://github.com/LazyVim/LazyVim/issues/1735) ([57b504b](https://github.com/LazyVim/LazyVim/commit/57b504b9e8ae95c294c17e97e7f017f6f802ebbc)) +* **python:** add `ft` to Python keymaps, and fix "Markdown Preview" toggle description ([#1729](https://github.com/LazyVim/LazyVim/issues/1729)) ([7c60431](https://github.com/LazyVim/LazyVim/commit/7c60431c58a050cf4badced0609f3179bd284137)) +* **root:** dont use single-file lsps for root detection. use workspaces only ([6f88b8b](https://github.com/LazyVim/LazyVim/commit/6f88b8b36f8d4fd0e958e59b4e37e1a9ed2acb78)) + ## [10.2.0](https://github.com/LazyVim/LazyVim/compare/v10.1.1...v10.2.0) (2023-10-14) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 19686b57..3b8092c7 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.2.0" -- x-release-please-version +M.version = "10.3.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From be5eea476c98d46aefbbaee04b7f2bc82bb51c27 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 07:29:02 +0200 Subject: [PATCH 298/362] feat(keymaps): added toggle for treesitter highlights --- lua/lazyvim/config/keymaps.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 85517a65..173705ab 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -129,6 +129,7 @@ map("n", "uc", function() Util.toggle("conceallevel", false, {0, conceal if vim.lsp.inlay_hint then map("n", "uh", function() vim.lsp.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" }) end +map("n", "uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" }) -- lazygit map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) From 66482927cb279b8a5d9cfb4fc5c982d6e98c3aa3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Oct 2023 05:30:47 +0000 Subject: [PATCH 299/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index ecbf2c58..82cf4b6a 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 15 +*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 16 ============================================================================== Table of Contents *LazyVim-table-of-contents* From c3daced11ce33875059ad5dd74832bf4a232f195 Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Sun, 15 Oct 2023 23:35:57 -0600 Subject: [PATCH 300/362] feat(ui): add keymap to close other buffers (#1743) * feat(ui): add keymap to close other buffers * refactor --------- Co-authored-by: Folke Lemaitre --- lua/lazyvim/config/keymaps.lua | 15 ++++----------- lua/lazyvim/plugins/ui.lua | 7 +++++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 173705ab..bdfdec88 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -30,17 +30,10 @@ map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) -- buffers -if Util.has("bufferline.nvim") then - map("n", "", "BufferLineCyclePrev", { desc = "Prev buffer" }) - map("n", "", "BufferLineCycleNext", { desc = "Next buffer" }) - map("n", "[b", "BufferLineCyclePrev", { desc = "Prev buffer" }) - map("n", "]b", "BufferLineCycleNext", { desc = "Next buffer" }) -else - map("n", "", "bprevious", { desc = "Prev buffer" }) - map("n", "", "bnext", { desc = "Next buffer" }) - map("n", "[b", "bprevious", { desc = "Prev buffer" }) - map("n", "]b", "bnext", { desc = "Next buffer" }) -end +map("n", "", "bprevious", { desc = "Prev buffer" }) +map("n", "", "bnext", { desc = "Next buffer" }) +map("n", "[b", "bprevious", { desc = "Prev buffer" }) +map("n", "]b", "bnext", { desc = "Next buffer" }) map("n", "bb", "e #", { desc = "Switch to Other Buffer" }) map("n", "`", "e #", { desc = "Switch to Other Buffer" }) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 73a52cdf..3ccda60b 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -61,6 +61,13 @@ return { keys = { { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, + { "bo", "BufferlineCloseOthers", desc = "Delete other buffers" }, + { "br", "BufferlineCloseRight", desc = "Delete buffers to the right" }, + { "bl", "BufferlineCloseLeft", desc = "Delete buffers to the left" }, + { "", "BufferLineCyclePrev", desc = "Prev buffer" }, + { "", "BufferLineCycleNext", desc = "Next buffer" }, + { "[b", "BufferLineCyclePrev", desc = "Prev buffer" }, + { "]b", "BufferLineCycleNext", desc = "Next buffer" }, }, opts = { options = { From 8c726cd16638f51308f479f26143d94a6c3013ea Mon Sep 17 00:00:00 2001 From: Edouard Shamis <47914518+edshamis@users.noreply.github.com> Date: Mon, 16 Oct 2023 08:44:10 +0300 Subject: [PATCH 301/362] feat(lualine): use gitsigns for diff source (#1744) Co-authored-by: edshamis --- lua/lazyvim/plugins/ui.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 3ccda60b..69b46309 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -184,6 +184,16 @@ return { modified = icons.git.modified, removed = icons.git.removed, }, + source = function() + local gitsigns = vim.b.gitsigns_status_dict + if gitsigns then + return { + added = gitsigns.added, + modified = gitsigns.changed, + removed = gitsigns.removed, + } + end + end, }, }, lualine_y = { From 5c4f8811587d42965beea8eee3a9895cc7911c6a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 07:39:24 +0200 Subject: [PATCH 302/362] style(keymaps): no need to check for trouble to set [q, ]q --- lua/lazyvim/config/keymaps.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index bdfdec88..4b36d0ab 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -81,10 +81,8 @@ map("n", "fn", "enew", { desc = "New File" }) map("n", "xl", "lopen", { desc = "Location List" }) map("n", "xq", "copen", { desc = "Quickfix List" }) -if not Util.has("trouble.nvim") then - map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) - map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) -end +map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) +map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) -- formatting map({ "n", "v" }, "cf", function() From 982c8e301bb432f44a85d915a8268442c7db05fa Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 08:11:15 +0200 Subject: [PATCH 303/362] fix(conform): remove LazyVim's conform config changes since that's now merged in conform --- lua/lazyvim/plugins/formatting.lua | 38 +++++++++++++++++------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index c98a7252..28c794fc 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -3,21 +3,17 @@ local Util = require("lazyvim.util") local M = {} ---@type ConformOpts -local format_opts = {} +local conform_opts = {} ---@param opts ConformOpts function M.setup(_, opts) - local util = require("conform.util") - opts.formatters = opts.formatters or {} - for name, formatter in pairs(opts.formatters) do + for name, formatter in pairs(opts.formatters or {}) do if type(formatter) == "table" then - local ok, defaults = pcall(require, "conform.formatters." .. name) - if ok and type(defaults) == "table" then - opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter) - end - if opts.formatters[name].extra_args then - opts.formatters[name].args = - util.extend_args(opts.formatters[name].args or {}, opts.formatters[name].extra_args) + ---@diagnostic disable-next-line: undefined-field + if formatter.extra_args then + ---@diagnostic disable-next-line: undefined-field + formatter.prepend_args = formatter.extra_args + Util.deprecate(("opts.formatters.%s.extra_args"):format(name), ("opts.formatters.%s.prepend_args"):format(name)) end end end @@ -29,10 +25,11 @@ function M.setup(_, opts) key ) ) + ---@diagnostic disable-next-line: no-unknown opts[key] = nil end end - format_opts = opts.format + conform_opts = opts require("conform").setup(opts) end @@ -61,10 +58,15 @@ return { priority = 100, primary = true, format = function(buf) - require("conform").format(Util.merge(format_opts, { bufnr = buf })) + require("conform").format(Util.merge({ + timeout_ms = conform_opts.format.timeout_ms, + async = conform_opts.format.async, + quiet = conform_opts.format.quiet, + }, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) + ---@param v conform.FormatterInfo return vim.tbl_map(function(v) return v.name end, ret) @@ -82,11 +84,14 @@ return { }, { title = "LazyVim" }) end ---@class ConformOpts - return { + local opts = { -- LazyVim will use these options when formatting with the conform.nvim formatter format = { - timeout_ms = 1000, + timeout_ms = 3000, + async = false, -- not recommended to change + quiet = false, -- not recommended to change }, + ---@type table formatters_by_ft = { lua = { "stylua" }, fish = { "fish_indent" }, @@ -94,7 +99,7 @@ return { }, -- LazyVim will merge the options you set here with builtin formatters. -- You can also define any custom formatters here. - ---@type table + ---@type table formatters = { injected = { options = { ignore_errors = true } }, -- # Example of using dprint only when a dprint.json file is present @@ -110,6 +115,7 @@ return { -- }, }, } + return opts end, config = M.setup, }, From 152e1c6692566a2e2a3968fbfc6eca69d33ba02c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 08:36:27 +0200 Subject: [PATCH 304/362] feat(markdown): added headlines.nvim to markdown extra --- lua/lazyvim/plugins/extras/lang/markdown.lua | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index f57954f1..3fc9c0f1 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -61,4 +61,19 @@ return { vim.cmd([[do FileType]]) end, }, + + { + "lukas-reineke/headlines.nvim", + opts = function() + local opts = {} + for _, ft in ipairs({ "markdown", "norg", "rmd", "org" }) do + opts[ft] = { headline_highlights = {} } + for i = 1, 6 do + table.insert(opts[ft].headline_highlights, "Headline" .. i) + end + end + return opts + end, + ft = { "markdown", "norg", "rmd", "org" }, + }, } From 9517e64009a1a547f5e5b96a8fc78bf5ea0bbb6e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 08:35:35 +0200 Subject: [PATCH 305/362] fix(root): root dir for windows. Fixes #1749 --- lua/lazyvim/util/lualine.lua | 4 ++-- lua/lazyvim/util/root.lua | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 1ec2cd19..3e3cdb9a 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -75,7 +75,7 @@ function M.pretty_path(opts) if path == "" then return "" end - local root = Util.root.get() + local root = Util.root.get({ normalize = true }) local cwd = Util.root.cwd() if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then @@ -111,7 +111,7 @@ function M.root_dir(opts) local function get() local cwd = Util.root.cwd() - local root = Util.root.get() + local root = Util.root.get({ normalize = true }) local name = vim.fs.basename(root) if root == cwd then diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 519546e1..a6deb240 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -141,10 +141,16 @@ end -- * lsp root_dir -- * root pattern of filename of the current buffer -- * root pattern of cwd +---@param opts {normalize?:boolean} ---@return string -function M.get() +function M.get(opts) + opts = opts or {} local roots = M.detect({ all = false }) - return roots[1] and roots[1].paths[1] or vim.loop.cwd() + local ret = roots[1] and roots[1].paths[1] or vim.loop.cwd() + if opts.normalize then + return ret + end + return Util.is_win() and ret:gsub("/", "\\") or ret end ---@param opts? {hl_last?: string} From f513e1cedef94d7e464a1c45cc0a6bf8e452dc43 Mon Sep 17 00:00:00 2001 From: ueaner Date: Mon, 16 Oct 2023 16:41:54 +0800 Subject: [PATCH 306/362] ci: LazyVim now requires Neovim >= 0.9.0 (#1751) --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2ffff686..51c47553 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: uses: kdheepak/panvimdoc@main with: vimdoc: LazyVim - version: "Neovim >= 0.8.0" + version: "Neovim >= 0.9.0" demojify: true treesitter: true - name: Push changes From db175ef3f6886675691b53e6a30aecee9ca73d22 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Oct 2023 08:42:32 +0000 Subject: [PATCH 307/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 82cf4b6a..19a7948e 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 16 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 16 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 98db7ec0d287adcd8eaf6a93c4a392f588b5615a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 12:42:54 +0200 Subject: [PATCH 308/362] perf(root): cache root detection. Fixes #1753 --- lua/lazyvim/config/init.lua | 5 +---- lua/lazyvim/util/root.lua | 30 +++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 3b8092c7..fd9ffcd2 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -180,10 +180,7 @@ function M.setup(opts) Util.format.setup() Util.news.setup() - - vim.api.nvim_create_user_command("LazyRoot", function() - Util.root.info() - end, { desc = "LazyVim roots for the current buffer" }) + Util.root.setup() vim.api.nvim_create_user_command("LazyExtras", function() Util.extras.show() diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index a6deb240..29581975 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -136,18 +136,38 @@ function M.info() return roots[1] and roots[1].paths[1] or vim.loop.cwd() end +---@type table +M.cache = {} + +function M.setup() + vim.api.nvim_create_user_command("LazyRoot", function() + Util.root.info() + end, { desc = "LazyVim roots for the current buffer" }) + + vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost" }, { + group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }), + callback = function(event) + M.cache[event.buf] = nil + end, + }) +end + -- returns the root directory based on: -- * lsp workspace folders -- * lsp root_dir -- * root pattern of filename of the current buffer -- * root pattern of cwd ----@param opts {normalize?:boolean} +---@param opts? {normalize?:boolean} ---@return string function M.get(opts) - opts = opts or {} - local roots = M.detect({ all = false }) - local ret = roots[1] and roots[1].paths[1] or vim.loop.cwd() - if opts.normalize then + local buf = vim.api.nvim_get_current_buf() + local ret = M.cache[buf] + if not ret then + local roots = M.detect({ all = false }) + ret = roots[1] and roots[1].paths[1] or vim.loop.cwd() + M.cache[buf] = ret + end + if opts and opts.normalize then return ret end return Util.is_win() and ret:gsub("/", "\\") or ret From 3dbeda9d96a2225875c4991116cb834f20588ddb Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 12:44:41 +0200 Subject: [PATCH 309/362] fix(markdown): add marksman to mason install --- lua/lazyvim/plugins/extras/lang/markdown.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 3fc9c0f1..ecb9b0a6 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -11,7 +11,7 @@ return { "williamboman/mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "markdownlint" }) + vim.list_extend(opts.ensure_installed, { "markdownlint", "marksman" }) end, }, { From 5926cda069e266534ad13da74053d7588cdbf8db Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:37:38 +0200 Subject: [PATCH 310/362] chore(main): release 10.4.0 (#1747) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 22 ++++++++++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c3bd78..1ac78384 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,27 @@ # Changelog +## [10.4.0](https://github.com/LazyVim/LazyVim/compare/v10.3.0...v10.4.0) (2023-10-16) + + +### Features + +* **keymaps:** added toggle for treesitter highlights ([be5eea4](https://github.com/LazyVim/LazyVim/commit/be5eea476c98d46aefbbaee04b7f2bc82bb51c27)) +* **lualine:** use gitsigns for diff source ([#1744](https://github.com/LazyVim/LazyVim/issues/1744)) ([8c726cd](https://github.com/LazyVim/LazyVim/commit/8c726cd16638f51308f479f26143d94a6c3013ea)) +* **markdown:** added headlines.nvim to markdown extra ([152e1c6](https://github.com/LazyVim/LazyVim/commit/152e1c6692566a2e2a3968fbfc6eca69d33ba02c)) +* **ui:** add keymap to close other buffers ([#1743](https://github.com/LazyVim/LazyVim/issues/1743)) ([c3daced](https://github.com/LazyVim/LazyVim/commit/c3daced11ce33875059ad5dd74832bf4a232f195)) + + +### Bug Fixes + +* **conform:** remove LazyVim's conform config changes since that's now merged in conform ([982c8e3](https://github.com/LazyVim/LazyVim/commit/982c8e301bb432f44a85d915a8268442c7db05fa)) +* **markdown:** add marksman to mason install ([3dbeda9](https://github.com/LazyVim/LazyVim/commit/3dbeda9d96a2225875c4991116cb834f20588ddb)) +* **root:** root dir for windows. Fixes [#1749](https://github.com/LazyVim/LazyVim/issues/1749) ([9517e64](https://github.com/LazyVim/LazyVim/commit/9517e64009a1a547f5e5b96a8fc78bf5ea0bbb6e)) + + +### Performance Improvements + +* **root:** cache root detection. Fixes [#1753](https://github.com/LazyVim/LazyVim/issues/1753) ([98db7ec](https://github.com/LazyVim/LazyVim/commit/98db7ec0d287adcd8eaf6a93c4a392f588b5615a)) + ## [10.3.0](https://github.com/LazyVim/LazyVim/compare/v10.2.0...v10.3.0) (2023-10-15) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index fd9ffcd2..7f491c91 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.3.0" -- x-release-please-version +M.version = "10.4.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From fef0b3f7564e64f92df129cd86bc904afc19b976 Mon Sep 17 00:00:00 2001 From: Kevin Traver Date: Mon, 16 Oct 2023 09:19:52 -0600 Subject: [PATCH 311/362] fix(ui): fix BufferLineClose commands (#1756) BufferLine has capital letter l --- lua/lazyvim/plugins/ui.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 69b46309..5eaeb4a0 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -61,9 +61,9 @@ return { keys = { { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, - { "bo", "BufferlineCloseOthers", desc = "Delete other buffers" }, - { "br", "BufferlineCloseRight", desc = "Delete buffers to the right" }, - { "bl", "BufferlineCloseLeft", desc = "Delete buffers to the left" }, + { "bo", "BufferLineCloseOthers", desc = "Delete other buffers" }, + { "br", "BufferLineCloseRight", desc = "Delete buffers to the right" }, + { "bl", "BufferLineCloseLeft", desc = "Delete buffers to the left" }, { "", "BufferLineCyclePrev", desc = "Prev buffer" }, { "", "BufferLineCycleNext", desc = "Next buffer" }, { "[b", "BufferLineCyclePrev", desc = "Prev buffer" }, From ff64cc53992b966a2558e95afc449e1da29dd44d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Mon, 16 Oct 2023 23:01:18 +0200 Subject: [PATCH 312/362] fix(format): set formatexpr in options so users can override it. Fixes #1759 --- lua/lazyvim/config/options.lua | 2 ++ lua/lazyvim/plugins/formatting.lua | 1 - lua/lazyvim/util/format.lua | 9 ++++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 5a071a15..d1605f93 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -87,5 +87,7 @@ else vim.opt.foldmethod = "indent" end +vim.o.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()" + -- Fix markdown indentation settings vim.g.markdown_recommended_style = 0 diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 28c794fc..66edd1bb 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -50,7 +50,6 @@ return { }, }, init = function() - vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" -- Install the conform formatter on VeryLazy require("lazyvim.util").on_very_lazy(function() require("lazyvim.util").format.register({ diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index 2a5ef5ac..fa972296 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -25,6 +25,13 @@ function M.register(formatter) end) end +function M.formatexpr() + if Util.has("conform.nvim") then + return require("conform").formatexpr() + end + return vim.lsp.formatexpr({ timeout_ms = 3000 }) +end + ---@param buf? number ---@return (LazyFormatter|{active:boolean,resolved:string[]})[] function M.resolve(buf) @@ -67,7 +74,7 @@ function M.info(buf) end end if not have then - lines[#lines+1] = "\n***No formatters available for this buffer.***" + lines[#lines + 1] = "\n***No formatters available for this buffer.***" end Util[enabled and "info" or "warn"]( table.concat(lines, "\n"), From 42ba1af40fd799f3cd04d4703c6f1a5cc0e349c7 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 23:09:17 +0200 Subject: [PATCH 313/362] chore(main): release 10.4.1 (#1757) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac78384..486131ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [10.4.1](https://github.com/LazyVim/LazyVim/compare/v10.4.0...v10.4.1) (2023-10-16) + + +### Bug Fixes + +* **format:** set formatexpr in options so users can override it. Fixes [#1759](https://github.com/LazyVim/LazyVim/issues/1759) ([ff64cc5](https://github.com/LazyVim/LazyVim/commit/ff64cc53992b966a2558e95afc449e1da29dd44d)) +* **ui:** fix BufferLineClose commands ([#1756](https://github.com/LazyVim/LazyVim/issues/1756)) ([fef0b3f](https://github.com/LazyVim/LazyVim/commit/fef0b3f7564e64f92df129cd86bc904afc19b976)) + ## [10.4.0](https://github.com/LazyVim/LazyVim/compare/v10.3.0...v10.4.0) (2023-10-16) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 7f491c91..0e611fd9 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.4.0" -- x-release-please-version +M.version = "10.4.1" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 315df373f2d0c354b08acd607f6227b07436ce03 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 17 Oct 2023 08:28:12 +0200 Subject: [PATCH 314/362] fix(statuscolumn): correct line numbers & respect more options --- lua/lazyvim/util/ui.lua | 68 +++++++++++++++++++++++------------------ 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 6c5a3c1f..c17a1e7b 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -86,42 +86,50 @@ end function M.statuscolumn() local win = vim.g.statusline_winid - if vim.wo[win].signcolumn == "no" then - return "" - end local buf = vim.api.nvim_win_get_buf(win) + local is_file = vim.bo[buf].buftype == "" + local show_signs = vim.wo[win].signcolumn ~= "no" - ---@type Sign?,Sign?,Sign? - local left, right, fold - for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do - if s.name and s.name:find("GitSign") then - right = s + local components = { "", "", "" } -- left, middle, right + + if show_signs then + ---@type Sign?,Sign?,Sign? + local left, right, fold + for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do + if s.name and s.name:find("GitSign") then + right = s + else + left = s + end + end + if vim.v.virtnum ~= 0 then + left = nil + end + vim.api.nvim_win_call(win, function() + if vim.fn.foldclosed(vim.v.lnum) >= 0 then + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } + end + end) + -- Left: mark or non-git sign + components[1] = M.icon(M.get_mark(buf, vim.v.lnum) or left) + -- Right: fold icon or git sign (only if file) + components[3] = is_file and M.icon(fold or right) or "" + end + + -- Numbers in Neovim are weird + -- They show when either number or relativenumber is true + local is_num = vim.wo[win].number + local is_relnum = vim.wo[win].relativenumber + if (is_num or is_relnum) and vim.v.virtnum == 0 then + if vim.v.relnum == 0 then + components[2] = is_num and "%l" or "%r" -- the current line else - left = s + components[2] = is_relnum and "%r" or "%l" -- other lines end + components[2] = "%=" .. components[2] .. " " -- right align end - if vim.v.virtnum ~= 0 then - left = nil - end - - vim.api.nvim_win_call(win, function() - if vim.fn.foldclosed(vim.v.lnum) >= 0 then - fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } - end - end) - - local nu = "" - if vim.wo[win].number and vim.v.virtnum == 0 then - nu = vim.wo[win].relativenumber and vim.v.relnum ~= 0 and vim.v.relnum or vim.v.lnum - end - - return table.concat({ - M.icon(M.get_mark(buf, vim.v.lnum) or left), - [[%=]], - nu .. " ", - M.icon(fold or right), - }, "") + return table.concat(components, "") end function M.fg(name) From 4da4583b4a0b72569c45208cb0f09f072b6435e9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 17 Oct 2023 06:29:04 +0000 Subject: [PATCH 315/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 19a7948e..5d0601e1 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 16 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 17 ============================================================================== Table of Contents *LazyVim-table-of-contents* From af3ca06472ea60091fb8baba0ffd37b54566501d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 17 Oct 2023 08:42:17 +0200 Subject: [PATCH 316/362] docs: fixed conform examples --- lua/lazyvim/plugins/formatting.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 66edd1bb..6d8c9bc7 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -96,7 +96,7 @@ return { fish = { "fish_indent" }, sh = { "shfmt" }, }, - -- LazyVim will merge the options you set here with builtin formatters. + -- The options you set here will be merged with the builtin formatters. -- You can also define any custom formatters here. ---@type table formatters = { @@ -110,7 +110,7 @@ return { -- -- # Example of using shfmt with extra args -- shfmt = { - -- extra_args = { "-i", "2", "-ci" }, + -- prepend_args = { "-i", "2", "-ci" }, -- }, }, } From c711309a673a755652a90a080fd23dbab5dd61d5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:04:24 +0200 Subject: [PATCH 317/362] chore(main): release 10.4.2 (#1765) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 486131ac..f70e72c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [10.4.2](https://github.com/LazyVim/LazyVim/compare/v10.4.1...v10.4.2) (2023-10-17) + + +### Bug Fixes + +* **statuscolumn:** correct line numbers & respect more options ([315df37](https://github.com/LazyVim/LazyVim/commit/315df373f2d0c354b08acd607f6227b07436ce03)) + ## [10.4.1](https://github.com/LazyVim/LazyVim/compare/v10.4.0...v10.4.1) (2023-10-16) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 0e611fd9..056ab274 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.4.1" -- x-release-please-version +M.version = "10.4.2" -- x-release-please-version ---@class LazyVimOptions local defaults = { From b0ded5c015a68f07a32fab64a2cd0f27f4d69870 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 17 Oct 2023 16:33:55 +0200 Subject: [PATCH 318/362] fix(dot): treesitter langs in dot extra were not added --- lua/lazyvim/plugins/extras/util/dot.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index 2424589d..c25e0f6c 100644 --- a/lua/lazyvim/plugins/extras/util/dot.lua +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -37,7 +37,7 @@ return { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) local function add(lang) - if type(opts.ensure_installed) ~= "table" then + if type(opts.ensure_installed) == "table" then table.insert(opts.ensure_installed, lang) end end From 1d4fbd3b2e48eaae448073af020ca2617ab7bd5c Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 18 Oct 2023 00:03:34 +0800 Subject: [PATCH 319/362] fix(keymaps): let keymap n and N opens folds (#1298) It's strange that mappings to n and N do not open folds like its original behavior, so I append `zv` to manually open folds. --- lua/lazyvim/config/keymaps.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index 4b36d0ab..d7a480cb 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -50,10 +50,10 @@ map( ) -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n -map("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) +map("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next search result" }) map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) -map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) +map("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev search result" }) map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) From 5c1656729aeb39fbb8dc29d4f3d6d86d0836f8b4 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 17 Oct 2023 18:28:06 +0200 Subject: [PATCH 320/362] fix(dashboard): config shortcut when opening dashboard again. Fixes #1768 --- lua/lazyvim/plugins/ui.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 5eaeb4a0..d0d24533 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -371,15 +371,15 @@ return { header = vim.split(logo, "\n"), -- stylua: ignore center = { - { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, - { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, - { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, - { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, - { action = Util.telescope.config_files(), desc = " Config", icon = " ", key = "c" }, - { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, - { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, - { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, + { action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" }, + { action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" }, + { action = [[lua require("lazyvim.util").telescope.config_files()()]], desc = " Config", icon = " ", key = "c" }, + { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, + { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" }, }, footer = function() local stats = require("lazy").stats() From 2e308d5440c830bb37531d03a0313af3a5c94bb5 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 18 Oct 2023 00:04:28 +0200 Subject: [PATCH 321/362] fix(neotest): better integration with trouble: no longer steals focus and hides when all ok --- lua/lazyvim/plugins/extras/test/core.lua | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/test/core.lua b/lua/lazyvim/plugins/extras/test/core.lua index d22e5205..321955ab 100644 --- a/lua/lazyvim/plugins/extras/test/core.lua +++ b/lua/lazyvim/plugins/extras/test/core.lua @@ -27,7 +27,7 @@ return { quickfix = { open = function() if require("lazyvim.util").has("trouble.nvim") then - vim.cmd("Trouble quickfix") + require("trouble").open({ mode = "quickfix", focus = false }) else vim.cmd("copen") end @@ -46,6 +46,37 @@ return { }, }, neotest_ns) + if require("lazyvim.util").has("trouble.nvim") then + opts.consumers = opts.consumers or {} + -- Refresh and auto close trouble after running tests + ---@type neotest.Consumer + opts.consumers.trouble = function(client) + client.listeners.results = function(adapter_id, results, partial) + if partial then + return + end + local tree = assert(client:get_position(nil, { adapter = adapter_id })) + + local failed = 0 + for pos_id, result in pairs(results) do + if result.status == "failed" and tree:get_key(pos_id) then + failed = failed + 1 + end + end + vim.schedule(function() + local trouble = require("trouble") + if trouble.is_open() then + trouble.refresh() + if failed == 0 then + trouble.close() + end + end + end) + return {} + end + end + end + if opts.adapters then local adapters = {} for name, config in pairs(opts.adapters or {}) do From 0e12b007433d910adc1081f267f3894f887942e3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 00:06:46 +0200 Subject: [PATCH 322/362] chore(main): release 10.4.3 (#1771) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 10 ++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f70e72c7..ba2d6af4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [10.4.3](https://github.com/LazyVim/LazyVim/compare/v10.4.2...v10.4.3) (2023-10-17) + + +### Bug Fixes + +* **dashboard:** config shortcut when opening dashboard again. Fixes [#1768](https://github.com/LazyVim/LazyVim/issues/1768) ([5c16567](https://github.com/LazyVim/LazyVim/commit/5c1656729aeb39fbb8dc29d4f3d6d86d0836f8b4)) +* **dot:** treesitter langs in dot extra were not added ([b0ded5c](https://github.com/LazyVim/LazyVim/commit/b0ded5c015a68f07a32fab64a2cd0f27f4d69870)) +* **keymaps:** let keymap n and N opens folds ([#1298](https://github.com/LazyVim/LazyVim/issues/1298)) ([1d4fbd3](https://github.com/LazyVim/LazyVim/commit/1d4fbd3b2e48eaae448073af020ca2617ab7bd5c)) +* **neotest:** better integration with trouble: no longer steals focus and hides when all ok ([2e308d5](https://github.com/LazyVim/LazyVim/commit/2e308d5440c830bb37531d03a0313af3a5c94bb5)) + ## [10.4.2](https://github.com/LazyVim/LazyVim/compare/v10.4.1...v10.4.2) (2023-10-17) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 056ab274..2b4ff20e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.4.2" -- x-release-please-version +M.version = "10.4.3" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 7d8b3e8ef96f91f96c8e3a0ba62dfab270debf9f Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 18 Oct 2023 11:38:54 +0200 Subject: [PATCH 323/362] fix(project): don't let `project.nvim` change the cwd. Leads to too much confusion --- lua/lazyvim/plugins/extras/util/project.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 8164d19f..e05f75fb 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -5,7 +5,9 @@ return { -- project management { "ahmedkhalf/project.nvim", - opts = {}, + opts = { + manual_mode = true, + }, event = "VeryLazy", config = function(_, opts) require("project_nvim").setup(opts) From 5c8cefaf40ea21fe5e954fd241ca1821733111b3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 18 Oct 2023 09:39:39 +0000 Subject: [PATCH 324/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 5d0601e1..ea17820b 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 17 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 18 ============================================================================== Table of Contents *LazyVim-table-of-contents* From ae77bfda89067c36291365c0e2b4d4db7bbc3aac Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Oct 2023 13:11:54 +0200 Subject: [PATCH 325/362] chore(main): release 10.4.4 (#1786) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba2d6af4..4b16dd17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [10.4.4](https://github.com/LazyVim/LazyVim/compare/v10.4.3...v10.4.4) (2023-10-18) + + +### Bug Fixes + +* **project:** don't let `project.nvim` change the cwd. Leads to too much confusion ([7d8b3e8](https://github.com/LazyVim/LazyVim/commit/7d8b3e8ef96f91f96c8e3a0ba62dfab270debf9f)) + ## [10.4.3](https://github.com/LazyVim/LazyVim/compare/v10.4.2...v10.4.3) (2023-10-17) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 2b4ff20e..b99f473c 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.4.3" -- x-release-please-version +M.version = "10.4.4" -- x-release-please-version ---@class LazyVimOptions local defaults = { From d73aee4a934b0aa12e07039da9e2df0215ba2cba Mon Sep 17 00:00:00 2001 From: Jorge Villalobos Date: Thu, 19 Oct 2023 01:45:03 -0400 Subject: [PATCH 326/362] feat(dashboard): remove unnecessary brackets from keys (#1791) --- lua/lazyvim/plugins/ui.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index d0d24533..2f97c374 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -391,6 +391,7 @@ return { for _, button in ipairs(opts.config.center) do button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + button.key_format = " %s" end -- close Lazy and re-open when the dashboard is ready From b8c7e70c80ee9689a45b19c3c58020e69c9fef8a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 19 Oct 2023 05:45:44 +0000 Subject: [PATCH 327/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index ea17820b..b1e64e73 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 18 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 19 ============================================================================== Table of Contents *LazyVim-table-of-contents* From 0ac8f6fb3b1705c2b675a0e3cbee4968370f047a Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 19 Oct 2023 07:45:46 +0200 Subject: [PATCH 328/362] fix(treesitter-context): set default max_lines=3 --- lua/lazyvim/plugins/treesitter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 1b4debcf..c8ba7f48 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -109,7 +109,7 @@ return { "nvim-treesitter/nvim-treesitter-context", event = "LazyFile", enabled = true, - opts = { mode = "cursor" }, + opts = { mode = "cursor", max_lines = 3 }, keys = { { "ut", From 98b51a608cf89fca43e9d026d21b75d251e17167 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 19 Oct 2023 07:47:37 +0200 Subject: [PATCH 329/362] style(dashboard): make layout exactly the same as before --- lua/lazyvim/plugins/ui.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 2f97c374..88577395 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -391,7 +391,7 @@ return { for _, button in ipairs(opts.config.center) do button.desc = button.desc .. string.rep(" ", 43 - #button.desc) - button.key_format = " %s" + button.key_format = " %s" end -- close Lazy and re-open when the dashboard is ready From ea3155aef6d47e744cb2b4a7a3b567288d780f8d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 19 Oct 2023 07:52:45 +0200 Subject: [PATCH 330/362] fix(conform): allow overriding all conform format options. Fixes #1790 --- lua/lazyvim/plugins/formatting.lua | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index 6d8c9bc7..eb2dd1a8 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -2,9 +2,6 @@ local Util = require("lazyvim.util") local M = {} ----@type ConformOpts -local conform_opts = {} - ---@param opts ConformOpts function M.setup(_, opts) for name, formatter in pairs(opts.formatters or {}) do @@ -29,7 +26,6 @@ function M.setup(_, opts) opts[key] = nil end end - conform_opts = opts require("conform").setup(opts) end @@ -57,11 +53,10 @@ return { priority = 100, primary = true, format = function(buf) - require("conform").format(Util.merge({ - timeout_ms = conform_opts.format.timeout_ms, - async = conform_opts.format.async, - quiet = conform_opts.format.quiet, - }, { bufnr = buf })) + local plugin = require("lazy.core.config").plugins["conform.nvim"] + local Plugin = require("lazy.core.plugin") + local opts = Plugin.values(plugin, "opts", false) + require("conform").format(Util.merge(opts.format, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) From fad37772967f06c65d6f0b52c2ea6f190b3218ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Freitas?= Date: Thu, 19 Oct 2023 06:54:19 +0100 Subject: [PATCH 331/362] fix(tabnine): run `:CmpTabnineHub` automatically on build (#1788) --- lua/lazyvim/plugins/extras/coding/tabnine.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua index 696103ce..aac8519e 100644 --- a/lua/lazyvim/plugins/extras/coding/tabnine.lua +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -5,10 +5,12 @@ return { { "nvim-cmp", dependencies = { - -- Add TabNine support, make sure you run :CmpTabnineHub after installation. { "tzachar/cmp-tabnine", - build = Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", + build = { + Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", + ":CmpTabnineHub", + }, dependencies = "hrsh7th/nvim-cmp", opts = { max_lines = 1000, From 82da2440e4c9d7e604cf998aee0655f78ddfdd5c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 19 Oct 2023 19:54:34 +0200 Subject: [PATCH 332/362] fix(nvim-ts-autotag): make it actually work :) --- lua/lazyvim/plugins/treesitter.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index c8ba7f48..3277ef83 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -131,7 +131,7 @@ return { -- Automatically add closing tags for HTML and JSX { "windwp/nvim-ts-autotag", - event = "InsertEnter", + event = "LazyFile", opts = {}, }, } From 8df44b3bb54483e42a27dc30a8b343acc5d5d242 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Thu, 19 Oct 2023 14:12:48 -0400 Subject: [PATCH 333/362] feat(typescript): added remove unused imports (#1794) --- lua/lazyvim/plugins/extras/lang/typescript.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4af1deec..4f53ae8c 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -32,6 +32,19 @@ return { end, desc = "Organize Imports", }, + { + "cR", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.removeUnused.ts" }, + diagnostics = {}, + }, + }) + end, + desc = "Remove Unused Imports", + }, }, settings = { typescript = { From e996eed750aabdfaa976357450f9ccbcd333a785 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 20:14:17 +0200 Subject: [PATCH 334/362] chore(main): release 10.5.0 (#1800) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 15 +++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b16dd17..85e623c7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19) + + +### Features + +* **dashboard:** remove unnecessary brackets from keys ([#1791](https://github.com/LazyVim/LazyVim/issues/1791)) ([d73aee4](https://github.com/LazyVim/LazyVim/commit/d73aee4a934b0aa12e07039da9e2df0215ba2cba)) + + +### Bug Fixes + +* **conform:** allow overriding all conform format options. Fixes [#1790](https://github.com/LazyVim/LazyVim/issues/1790) ([ea3155a](https://github.com/LazyVim/LazyVim/commit/ea3155aef6d47e744cb2b4a7a3b567288d780f8d)) +* **nvim-ts-autotag:** make it actually work :) ([82da244](https://github.com/LazyVim/LazyVim/commit/82da2440e4c9d7e604cf998aee0655f78ddfdd5c)) +* **tabnine:** run `:CmpTabnineHub` automatically on build ([#1788](https://github.com/LazyVim/LazyVim/issues/1788)) ([fad3777](https://github.com/LazyVim/LazyVim/commit/fad37772967f06c65d6f0b52c2ea6f190b3218ee)) +* **treesitter-context:** set default max_lines=3 ([0ac8f6f](https://github.com/LazyVim/LazyVim/commit/0ac8f6fb3b1705c2b675a0e3cbee4968370f047a)) + ## [10.4.4](https://github.com/LazyVim/LazyVim/compare/v10.4.3...v10.4.4) (2023-10-18) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index b99f473c..09e6c6e0 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.4.4" -- x-release-please-version +M.version = "10.5.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 0bb628053beec25efbc5bd1e8600ef039fa75a20 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Oct 2023 20:16:16 +0200 Subject: [PATCH 335/362] chore(main): release 10.5.0 (#1808) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85e623c7..4dd289f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ ## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19) +### Features + +* **dashboard:** remove unnecessary brackets from keys ([#1791](https://github.com/LazyVim/LazyVim/issues/1791)) ([d73aee4](https://github.com/LazyVim/LazyVim/commit/d73aee4a934b0aa12e07039da9e2df0215ba2cba)) +* **typescript:** added remove unused imports ([#1794](https://github.com/LazyVim/LazyVim/issues/1794)) ([8df44b3](https://github.com/LazyVim/LazyVim/commit/8df44b3bb54483e42a27dc30a8b343acc5d5d242)) + + +### Bug Fixes + +* **conform:** allow overriding all conform format options. Fixes [#1790](https://github.com/LazyVim/LazyVim/issues/1790) ([ea3155a](https://github.com/LazyVim/LazyVim/commit/ea3155aef6d47e744cb2b4a7a3b567288d780f8d)) +* **nvim-ts-autotag:** make it actually work :) ([82da244](https://github.com/LazyVim/LazyVim/commit/82da2440e4c9d7e604cf998aee0655f78ddfdd5c)) +* **tabnine:** run `:CmpTabnineHub` automatically on build ([#1788](https://github.com/LazyVim/LazyVim/issues/1788)) ([fad3777](https://github.com/LazyVim/LazyVim/commit/fad37772967f06c65d6f0b52c2ea6f190b3218ee)) +* **treesitter-context:** set default max_lines=3 ([0ac8f6f](https://github.com/LazyVim/LazyVim/commit/0ac8f6fb3b1705c2b675a0e3cbee4968370f047a)) + +## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19) + + ### Features * **dashboard:** remove unnecessary brackets from keys ([#1791](https://github.com/LazyVim/LazyVim/issues/1791)) ([d73aee4](https://github.com/LazyVim/LazyVim/commit/d73aee4a934b0aa12e07039da9e2df0215ba2cba)) From 786a061eaa2b994fcd13e5dd31ea0e73a9d76069 Mon Sep 17 00:00:00 2001 From: abeldekat <58370433+abeldekat@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:27:10 +0000 Subject: [PATCH 336/362] style(dashboard): remove unnecessary brackets from keys, including extras (#1809) * style(dashboard): remove unnecessary brackets from keys, including the p key from the project extras * review Folke --------- Co-authored-by: abeldekat --- lua/lazyvim/plugins/extras/util/project.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index e05f75fb..3936c96a 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -56,6 +56,10 @@ return { icon = " ", key = "p", } + + projects.desc = projects.desc .. string.rep(" ", 43 - #projects.desc) + projects.key_format = " %s" + table.insert(opts.config.center, 3, projects) end, }, From fa3170d422f3c661d0411472c96f92e5324dc281 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 20 Oct 2023 11:27:50 +0000 Subject: [PATCH 337/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index b1e64e73..eb178733 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 19 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 20 ============================================================================== Table of Contents *LazyVim-table-of-contents* From e55ab411b42c75919b33b87e19714b5c595316d4 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sun, 22 Oct 2023 15:44:08 +0300 Subject: [PATCH 338/362] fix(mini.hipatterns): use `extmark_opts` instead of soft deprecated `priority` (#1841) --- lua/lazyvim/plugins/extras/util/mini-hipatterns.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 43b8c49d..2add9c2f 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -67,7 +67,7 @@ M.plugin = { return hl end end, - priority = 2000, + extmark_opts = { priority = 2000 }, } end require("mini.hipatterns").setup(opts) From e7130c8250c403140ce504bde9e973d5a301ab4c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 22 Oct 2023 12:44:41 +0000 Subject: [PATCH 339/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index eb178733..d3e0227b 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 20 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 22 ============================================================================== Table of Contents *LazyVim-table-of-contents* From ef5ec9a3bf6b03d9e81cc5252ec685bbbb0cdbed Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 22 Oct 2023 21:44:43 +0200 Subject: [PATCH 340/362] style: added trouble ft for the next gen trouble --- lua/lazyvim/plugins/colorscheme.lua | 1 + lua/lazyvim/plugins/editor.lua | 2 +- lua/lazyvim/plugins/extras/ui/edgy.lua | 8 +++++++- lua/lazyvim/plugins/ui.lua | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/colorscheme.lua b/lua/lazyvim/plugins/colorscheme.lua index 8ed12bbd..2c28f1c4 100644 --- a/lua/lazyvim/plugins/colorscheme.lua +++ b/lua/lazyvim/plugins/colorscheme.lua @@ -21,6 +21,7 @@ return { illuminate = true, indent_blankline = { enabled = true }, lsp_trouble = true, + trouble = true, mason = true, mini = true, native_lsp = { diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 9ee3eb03..67c45e51 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -52,7 +52,7 @@ return { end, opts = { sources = { "filesystem", "buffers", "git_status", "document_symbols" }, - open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "Outline" }, + open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" }, filesystem = { bind_to_cwd = false, follow_current_file = { enabled = true }, diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 6cabd24d..e2513828 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -40,6 +40,12 @@ return { end, }, "Trouble", + { + ft = "trouble", + filter = function(buf, win) + return vim.api.nvim_win_get_config(win).relative == "" + end, + }, { ft = "qf", title = "QuickFix" }, { ft = "help", @@ -129,7 +135,7 @@ return { optional = true, opts = function(_, opts) opts.open_files_do_not_replace_types = opts.open_files_do_not_replace_types - or { "terminal", "Trouble", "qf", "Outline" } + or { "terminal", "Trouble", "qf", "Outline", "trouble" } table.insert(opts.open_files_do_not_replace_types, "edgy") end, }, diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 88577395..5f8ece20 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -228,6 +228,7 @@ return { "dashboard", "neo-tree", "Trouble", + "trouble", "lazy", "mason", "notify", @@ -259,11 +260,13 @@ return { "dashboard", "neo-tree", "Trouble", + "trouble", "lazy", "mason", "notify", "toggleterm", "lazyterm", + "trouble", }, callback = function() vim.b.miniindentscope_disable = true From 99598ef7c7c15c980b6d5c36f8e9cefd745fcf34 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 12:35:22 +0200 Subject: [PATCH 341/362] feat(telescope): sort buffers with lastused and mru --- lua/lazyvim/plugins/editor.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 67c45e51..8c34f357 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -127,12 +127,16 @@ return { }, }, keys = { - { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, + { + ",", + "Telescope buffers sort_mru=true sort_lastused=true", + desc = "Switch Buffer", + }, { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { ":", "Telescope command_history", desc = "Command History" }, { "", Util.telescope("files"), desc = "Find Files (root dir)" }, -- find - { "fb", "Telescope buffers", desc = "Buffers" }, + { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, { "fc", Util.telescope.config_files(), desc = "Find Config File" }, { "ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, From a5c9708736f6ecd3e3413ad0ca34b7b1fa3d4862 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 14:05:29 +0200 Subject: [PATCH 342/362] perf(ui): wrap treesitter.foldexpr and cache get_parser during a event loop tick. Fixes #1846 --- lua/lazyvim/config/options.lua | 2 +- lua/lazyvim/util/ui.lua | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index d1605f93..69e8e8d3 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -82,7 +82,7 @@ end -- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now if vim.fn.has("nvim-0.10") == 1 then vim.opt.foldmethod = "expr" - vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()" else vim.opt.foldmethod = "indent" end diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index c17a1e7b..68999eda 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -141,4 +141,42 @@ function M.fg(name) return fg and { fg = string.format("#%06x", fg) } or nil end +M.skip_foldexpr = {} ---@type table +local skip_check = assert(vim.loop.new_check()) + +function M.foldexpr() + local buf = vim.api.nvim_get_current_buf() + + -- still in the same tick and no parser + if M.skip_foldexpr[buf] then + return "0" + end + + -- don't use treesitter folds for non-file buffers + if vim.bo[buf].buftype ~= "" then + return "0" + end + + -- as long as we don't have a filetype, don't bother + -- checking if treesitter is available (it won't) + if vim.bo[buf].filetype == "" then + return "0" + end + + local ok = pcall(vim.treesitter.get_parser, buf) + + if ok then + return vim.treesitter.foldexpr() + end + + -- no parser available, so mark it as skip + -- in the next tick, all skip marks will be reset + M.skip_foldexpr[buf] = true + skip_check:start(function() + M.skip_foldexpr = {} + skip_check:stop() + end) + return "0" +end + return M From c400cf0014d293d08414e1f98582b9baa9449b49 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 25 Oct 2023 12:06:15 +0000 Subject: [PATCH 343/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index d3e0227b..6982b959 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 22 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 25 ============================================================================== Table of Contents *LazyVim-table-of-contents* From eab464d52d28d4e24e5d189ee627c96e720e057c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 14:23:36 +0200 Subject: [PATCH 344/362] fix(markdown): create default numbered Headline groups for colorschemes that dont support them. Fixes #1822 --- lua/lazyvim/plugins/extras/lang/markdown.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index ecb9b0a6..24e3b891 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -67,9 +67,13 @@ return { opts = function() local opts = {} for _, ft in ipairs({ "markdown", "norg", "rmd", "org" }) do - opts[ft] = { headline_highlights = {} } + opts[ft] = { + headline_highlights = {}, + } for i = 1, 6 do - table.insert(opts[ft].headline_highlights, "Headline" .. i) + local hl = "Headline" .. i + vim.api.nvim_set_hl(0, hl, { link = "Headline", default = true }) + table.insert(opts[ft].headline_highlights, hl) end end return opts From 1e1b68d633d4bd4faa912ba5f49ab6b8601dc0c9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 15:40:25 +0200 Subject: [PATCH 345/362] fix(treesitter): make treesitter queries available at startup. See #1816 Fixes #1858 --- lua/lazyvim/plugins/treesitter.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 3277ef83..e66725c0 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -7,6 +7,15 @@ return { version = false, -- last release is way too old and doesn't work on Windows build = ":TSUpdate", event = { "LazyFile", "VeryLazy" }, + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer trigger the **nvim-treeitter** module to be loaded in time. + -- Luckily, the only thins that those plugins need are the custom queries, which we make available + -- during startup. + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects", From b651560ad0ee750c96bca6866cfdc008e75d397c Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 15:40:57 +0200 Subject: [PATCH 346/362] perf(markdown): prevent headlines.nvim slowing down initial rendering with `nvim README.md` --- lua/lazyvim/plugins/extras/lang/markdown.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 24e3b891..5aa9dc33 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -79,5 +79,12 @@ return { return opts end, ft = { "markdown", "norg", "rmd", "org" }, + config = function(_, opts) + -- PERF: schedule to prevent headlines slowing down opening a file + vim.schedule(function() + require("headlines").setup(opts) + require("headlines").refresh() + end) + end, }, } From 6dfeeb83228e7a7aa54972bd76f7cda099ccb35c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:44:48 +0200 Subject: [PATCH 347/362] chore(main): release 10.6.0 (#1842) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 20 ++++++++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dd289f3..773890db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## [10.6.0](https://github.com/LazyVim/LazyVim/compare/v10.5.0...v10.6.0) (2023-10-25) + + +### Features + +* **telescope:** sort buffers with lastused and mru ([99598ef](https://github.com/LazyVim/LazyVim/commit/99598ef7c7c15c980b6d5c36f8e9cefd745fcf34)) + + +### Bug Fixes + +* **markdown:** create default numbered Headline groups for colorschemes that dont support them. Fixes [#1822](https://github.com/LazyVim/LazyVim/issues/1822) ([eab464d](https://github.com/LazyVim/LazyVim/commit/eab464d52d28d4e24e5d189ee627c96e720e057c)) +* **mini.hipatterns:** use `extmark_opts` instead of soft deprecated `priority` ([#1841](https://github.com/LazyVim/LazyVim/issues/1841)) ([e55ab41](https://github.com/LazyVim/LazyVim/commit/e55ab411b42c75919b33b87e19714b5c595316d4)) +* **treesitter:** make treesitter queries available at startup. See [#1816](https://github.com/LazyVim/LazyVim/issues/1816) Fixes [#1858](https://github.com/LazyVim/LazyVim/issues/1858) ([1e1b68d](https://github.com/LazyVim/LazyVim/commit/1e1b68d633d4bd4faa912ba5f49ab6b8601dc0c9)) + + +### Performance Improvements + +* **markdown:** prevent headlines.nvim slowing down initial rendering with `nvim README.md` ([b651560](https://github.com/LazyVim/LazyVim/commit/b651560ad0ee750c96bca6866cfdc008e75d397c)) +* **ui:** wrap treesitter.foldexpr and cache get_parser during a event loop tick. Fixes [#1846](https://github.com/LazyVim/LazyVim/issues/1846) ([a5c9708](https://github.com/LazyVim/LazyVim/commit/a5c9708736f6ecd3e3413ad0ca34b7b1fa3d4862)) + ## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 09e6c6e0..4191a940 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.5.0" -- x-release-please-version +M.version = "10.6.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 61fae7d23f5689a9112b265f4bfb8468a131ae66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=87=91=E9=9B=84=E9=95=95?= Date: Wed, 25 Oct 2023 21:46:39 +0800 Subject: [PATCH 348/362] fix: fix jdtls not spwaning in windows (#1864) --- lua/lazyvim/plugins/extras/lang/java.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index 64808bee..f7e7ca5f 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -85,7 +85,7 @@ return { -- How to run jdtls. This can be overridden to a full java command-line -- if the Python wrapper script doesn't suffice. - cmd = { "jdtls" }, + cmd = { vim.fn.exepath("jdtls") }, full_cmd = function(opts) local fname = vim.api.nvim_buf_get_name(0) local root_dir = opts.root_dir(fname) From 37953585bb06b3ffbdb37b40bb586590fde2b2a9 Mon Sep 17 00:00:00 2001 From: Amaan Qureshi Date: Wed, 25 Oct 2023 09:47:07 -0400 Subject: [PATCH 349/362] fix(extras.python-semshi): improve highlights (#1845) --- lua/lazyvim/plugins/extras/lang/python-semshi.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/python-semshi.lua b/lua/lazyvim/plugins/extras/lang/python-semshi.lua index a9a4870e..e4e32c10 100644 --- a/lua/lazyvim/plugins/extras/lang/python-semshi.lua +++ b/lua/lazyvim/plugins/extras/lang/python-semshi.lua @@ -17,13 +17,14 @@ return { -- Only add style, inherit or link to the LSP's colors vim.cmd([[ highlight! semshiGlobal gui=italic - highlight! semshiImported gui=bold + highlight! link semshiImported @none highlight! link semshiParameter @lsp.type.parameter highlight! link semshiParameterUnused DiagnosticUnnecessary highlight! link semshiBuiltin @function.builtin - highlight! link semshiAttribute @attribute + highlight! link semshiAttribute @field highlight! link semshiSelf @lsp.type.selfKeyword highlight! link semshiUnresolved @lsp.type.unresolvedReference + highlight! link semshiFree @none ]]) end, }) From 9e1f83522396d141455de8f2d5e0b3e8beca8d0a Mon Sep 17 00:00:00 2001 From: Jorge Villalobos Date: Wed, 25 Oct 2023 09:48:45 -0400 Subject: [PATCH 350/362] feat(nvim): extend j/k enhancements to up/down arrows (#1833) --- lua/lazyvim/config/keymaps.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index d7a480cb..c5f70016 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -7,7 +7,9 @@ local map = Util.safe_keymap_set -- better up/down map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -- Move to window using the hjkl keys map("n", "", "h", { desc = "Go to left window", remap = true }) From 58ddf405e09da967eca29169571114b01172fff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=9E?= <42881610+konosubakonoakua@users.noreply.github.com> Date: Wed, 25 Oct 2023 21:50:02 +0800 Subject: [PATCH 351/362] fix(lang): add cmakelint to ensure installed list (#1826) 1. mason/cmakelang install bin/cmake-lint 2. nvim-lint only recognize bin/cmakelint 3. mason/cmakelint install bin/cmakelint so we need mason/cmakelint installed to using nvim-lint to perform formatting --- lua/lazyvim/plugins/extras/lang/cmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index 404a072a..e95dbfdd 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -30,7 +30,7 @@ return { "mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - vim.list_extend(opts.ensure_installed, { "cmakelang" }) + vim.list_extend(opts.ensure_installed, { "cmakelang", "cmakelint" }) end, }, { From 028f69c03c6014f06525eff0a44410bb3f479174 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:51:56 +0200 Subject: [PATCH 352/362] chore(main): release 10.7.0 (#1869) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 14 ++++++++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 773890db..c3dc6034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [10.7.0](https://github.com/LazyVim/LazyVim/compare/v10.6.0...v10.7.0) (2023-10-25) + + +### Features + +* **nvim:** extend j/k enhancements to up/down arrows ([#1833](https://github.com/LazyVim/LazyVim/issues/1833)) ([9e1f835](https://github.com/LazyVim/LazyVim/commit/9e1f83522396d141455de8f2d5e0b3e8beca8d0a)) + + +### Bug Fixes + +* **extras.python-semshi:** improve highlights ([#1845](https://github.com/LazyVim/LazyVim/issues/1845)) ([3795358](https://github.com/LazyVim/LazyVim/commit/37953585bb06b3ffbdb37b40bb586590fde2b2a9)) +* fix jdtls not spwaning in windows ([#1864](https://github.com/LazyVim/LazyVim/issues/1864)) ([61fae7d](https://github.com/LazyVim/LazyVim/commit/61fae7d23f5689a9112b265f4bfb8468a131ae66)) +* **lang:** add cmakelint to ensure installed list ([#1826](https://github.com/LazyVim/LazyVim/issues/1826)) ([58ddf40](https://github.com/LazyVim/LazyVim/commit/58ddf405e09da967eca29169571114b01172fff3)) + ## [10.6.0](https://github.com/LazyVim/LazyVim/compare/v10.5.0...v10.6.0) (2023-10-25) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 4191a940..fc5487c5 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.6.0" -- x-release-please-version +M.version = "10.7.0" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 60e57070131f4c544e17541610415d4d51769d62 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 15:54:35 +0200 Subject: [PATCH 353/362] fix(util): pcall deletion of lazy_file augroup. See #1863 --- lua/lazyvim/util/plugin.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 9ff2c986..fdd76f1a 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -80,7 +80,7 @@ function M.lazy_file() if #events == 0 then return end - vim.api.nvim_del_augroup_by_name("lazy_file") + pcall(vim.api.nvim_del_augroup_by_name, "lazy_file") ---@type table local skips = {} From f589154268dfcb3e8f91075791a0a618c97fe59d Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 17:23:37 +0200 Subject: [PATCH 354/362] fix(catppuccin): trouble integration. Fixes #1872 --- lua/lazyvim/plugins/colorscheme.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/plugins/colorscheme.lua b/lua/lazyvim/plugins/colorscheme.lua index 2c28f1c4..8ed12bbd 100644 --- a/lua/lazyvim/plugins/colorscheme.lua +++ b/lua/lazyvim/plugins/colorscheme.lua @@ -21,7 +21,6 @@ return { illuminate = true, indent_blankline = { enabled = true }, lsp_trouble = true, - trouble = true, mason = true, mini = true, native_lsp = { From 9a6b0f8928ad2e802cae36c6b05b94cd9a73451f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 25 Oct 2023 17:52:35 +0200 Subject: [PATCH 355/362] chore(main): release 10.7.1 (#1870) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++++ lua/lazyvim/config/init.lua | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c3dc6034..a6de0da5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [10.7.1](https://github.com/LazyVim/LazyVim/compare/v10.7.0...v10.7.1) (2023-10-25) + + +### Bug Fixes + +* **catppuccin:** trouble integration. Fixes [#1872](https://github.com/LazyVim/LazyVim/issues/1872) ([f589154](https://github.com/LazyVim/LazyVim/commit/f589154268dfcb3e8f91075791a0a618c97fe59d)) +* **util:** pcall deletion of lazy_file augroup. See [#1863](https://github.com/LazyVim/LazyVim/issues/1863) ([60e5707](https://github.com/LazyVim/LazyVim/commit/60e57070131f4c544e17541610415d4d51769d62)) + ## [10.7.0](https://github.com/LazyVim/LazyVim/compare/v10.6.0...v10.7.0) (2023-10-25) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index fc5487c5..12d49ed6 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -3,7 +3,7 @@ local Util = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.7.0" -- x-release-please-version +M.version = "10.7.1" -- x-release-please-version ---@class LazyVimOptions local defaults = { From 09eafc60eff2ba7d7b78c1717d07ce26b762a8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Freitas?= Date: Wed, 25 Oct 2023 19:00:01 +0100 Subject: [PATCH 356/362] fix(mini.indentscope): remove duplicated filetype (#1871) --- lua/lazyvim/plugins/ui.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 5f8ece20..50efb153 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -266,7 +266,6 @@ return { "notify", "toggleterm", "lazyterm", - "trouble", }, callback = function() vim.b.miniindentscope_disable = true From 4558407574d0cdbe55720ab349df201bd4d5f5de Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 26 Oct 2023 07:38:53 +0200 Subject: [PATCH 357/362] fix(plugin): LazyFile now properly deals with deleted buffers. Fixes #1877 --- lua/lazyvim/util/plugin.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index fdd76f1a..7ab69134 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -76,11 +76,13 @@ function M.lazy_file() local events = {} ---@type {event: string, buf: number, data?: any}[] + local done = false local function load() - if #events == 0 then + if #events == 0 or done then return end - pcall(vim.api.nvim_del_augroup_by_name, "lazy_file") + done = true + vim.api.nvim_del_augroup_by_name("lazy_file") ---@type table local skips = {} @@ -90,17 +92,19 @@ function M.lazy_file() vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false }) for _, event in ipairs(events) do - Event.trigger({ - event = event.event, - exclude = skips[event.event], - data = event.data, - buf = event.buf, - }) - if vim.bo[event.buf].filetype then + if vim.api.nvim_buf_is_valid(event.buf) then Event.trigger({ - event = "FileType", + event = event.event, + exclude = skips[event.event], + data = event.data, buf = event.buf, }) + if vim.bo[event.buf].filetype then + Event.trigger({ + event = "FileType", + buf = event.buf, + }) + end end end vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false }) From 7831fc94ca5989baf766c0bb6ad36a70838c3d5a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Oct 2023 05:39:38 +0000 Subject: [PATCH 358/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 6982b959..181205b6 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 25 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 26 ============================================================================== Table of Contents *LazyVim-table-of-contents* From e01ad513aa4f50bdb385a7454c9e1ec3a0d5dc94 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 27 Oct 2023 18:34:33 +0200 Subject: [PATCH 359/362] fix(sessions): added folds to sessions --- lua/lazyvim/config/options.lua | 2 +- lua/lazyvim/plugins/util.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 69e8e8d3..3c9686b1 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -34,7 +34,7 @@ opt.pumblend = 10 -- Popup blend opt.pumheight = 10 -- Maximum number of entries in a popup opt.relativenumber = true -- Relative line numbers opt.scrolloff = 4 -- Lines of context -opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" } +opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" } opt.shiftround = true -- Round indent opt.shiftwidth = 2 -- Size of an indent opt.shortmess:append({ W = true, I = true, c = true, C = true }) diff --git a/lua/lazyvim/plugins/util.lua b/lua/lazyvim/plugins/util.lua index 7baa387e..c3870889 100644 --- a/lua/lazyvim/plugins/util.lua +++ b/lua/lazyvim/plugins/util.lua @@ -15,7 +15,7 @@ return { { "folke/persistence.nvim", event = "BufReadPre", - opts = { options = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" } }, + opts = { options = vim.opt.sessionoptions:get() }, -- stylua: ignore keys = { { "qs", function() require("persistence").load() end, desc = "Restore Session" }, From 4b758c40c0846d7f699819352581e452d055243e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 27 Oct 2023 16:35:14 +0000 Subject: [PATCH 360/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 181205b6..03a1f372 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 26 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 27 ============================================================================== Table of Contents *LazyVim-table-of-contents* From b32b4fd581018cf14bf30ae4cd8d94cd43552813 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sat, 28 Oct 2023 16:38:43 +0200 Subject: [PATCH 361/362] fix(extras): dont show extras that give errors (user's extras). Fixes #1895 --- lua/lazyvim/util/extras.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index 0417b81e..4e2f0bc1 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -44,7 +44,10 @@ function M.get() Util.walk(root, function(path, name, type) if type == "file" and name:match("%.lua$") then name = path:sub(#root + 2, -5):gsub("/", ".") - extras[#extras + 1] = M.get_extra(source, source.module .. "." .. name) + local ok, extra = pcall(M.get_extra, source, source.module .. "." .. name) + if ok then + extras[#extras + 1] = extra + end end end) end From e5babf289c5ccd91bcd068bfc623335eb76cbc1f Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 28 Oct 2023 14:39:26 +0000 Subject: [PATCH 362/362] chore(build): auto-generate vimdoc --- doc/LazyVim.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 03a1f372..bb2c94cd 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 27 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 28 ============================================================================== Table of Contents *LazyVim-table-of-contents*