Merge branch 'main' into dev

This commit is contained in:
chuyanlong 2025-09-17 16:29:04 +08:00
commit 6e74292c05
14 changed files with 164 additions and 261 deletions

16
NEWS.md
View file

@ -2,17 +2,21 @@
## 15.x
**Neovim** `>= 0.11.0` includes a lot of changes to the underlying LSP implementation.
**Neovim** `>= 0.11.2` includes a lot of changes to the underlying LSP implementation.
Going forward, **LazyVim** requires **Neovim** `>= 0.11.0`, and drops support for older versions.
Going forward, **LazyVim** requires **Neovim** `>= 0.11.2`, and drops support for older versions.
### Changes
- removed compatibility code for Neovim `< 0.11`
- updated all LSP code to use the new LSP implementation
- removed compatibility code for Neovim `< 0.11.2`
- configure **LSP** with the native `vim.lsp.config`
- migrated **mason.nvim** and **mason-lspconfig.nvim** to `v2.x`
- added new `treesitter-main` extra to test the new `main` branch of `nvim-treesitter`
- after enabling, you will get errors. Update with `:Lazy` and restart Neovim
- migrated to [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/tree/main) **main** branch
- with the new version, the `tree-sitter` cli is **required** to install parsers
- best to run `:checkhealth nvim_treesitter` after updating
- replace `nvim-treesitter` incremental selection with `flash.nvim`, since it is no longer supported
- enabled [blink.cmp](https://github.com/saghen/blink.cmp) **cmdline** completions
- use **LSP** based folding when available (disable with `nvim-lspconfig.folds.enabled = false`)
## 14.x

View file

@ -56,7 +56,7 @@ to tweak your config as needed, along with the convenience of a pre-configured s
## ⚡️ Requirements
- Neovim >= **0.11.0** (needs to be built with **LuaJIT**)
- Neovim >= **0.11.2** (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)

View file

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim Last change: 2025 September 16
*LazyVim.txt* For Neovim Last change: 2025 September 17
==============================================================================
Table of Contents *LazyVim-table-of-contents*
@ -53,7 +53,7 @@ FEATURES *LazyVim-features*
REQUIREMENTS *LazyVim-requirements*
- Neovim >= **0.11.0** (needs to be built with **LuaJIT**)
- Neovim >= **0.11.2** (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>

View file

@ -53,7 +53,7 @@ local opt = vim.opt
opt.autowrite = true -- Enable auto write
-- only set clipboard if not in ssh, to make sure the OSC 52
-- integration works automatically. Requires Neovim >= 0.10.0
-- integration works automatically.
opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard
opt.completeopt = "menu,menuone,noselect"
opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions
@ -68,7 +68,7 @@ opt.fillchars = {
diff = "",
eob = " ",
}
opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
opt.foldexpr = "v:lua.LazyVim.ui.foldexpr()" -- treesitter folds
opt.foldlevel = 99
opt.foldmethod = "expr"
opt.foldtext = ""
@ -78,6 +78,7 @@ opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --vimgrep"
opt.ignorecase = true -- Ignore case
opt.inccommand = "nosplit" -- preview incremental substitute
opt.indentexpr = "v:lua.LazyVim.ui.indentexpr()" -- treesitter indents
opt.jumpoptions = "view"
opt.laststatus = 3 -- global statusline
opt.linebreak = true -- Wrap lines at convenient points

View file

@ -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.11.0") == 1 then
ok("Using Neovim >= 0.11.0")
if vim.fn.has("nvim-0.11.2") == 1 then
ok("Using Neovim >= 0.11.2")
else
error("Neovim >= 0.11.0 is required")
error("Neovim >= 0.11.2 is required")
end
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit", "fzf", "curl" }) do

View file

@ -4,7 +4,7 @@ return {
{
"MagicDuck/grug-far.nvim",
opts = { headerMaxWidth = 80 },
cmd = "GrugFar",
cmd = { "GrugFar", "GrugFarWithin" },
keys = {
{
"<leader>sr",
@ -40,6 +40,16 @@ return {
{ "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
{ "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
{ "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
-- Simulate nvim-treesitter incremental selection
{ "<c-space>", mode = { "n", "o", "x" },
function()
require("flash").treesitter({
actions = {
["<c-space>"] = "next",
["<BS>"] = "prev"
}
})
end, desc = "Treesitter Incremental Selection" },
},
},
@ -144,7 +154,7 @@ return {
local gs = package.loaded.gitsigns
local function map(mode, l, r, desc)
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc })
vim.keymap.set(mode, l, r, { buffer = buffer, desc = desc, silent = true })
end
-- stylua: ignore start

View file

@ -14,12 +14,21 @@ return {
opts = { ensure_installed = { "vue", "css" } },
},
-- Configure vtsls (the TypeScript plugin host) with @vue/typescript-plugin
-- Add LSP servers
{
"neovim/nvim-lspconfig",
opts = {
servers = {
vue_ls = {},
vtsls = {},
},
},
},
-- Configure tsserver plugin
{
"neovim/nvim-lspconfig",
opts = function(_, opts)
opts.servers.vtsls = opts.servers.vtsls or {}
opts.servers.vtsls.filetypes = opts.servers.vtsls.filetypes or {}
table.insert(opts.servers.vtsls.filetypes, "vue")
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
{
@ -32,38 +41,4 @@ return {
})
end,
},
-- Hook vue_ls to forward requests to vtsls
{
"neovim/nvim-lspconfig",
opts = {
servers = {
volar = { -- when LazyVim switches to nvim-lspconfig ≥ v2.2.0 rename this to `vue_ls`
on_init = function(client)
client.handlers["tsserver/request"] = function(_, result, context)
-- find the vtsls client
local clients = vim.lsp.get_clients({ bufnr = context.bufnr, name = "vtsls" })
if #clients == 0 then
vim.notify("Could not find `vtsls` client, Vue LSP features will be disabled", vim.log.levels.ERROR)
return
end
local ts_client = clients[1]
-- unpack the forwarded request
local params = unpack(result)
local id, command, payload = unpack(params)
-- forward it
ts_client:exec_cmd({
title = "vue_request_forward",
command = "typescript.tsserverRequest",
arguments = { command, payload },
}, { bufnr = context.bufnr }, function(_, resp)
-- send the tsserver/response back to Vue LSP
client.notify("tsserver/response", { { id, resp.body } })
end)
end
end,
},
},
},
},
}

View file

@ -10,7 +10,7 @@ return {
"neovim/nvim-lspconfig",
-- other settings removed for brevity
opts = {
---@type lspconfig.options
---@type table<string, vim.lsp.Config>
servers = {
eslint = {
settings = {
@ -26,10 +26,6 @@ return {
return
end
local function get_client(buf)
return vim.lsp.get_clients({ name = "eslint", bufnr = buf })[1]
end
local formatter = LazyVim.lsp.formatter({
name = "eslint: lsp",
primary = false,
@ -37,24 +33,6 @@ return {
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(buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) })
if #diag > 0 then
vim.cmd("EslintFixAll")
end
end
end
end
-- register the formatter with LazyVim
LazyVim.format.register(formatter)
end,

View file

@ -1,90 +0,0 @@
return {
{
"nvim-treesitter/nvim-treesitter",
version = false, -- last release is way too old and doesn't work on Windows
branch = "main",
build = ":TSUpdate",
lazy = true,
cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" },
init = function() end,
---@param opts TSConfig
config = function(_, opts)
if vim.fn.executable("tree-sitter") == 0 then
LazyVim.error("**treesitter-main** requires the `tree-sitter` executable to be installed")
return
end
if type(opts.ensure_installed) ~= "table" then
error("opts.ensure_installed must be a table")
end
local TS = require("nvim-treesitter")
TS.setup(opts)
local needed = LazyVim.dedup(opts.ensure_installed --[[@as string[] ]])
local installed = TS.get_installed("parsers")
local install = vim.tbl_filter(function(lang)
return not vim.tbl_contains(installed, lang)
end, needed)
if #install > 0 then
TS.install(install, { summary = true })
vim.list_extend(installed, install)
end
-- backwards compatibility with the old treesitter config for highlight and indent
local highlight, indent = vim.tbl_get(opts, "highlight", "enable"), vim.tbl_get(opts, "indent", "enable")
if highlight or indent then
vim.api.nvim_create_autocmd("FileType", {
callback = function(ev)
local lang = vim.treesitter.language.get_lang(ev.match)
if not vim.tbl_contains(installed, lang) then
return
end
if highlight then
pcall(vim.treesitter.start)
end
if indent then
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
})
end
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
event = "VeryLazy",
opts = {},
keys = function()
local moves = {
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
}
local ret = {} ---@type LazyKeysSpec[]
for method, keymaps in pairs(moves) do
for key, query in pairs(keymaps) do
local desc = query:gsub("@", ""):gsub("%..*", "")
desc = desc:sub(1, 1):upper() .. desc:sub(2)
desc = (key:sub(1, 1) == "[" and "Prev " or "Next ") .. desc
desc = desc .. (key:sub(2, 2) == key:sub(2, 2):upper() and " End" or " Start")
ret[#ret + 1] = {
key,
function()
require("nvim-treesitter-textobjects.move")[method](query, "textobjects")
end,
desc = desc,
mode = { "n", "x", "o" },
silent = true,
}
end
end
return ret
end,
config = function(_, opts)
require("nvim-treesitter-textobjects").setup(opts)
end,
},
}

View file

@ -1,6 +1,6 @@
if vim.fn.has("nvim-0.11.0") == 0 then
if vim.fn.has("nvim-0.11.2") == 0 then
vim.api.nvim_echo({
{ "LazyVim requires Neovim >= 0.11.0\n", "ErrorMsg" },
{ "LazyVim requires Neovim >= 0.11.2\n", "ErrorMsg" },
{ "For more info, see: https://github.com/LazyVim/LazyVim/issues/6421\n", "Comment" },
{ "Press any key to exit", "MoreMsg" },
}, true, {})

View file

@ -20,7 +20,6 @@ return {
source = "if_many",
prefix = "",
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
-- prefix = "icons",
},
severity_sort = true,
@ -33,19 +32,25 @@ return {
},
},
},
-- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0
-- Enable this to enable the builtin LSP inlay hints on Neovim.
-- Be aware that you also will need to properly configure your LSP server to
-- provide the inlay hints.
inlay_hints = {
enabled = true,
exclude = { "vue" }, -- filetypes for which you don't want to enable inlay hints
},
-- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0
-- Enable this to enable the builtin LSP code lenses on Neovim.
-- Be aware that you also will need to properly configure your LSP server to
-- provide the code lenses.
codelens = {
enabled = false,
},
-- Enable this to enable the builtin LSP folding on Neovim.
-- Be aware that you also will need to properly configure your LSP server to
-- provide the folds.
folds = {
enabled = true,
},
-- add any global capabilities here
capabilities = {
workspace = {
@ -138,6 +143,14 @@ return {
end)
end
-- folds
if opts.folds.enabled then
LazyVim.lsp.on_supports_method("textDocument/foldingRange", function(client, buffer)
local win = vim.api.nvim_get_current_win()
vim.wo[win][0].foldexpr = "v:lua.vim.lsp.foldexpr()"
end)
end
-- code lens
if opts.codelens.enabled and vim.lsp.codelens then
LazyVim.lsp.on_supports_method("textDocument/codeLens", function(client, buffer)

View file

@ -1,43 +1,25 @@
return {
{
"folke/which-key.nvim",
opts = {
spec = {
{ "<BS>", desc = "Decrement Selection", mode = "x" },
{ "<c-space>", desc = "Increment Selection", mode = { "x", "n" } },
},
},
},
-- Treesitter is a new parser generator tool that we can
-- use in Neovim to power faster and more accurate
-- syntax highlighting.
{
"nvim-treesitter/nvim-treesitter",
branch = "main",
version = false, -- last release is way too old and doesn't work on Windows
build = ":TSUpdate",
event = { "LazyFile", "VeryLazy" },
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
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-treesitter** module to be loaded in time.
-- Luckily, the only things 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")
build = function()
local TS = require("nvim-treesitter")
if not TS.get_installed then
LazyVim.error("Please restart Neovim and run `:TSUpdate` to use the `nvim-treesitter` **main** branch.")
return
end
vim.cmd.TSUpdate()
end,
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
keys = {
{ "<c-space>", desc = "Increment Selection" },
{ "<bs>", desc = "Decrement Selection", mode = "x" },
},
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
event = { "LazyFile", "VeryLazy" },
cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" },
opts_extend = { "ensure_installed" },
---@type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = {
highlight = { enable = true },
indent = { enable = true },
ensure_installed = {
"bash",
"c",
@ -64,65 +46,94 @@ return {
"xml",
"yaml",
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-space>",
node_incremental = "<C-space>",
scope_incremental = false,
node_decremental = "<bs>",
},
},
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
},
},
},
---@param plugin LazyPlugin
---@param opts TSConfig
config = function(_, opts)
if type(opts.ensure_installed) == "table" then
opts.ensure_installed = LazyVim.dedup(opts.ensure_installed)
config = function(plugin, opts)
if vim.fn.executable("tree-sitter") == 0 then
LazyVim.error({
"**treesitter-main** requires the `tree-sitter` CLI executable to be installed.",
"Run `:checkhealth nvim_treesitter` for more information.",
})
return
end
require("nvim-treesitter.configs").setup(opts)
if type(opts.ensure_installed) ~= "table" then
LazyVim.error("`nvim-treesitter` opts.ensure_installed must be a table")
end
local TS = require("nvim-treesitter")
if not TS.get_installed then
LazyVim.error("Please use `:Lazy` and update `nvim-treesitter`")
return
end
TS.setup(opts)
local needed = LazyVim.dedup(opts.ensure_installed --[[@as string[] ]])
LazyVim.ui.installed = TS.get_installed("parsers")
local install = vim.tbl_filter(function(lang)
return not LazyVim.ui.have(lang)
end, needed)
if #install > 0 then
TS.install(install, { summary = true }):await(function()
LazyVim.ui.installed = TS.get_installed("parsers")
end)
end
vim.api.nvim_create_autocmd("FileType", {
callback = function(ev)
if LazyVim.ui.have(ev.match) then
pcall(vim.treesitter.start)
end
end,
})
end,
},
{
"nvim-treesitter/nvim-treesitter-textobjects",
branch = "main",
event = "VeryLazy",
enabled = true,
config = function()
-- If treesitter is already loaded, we need to run config again for textobjects
if LazyVim.is_loaded("nvim-treesitter") then
local opts = LazyVim.opts("nvim-treesitter")
require("nvim-treesitter.configs").setup({ textobjects = opts.textobjects })
end
-- 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<string,fun(...)>
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<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
opts = {},
keys = function()
local moves = {
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
}
local ret = {} ---@type LazyKeysSpec[]
for method, keymaps in pairs(moves) do
for key, query in pairs(keymaps) do
local desc = query:gsub("@", ""):gsub("%..*", "")
desc = desc:sub(1, 1):upper() .. desc:sub(2)
desc = (key:sub(1, 1) == "[" and "Prev " or "Next ") .. desc
desc = desc .. (key:sub(2, 2) == key:sub(2, 2):upper() and " End" or " Start")
ret[#ret + 1] = {
key,
function()
-- don't use treesitter if in diff mode and the key is one of the c/C keys
if vim.wo.diff and key:find("[cC]") then
return vim.cmd("normal! " .. key)
end
end
return fn(q, ...)
end
require("nvim-treesitter-textobjects.move")[method](query, "textobjects")
end,
desc = desc,
mode = { "n", "x", "o" },
silent = true,
}
end
end
return ret
end,
config = function(_, opts)
local TS = require("nvim-treesitter-textobjects")
if not TS.setup then
LazyVim.error("Please use `:Lazy` and update `nvim-treesitter`")
return
end
TS.setup(opts)
end,
},

View file

@ -17,6 +17,7 @@ M.deprecated_extras = {
["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.",
["lazyvim.plugins.extras.coding.native_snippets"] = "Native snippets are now the default for **Neovim >= 0.10**",
["lazyvim.plugins.extras.ui.treesitter-rewrite"] = "Disabled `treesitter-rewrite` extra for now. Not ready yet.",
["lazyvim.plugins.extras.ui.treesitter-main"] = "the `nvim-treesitter` main branch is now used by default",
["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)",
["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature",
["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main",

View file

@ -1,22 +1,22 @@
---@class lazyvim.util.ui
local M = {}
-- optimized treesitter foldexpr for Neovim >= 0.10.0
M.installed = {} ---@type string[]
---@param ft string
function M.have(ft)
local lang = vim.treesitter.language.get_lang(ft)
return vim.tbl_contains(M.installed, lang)
end
function M.foldexpr()
local buf = vim.api.nvim_get_current_buf()
if vim.b[buf].ts_folds == nil then
-- 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
if vim.bo[buf].filetype:find("dashboard") then
vim.b[buf].ts_folds = false
else
vim.b[buf].ts_folds = pcall(vim.treesitter.get_parser, buf)
end
end
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or "0"
return M.have(vim.b[buf].filetype) and vim.treesitter.foldexpr() or "0"
end
function M.indentexpr()
local buf = vim.api.nvim_get_current_buf()
return M.have(vim.b[buf].filetype) and require("nvim-treesitter").indentexpr() or -1
end
return M