mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
6e74292c05
14 changed files with 164 additions and 261 deletions
16
NEWS.md
16
NEWS.md
|
|
@ -2,17 +2,21 @@
|
||||||
|
|
||||||
## 15.x
|
## 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
|
### Changes
|
||||||
|
|
||||||
- removed compatibility code for Neovim `< 0.11`
|
- removed compatibility code for Neovim `< 0.11.2`
|
||||||
- updated all LSP code to use the new LSP implementation
|
- configure **LSP** with the native `vim.lsp.config`
|
||||||
- migrated **mason.nvim** and **mason-lspconfig.nvim** to `v2.x`
|
- migrated **mason.nvim** and **mason-lspconfig.nvim** to `v2.x`
|
||||||
- added new `treesitter-main` extra to test the new `main` branch of `nvim-treesitter`
|
- migrated to [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter/tree/main) **main** branch
|
||||||
- after enabling, you will get errors. Update with `:Lazy` and restart Neovim
|
- 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
|
## 14.x
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ to tweak your config as needed, along with the convenience of a pre-configured s
|
||||||
|
|
||||||
## ⚡️ Requirements
|
## ⚡️ 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)
|
- Git >= **2.19.0** (for partial clones support)
|
||||||
- a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_**
|
- a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_**
|
||||||
- a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements)
|
- a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements)
|
||||||
|
|
|
||||||
|
|
@ -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*
|
Table of Contents *LazyVim-table-of-contents*
|
||||||
|
|
@ -53,7 +53,7 @@ FEATURES *LazyVim-features*
|
||||||
|
|
||||||
REQUIREMENTS *LazyVim-requirements*
|
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)
|
- Git >= **2.19.0** (for partial clones support)
|
||||||
- a Nerd Font <https://www.nerdfonts.com/> **(optional)**
|
- a Nerd Font <https://www.nerdfonts.com/> **(optional)**
|
||||||
- a **C** compiler for `nvim-treesitter`. See here <https://github.com/nvim-treesitter/nvim-treesitter#requirements>
|
- a **C** compiler for `nvim-treesitter`. See here <https://github.com/nvim-treesitter/nvim-treesitter#requirements>
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ local opt = vim.opt
|
||||||
|
|
||||||
opt.autowrite = true -- Enable auto write
|
opt.autowrite = true -- Enable auto write
|
||||||
-- only set clipboard if not in ssh, to make sure the OSC 52
|
-- 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.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard
|
||||||
opt.completeopt = "menu,menuone,noselect"
|
opt.completeopt = "menu,menuone,noselect"
|
||||||
opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions
|
opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions
|
||||||
|
|
@ -68,7 +68,7 @@ opt.fillchars = {
|
||||||
diff = "╱",
|
diff = "╱",
|
||||||
eob = " ",
|
eob = " ",
|
||||||
}
|
}
|
||||||
opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
|
opt.foldexpr = "v:lua.LazyVim.ui.foldexpr()" -- treesitter folds
|
||||||
opt.foldlevel = 99
|
opt.foldlevel = 99
|
||||||
opt.foldmethod = "expr"
|
opt.foldmethod = "expr"
|
||||||
opt.foldtext = ""
|
opt.foldtext = ""
|
||||||
|
|
@ -78,6 +78,7 @@ opt.grepformat = "%f:%l:%c:%m"
|
||||||
opt.grepprg = "rg --vimgrep"
|
opt.grepprg = "rg --vimgrep"
|
||||||
opt.ignorecase = true -- Ignore case
|
opt.ignorecase = true -- Ignore case
|
||||||
opt.inccommand = "nosplit" -- preview incremental substitute
|
opt.inccommand = "nosplit" -- preview incremental substitute
|
||||||
|
opt.indentexpr = "v:lua.LazyVim.ui.indentexpr()" -- treesitter indents
|
||||||
opt.jumpoptions = "view"
|
opt.jumpoptions = "view"
|
||||||
opt.laststatus = 3 -- global statusline
|
opt.laststatus = 3 -- global statusline
|
||||||
opt.linebreak = true -- Wrap lines at convenient points
|
opt.linebreak = true -- Wrap lines at convenient points
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,10 @@ local error = vim.health.error or vim.health.report_error
|
||||||
function M.check()
|
function M.check()
|
||||||
start("LazyVim")
|
start("LazyVim")
|
||||||
|
|
||||||
if vim.fn.has("nvim-0.11.0") == 1 then
|
if vim.fn.has("nvim-0.11.2") == 1 then
|
||||||
ok("Using Neovim >= 0.11.0")
|
ok("Using Neovim >= 0.11.2")
|
||||||
else
|
else
|
||||||
error("Neovim >= 0.11.0 is required")
|
error("Neovim >= 0.11.2 is required")
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit", "fzf", "curl" }) do
|
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit", "fzf", "curl" }) do
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ return {
|
||||||
{
|
{
|
||||||
"MagicDuck/grug-far.nvim",
|
"MagicDuck/grug-far.nvim",
|
||||||
opts = { headerMaxWidth = 80 },
|
opts = { headerMaxWidth = 80 },
|
||||||
cmd = "GrugFar",
|
cmd = { "GrugFar", "GrugFarWithin" },
|
||||||
keys = {
|
keys = {
|
||||||
{
|
{
|
||||||
"<leader>sr",
|
"<leader>sr",
|
||||||
|
|
@ -40,6 +40,16 @@ return {
|
||||||
{ "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
|
{ "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" },
|
||||||
{ "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" },
|
{ "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" },
|
{ "<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 gs = package.loaded.gitsigns
|
||||||
|
|
||||||
local function map(mode, l, r, desc)
|
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
|
end
|
||||||
|
|
||||||
-- stylua: ignore start
|
-- stylua: ignore start
|
||||||
|
|
|
||||||
|
|
@ -14,12 +14,21 @@ return {
|
||||||
opts = { ensure_installed = { "vue", "css" } },
|
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",
|
"neovim/nvim-lspconfig",
|
||||||
opts = function(_, opts)
|
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")
|
table.insert(opts.servers.vtsls.filetypes, "vue")
|
||||||
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
||||||
{
|
{
|
||||||
|
|
@ -32,38 +41,4 @@ return {
|
||||||
})
|
})
|
||||||
end,
|
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,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
-- other settings removed for brevity
|
-- other settings removed for brevity
|
||||||
opts = {
|
opts = {
|
||||||
---@type lspconfig.options
|
---@type table<string, vim.lsp.Config>
|
||||||
servers = {
|
servers = {
|
||||||
eslint = {
|
eslint = {
|
||||||
settings = {
|
settings = {
|
||||||
|
|
@ -26,10 +26,6 @@ return {
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_client(buf)
|
|
||||||
return vim.lsp.get_clients({ name = "eslint", bufnr = buf })[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
local formatter = LazyVim.lsp.formatter({
|
local formatter = LazyVim.lsp.formatter({
|
||||||
name = "eslint: lsp",
|
name = "eslint: lsp",
|
||||||
primary = false,
|
primary = false,
|
||||||
|
|
@ -37,24 +33,6 @@ return {
|
||||||
filter = "eslint",
|
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
|
-- register the formatter with LazyVim
|
||||||
LazyVim.format.register(formatter)
|
LazyVim.format.register(formatter)
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -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({
|
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" },
|
{ "For more info, see: https://github.com/LazyVim/LazyVim/issues/6421\n", "Comment" },
|
||||||
{ "Press any key to exit", "MoreMsg" },
|
{ "Press any key to exit", "MoreMsg" },
|
||||||
}, true, {})
|
}, true, {})
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ return {
|
||||||
source = "if_many",
|
source = "if_many",
|
||||||
prefix = "●",
|
prefix = "●",
|
||||||
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
-- 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",
|
-- prefix = "icons",
|
||||||
},
|
},
|
||||||
severity_sort = true,
|
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
|
-- Be aware that you also will need to properly configure your LSP server to
|
||||||
-- provide the inlay hints.
|
-- provide the inlay hints.
|
||||||
inlay_hints = {
|
inlay_hints = {
|
||||||
enabled = true,
|
enabled = true,
|
||||||
exclude = { "vue" }, -- filetypes for which you don't want to enable inlay hints
|
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
|
-- Be aware that you also will need to properly configure your LSP server to
|
||||||
-- provide the code lenses.
|
-- provide the code lenses.
|
||||||
codelens = {
|
codelens = {
|
||||||
enabled = false,
|
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
|
-- add any global capabilities here
|
||||||
capabilities = {
|
capabilities = {
|
||||||
workspace = {
|
workspace = {
|
||||||
|
|
@ -138,6 +143,14 @@ return {
|
||||||
end)
|
end)
|
||||||
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
|
-- code lens
|
||||||
if opts.codelens.enabled and vim.lsp.codelens then
|
if opts.codelens.enabled and vim.lsp.codelens then
|
||||||
LazyVim.lsp.on_supports_method("textDocument/codeLens", function(client, buffer)
|
LazyVim.lsp.on_supports_method("textDocument/codeLens", function(client, buffer)
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,25 @@
|
||||||
return {
|
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
|
-- Treesitter is a new parser generator tool that we can
|
||||||
-- use in Neovim to power faster and more accurate
|
-- use in Neovim to power faster and more accurate
|
||||||
-- syntax highlighting.
|
-- syntax highlighting.
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
branch = "main",
|
||||||
version = false, -- last release is way too old and doesn't work on Windows
|
version = false, -- last release is way too old and doesn't work on Windows
|
||||||
build = ":TSUpdate",
|
build = function()
|
||||||
event = { "LazyFile", "VeryLazy" },
|
local TS = require("nvim-treesitter")
|
||||||
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
|
if not TS.get_installed then
|
||||||
init = function(plugin)
|
LazyVim.error("Please restart Neovim and run `:TSUpdate` to use the `nvim-treesitter` **main** branch.")
|
||||||
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
|
return
|
||||||
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
|
end
|
||||||
-- no longer trigger the **nvim-treesitter** module to be loaded in time.
|
vim.cmd.TSUpdate()
|
||||||
-- 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")
|
|
||||||
end,
|
end,
|
||||||
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
|
lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
|
||||||
keys = {
|
event = { "LazyFile", "VeryLazy" },
|
||||||
{ "<c-space>", desc = "Increment Selection" },
|
cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" },
|
||||||
{ "<bs>", desc = "Decrement Selection", mode = "x" },
|
|
||||||
},
|
|
||||||
opts_extend = { "ensure_installed" },
|
opts_extend = { "ensure_installed" },
|
||||||
---@type TSConfig
|
|
||||||
---@diagnostic disable-next-line: missing-fields
|
|
||||||
opts = {
|
opts = {
|
||||||
highlight = { enable = true },
|
|
||||||
indent = { enable = true },
|
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
"bash",
|
"bash",
|
||||||
"c",
|
"c",
|
||||||
|
|
@ -64,65 +46,94 @@ return {
|
||||||
"xml",
|
"xml",
|
||||||
"yaml",
|
"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
|
---@param opts TSConfig
|
||||||
config = function(_, opts)
|
config = function(plugin, opts)
|
||||||
if type(opts.ensure_installed) == "table" then
|
if vim.fn.executable("tree-sitter") == 0 then
|
||||||
opts.ensure_installed = LazyVim.dedup(opts.ensure_installed)
|
LazyVim.error({
|
||||||
|
"**treesitter-main** requires the `tree-sitter` CLI executable to be installed.",
|
||||||
|
"Run `:checkhealth nvim_treesitter` for more information.",
|
||||||
|
})
|
||||||
|
return
|
||||||
end
|
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,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
|
branch = "main",
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
enabled = true,
|
opts = {},
|
||||||
config = function()
|
keys = function()
|
||||||
-- If treesitter is already loaded, we need to run config again for textobjects
|
local moves = {
|
||||||
if LazyVim.is_loaded("nvim-treesitter") then
|
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
|
||||||
local opts = LazyVim.opts("nvim-treesitter")
|
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
|
||||||
require("nvim-treesitter.configs").setup({ textobjects = opts.textobjects })
|
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer", ["[a"] = "@parameter.inner" },
|
||||||
end
|
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
|
||||||
|
}
|
||||||
-- When in diff mode, we want to use the default
|
local ret = {} ---@type LazyKeysSpec[]
|
||||||
-- vim text objects c & C instead of the treesitter ones.
|
for method, keymaps in pairs(moves) do
|
||||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
for key, query in pairs(keymaps) do
|
||||||
local configs = require("nvim-treesitter.configs")
|
local desc = query:gsub("@", ""):gsub("%..*", "")
|
||||||
for name, fn in pairs(move) do
|
desc = desc:sub(1, 1):upper() .. desc:sub(2)
|
||||||
if name:find("goto") == 1 then
|
desc = (key:sub(1, 1) == "[" and "Prev " or "Next ") .. desc
|
||||||
move[name] = function(q, ...)
|
desc = desc .. (key:sub(2, 2) == key:sub(2, 2):upper() and " End" or " Start")
|
||||||
if vim.wo.diff then
|
ret[#ret + 1] = {
|
||||||
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
key,
|
||||||
for key, query in pairs(config or {}) do
|
function()
|
||||||
if q == query and key:find("[%]%[][cC]") then
|
-- don't use treesitter if in diff mode and the key is one of the c/C keys
|
||||||
vim.cmd("normal! " .. key)
|
if vim.wo.diff and key:find("[cC]") then
|
||||||
return
|
return vim.cmd("normal! " .. key)
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
require("nvim-treesitter-textobjects.move")[method](query, "textobjects")
|
||||||
return fn(q, ...)
|
end,
|
||||||
end
|
desc = desc,
|
||||||
|
mode = { "n", "x", "o" },
|
||||||
|
silent = true,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
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,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ M.deprecated_extras = {
|
||||||
["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.",
|
["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.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-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.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.lazyrc"] = "local spec files are now a lazy.nvim feature",
|
||||||
["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main",
|
["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main",
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
---@class lazyvim.util.ui
|
---@class lazyvim.util.ui
|
||||||
local M = {}
|
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()
|
function M.foldexpr()
|
||||||
local buf = vim.api.nvim_get_current_buf()
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
if vim.b[buf].ts_folds == nil then
|
return M.have(vim.b[buf].filetype) and vim.treesitter.foldexpr() or "0"
|
||||||
-- as long as we don't have a filetype, don't bother
|
end
|
||||||
-- checking if treesitter is available (it won't)
|
|
||||||
if vim.bo[buf].filetype == "" then
|
function M.indentexpr()
|
||||||
return "0"
|
local buf = vim.api.nvim_get_current_buf()
|
||||||
end
|
return M.have(vim.b[buf].filetype) and require("nvim-treesitter").indentexpr() or -1
|
||||||
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"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue