(YankyPutIndentAfterShiftRight)", desc = "Put and Indent Right" },
- { "(YankyPutIndentAfterShiftLeft)", desc = "Put and Indent Left" },
- { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put Before and Indent Right" },
- { "(YankyPutIndentBeforeShiftLeft)", desc = "Put Before and Indent Left" },
- { "=p", "(YankyPutAfterFilter)", desc = "Put After Applying a Filter" },
- { "=P", "(YankyPutBeforeFilter)", desc = "Put Before Applying a Filter" },
- },
+ { "y", "(YankyYank)", mode = { "n", "x" }, desc = "Yank Text" },
+ { "p", "(YankyPutAfter)", mode = { "n", "x" }, desc = "Put Yanked Text After Cursor" },
+ { "P", "(YankyPutBefore)", mode = { "n", "x" }, desc = "Put Yanked Text Before Cursor" },
+ { "gp", "(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put Yanked Text After Selection" },
+ { "gP", "(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put Yanked Text Before Selection" },
+ { "[y", "(YankyCycleForward)", desc = "Cycle Forward Through Yank History" },
+ { "]y", "(YankyCycleBackward)", desc = "Cycle Backward Through Yank History" },
+ { "]p", "(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
+ { "[p", "(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
+ { "]P", "(YankyPutIndentAfterLinewise)", desc = "Put Indented After Cursor (Linewise)" },
+ { "[P", "(YankyPutIndentBeforeLinewise)", desc = "Put Indented Before Cursor (Linewise)" },
+ { ">p", "(YankyPutIndentAfterShiftRight)", desc = "Put and Indent Right" },
+ { "(YankyPutIndentAfterShiftLeft)", desc = "Put and Indent Left" },
+ { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put Before and Indent Right" },
+ { "(YankyPutIndentBeforeShiftLeft)", desc = "Put Before and Indent Left" },
+ { "=p", "(YankyPutAfterFilter)", desc = "Put After Applying a Filter" },
+ { "=P", "(YankyPutBeforeFilter)", desc = "Put Before Applying a Filter" },
},
}
diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua
index 7e370629..77864460 100644
--- a/lua/lazyvim/plugins/extras/dap/core.lua
+++ b/lua/lazyvim/plugins/extras/dap/core.lua
@@ -12,6 +12,8 @@ end
return {
"mfussenegger/nvim-dap",
+ recommended = true,
+ desc = "Debugging support. Requires language specific adapters to be configured. (see lang extras)",
dependencies = {
@@ -26,8 +28,6 @@ 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)
@@ -81,6 +81,11 @@ return {
},
},
},
+
+ -- VsCode launch.json parser
+ {
+ "folke/neoconf.nvim",
+ },
},
-- stylua: ignore
@@ -115,5 +120,18 @@ return {
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
)
end
+
+ -- setup dap config by VsCode launch.json file
+ local vscode = require("dap.ext.vscode")
+ local _filetypes = require("mason-nvim-dap.mappings.filetypes")
+ local filetypes = vim.tbl_deep_extend("force", _filetypes, {
+ ["node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" },
+ ["pwa-node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" },
+ })
+ local json = require("plenary.json")
+ vscode.json_decode = function(str)
+ return vim.json.decode(json.json_strip_comments(str))
+ end
+ vscode.load_launchjs(nil, filetypes)
end,
}
diff --git a/lua/lazyvim/plugins/extras/editor/dial.lua b/lua/lazyvim/plugins/extras/editor/dial.lua
index 20ebd7ff..cc262a33 100644
--- a/lua/lazyvim/plugins/extras/editor/dial.lua
+++ b/lua/lazyvim/plugins/extras/editor/dial.lua
@@ -5,7 +5,9 @@ M.dials_by_ft = {}
---@param increment boolean
---@param g? boolean
function M.dial(increment, g)
- local is_visual = vim.fn.mode(true):sub(1, 1) == "v"
+ local mode = vim.fn.mode(true)
+ -- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22'
+ local is_visual = mode == "v" or mode == "V" or mode == "\22"
local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal")
local group = M.dials_by_ft[vim.bo.filetype] or "default"
return require("dial.map")[func](group)
@@ -13,6 +15,8 @@ end
return {
"monaqa/dial.nvim",
+ recommended = true,
+ desc = "Increment and decrement numbers, dates, and more",
-- stylua: ignore
keys = {
{ "", function() return M.dial(true) end, expr = true, desc = "Increment", mode = {"n", "v"} },
diff --git a/lua/lazyvim/plugins/extras/editor/illuminate.lua b/lua/lazyvim/plugins/extras/editor/illuminate.lua
new file mode 100644
index 00000000..6fef79b4
--- /dev/null
+++ b/lua/lazyvim/plugins/extras/editor/illuminate.lua
@@ -0,0 +1,45 @@
+-- Automatically highlights other instances of the word under your cursor.
+-- This works with LSP, Treesitter, and regexp matching to find the other
+-- instances.
+return {
+ {
+ "RRethy/vim-illuminate",
+ event = "LazyFile",
+ opts = {
+ delay = 200,
+ large_file_cutoff = 2000,
+ large_file_overrides = {
+ providers = { "lsp" },
+ },
+ },
+ config = function(_, opts)
+ require("illuminate").configure(opts)
+
+ local function map(key, dir, buffer)
+ vim.keymap.set("n", key, function()
+ require("illuminate")["goto_" .. dir .. "_reference"](false)
+ end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer })
+ end
+
+ map("]]", "next")
+ map("[[", "prev")
+
+ -- also set it after loading ftplugins, since a lot overwrite [[ and ]]
+ vim.api.nvim_create_autocmd("FileType", {
+ callback = function()
+ local buffer = vim.api.nvim_get_current_buf()
+ map("]]", "next", buffer)
+ map("[[", "prev", buffer)
+ end,
+ })
+ end,
+ keys = {
+ { "]]", desc = "Next Reference" },
+ { "[[", desc = "Prev Reference" },
+ },
+ },
+ {
+ "neovim/nvim-lspconfig",
+ opts = { document_highlight = { enabed = false } },
+ },
+}
diff --git a/lua/lazyvim/plugins/extras/editor/leap.lua b/lua/lazyvim/plugins/extras/editor/leap.lua
index 19bfd4a8..6145d641 100644
--- a/lua/lazyvim/plugins/extras/editor/leap.lua
+++ b/lua/lazyvim/plugins/extras/editor/leap.lua
@@ -38,6 +38,7 @@ return {
-- rename surround mappings from gs to gz to prevent conflict with leap
{
"echasnovski/mini.surround",
+ optional = true,
opts = {
mappings = {
add = "gza", -- Add surrounding in Normal and Visual modes
@@ -50,6 +51,15 @@ return {
},
},
},
+ {
+ "folke/which-key.nvim",
+ optional = true,
+ opts = {
+ defaults = {
+ ["gz"] = { name = "+surround" },
+ },
+ },
+ },
-- makes some plugins dot-repeatable like leap
{ "tpope/vim-repeat", event = "VeryLazy" },
diff --git a/lua/lazyvim/plugins/extras/editor/refactoring.lua b/lua/lazyvim/plugins/extras/editor/refactoring.lua
index e5852a3c..cf6988a9 100644
--- a/lua/lazyvim/plugins/extras/editor/refactoring.lua
+++ b/lua/lazyvim/plugins/extras/editor/refactoring.lua
@@ -122,4 +122,15 @@ return {
end
end,
},
+
+ -- which key integration
+ {
+ "folke/which-key.nvim",
+ optional = true,
+ opts = {
+ defaults = {
+ ["r"] = { name = "+refactor" },
+ },
+ },
+ },
}
diff --git a/lua/lazyvim/plugins/extras/editor/trouble-v3.lua b/lua/lazyvim/plugins/extras/editor/trouble-v3.lua
index 41a773d1..9b6b8528 100644
--- a/lua/lazyvim/plugins/extras/editor/trouble-v3.lua
+++ b/lua/lazyvim/plugins/extras/editor/trouble-v3.lua
@@ -12,9 +12,18 @@ if vim.tbl_contains(Config.json.data.extras, "lazyvim.plugins.extras.editor.trou
})
end
end
+ if vim.fn.has("nvim-0.9.2") == 0 then
+ LazyVim.error({
+ "Trouble v3 requires Neovim >= 0.9.2",
+ "Please update your Neovim version.",
+ })
+ return {}
+ end
end
return {
+ desc = "Trouble rewrite including document symbols and a lualine component",
+ recommended = true,
{
"folke/trouble.nvim",
branch = "dev",
diff --git a/lua/lazyvim/plugins/extras/lang/ansible.lua b/lua/lazyvim/plugins/extras/lang/ansible.lua
index d1112115..5f080395 100644
--- a/lua/lazyvim/plugins/extras/lang/ansible.lua
+++ b/lua/lazyvim/plugins/extras/lang/ansible.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "yaml.ansible",
+ root = { "ansible.cfg", ".ansible-lint" },
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua
index 7705360d..44e2f64c 100644
--- a/lua/lazyvim/plugins/extras/lang/clangd.lua
+++ b/lua/lazyvim/plugins/extras/lang/clangd.lua
@@ -1,4 +1,17 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" },
+ root = {
+ ".clangd",
+ ".clang-tidy",
+ ".clang-format",
+ "compile_commands.json",
+ "compile_flags.txt",
+ "configure.ac", -- AutoTools
+ },
+ })
+ end,
-- Add C/C++ to treesitter
{
@@ -144,7 +157,7 @@ return {
type = "codelldb",
request = "attach",
name = "Attach to process",
- processId = require("dap.utils").pick_process,
+ pid = require("dap.utils").pick_process,
cwd = "${workspaceFolder}",
},
}
diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua
index 401669a3..a5bc804c 100644
--- a/lua/lazyvim/plugins/extras/lang/cmake.lua
+++ b/lua/lazyvim/plugins/extras/lang/cmake.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "cmake",
+ root = { "CMakePresets.json", "CTestConfig.cmake", "cmake" },
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua
index da9605ec..98a9be44 100644
--- a/lua/lazyvim/plugins/extras/lang/docker.lua
+++ b/lua/lazyvim/plugins/extras/lang/docker.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "dockerfile",
+ root = { "Dockerfile", "docker-compose.yml", "compose.yml", "docker-compose.yaml", "compose.yaml" },
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua
index f60dc18e..a6b9c260 100644
--- a/lua/lazyvim/plugins/extras/lang/elixir.lua
+++ b/lua/lazyvim/plugins/extras/lang/elixir.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "elixir", "eelixir", "heex", "surface" },
+ root = "mix.exs",
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua
index 036eab6f..2ec43e22 100644
--- a/lua/lazyvim/plugins/extras/lang/go.lua
+++ b/lua/lazyvim/plugins/extras/lang/go.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "go", "gomod", "gowork", "gotmpl" },
+ root = { "go.work", "go.mod" },
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua
index 75b0805b..2d99a6cd 100644
--- a/lua/lazyvim/plugins/extras/lang/java.lua
+++ b/lua/lazyvim/plugins/extras/lang/java.lua
@@ -16,6 +16,20 @@ local function extend_or_override(config, custom, ...)
end
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "java",
+ root = {
+ "build.gradle",
+ "build.gradle.kts",
+ "build.xml", -- Ant
+ "pom.xml", -- Maven
+ "settings.gradle", -- Gradle
+ "settings.gradle.kts", -- Gradle
+ },
+ })
+ end,
+
-- Add java to treesitter.
{
"nvim-treesitter/nvim-treesitter",
diff --git a/lua/lazyvim/plugins/extras/lang/json.lua b/lua/lazyvim/plugins/extras/lang/json.lua
index ff41ba4f..5f94caf7 100644
--- a/lua/lazyvim/plugins/extras/lang/json.lua
+++ b/lua/lazyvim/plugins/extras/lang/json.lua
@@ -1,4 +1,9 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "json", "jsonc", "json5" },
+ })
+ end,
-- add json to treesitter
{
diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua
index e56e6de2..e290f174 100644
--- a/lua/lazyvim/plugins/extras/lang/markdown.lua
+++ b/lua/lazyvim/plugins/extras/lang/markdown.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "markdown",
+ root = "README.md",
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua
index d4bd698b..74fd2bd2 100644
--- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua
+++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua
@@ -1,4 +1,11 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "cs", "vb" },
+ root = { "*.sln", "*.csproj", "omnisharp.json", "function.json" },
+ })
+ end,
+
{ "Hoffs/omnisharp-extended-lsp.nvim", lazy = true },
{
"nvim-treesitter/nvim-treesitter",
@@ -96,4 +103,18 @@ return {
end
end,
},
+ {
+ "nvim-neotest/neotest",
+ optional = true,
+ dependencies = {
+ "Issafalcon/neotest-dotnet",
+ },
+ opts = {
+ adapters = {
+ ["neotest-dotnet"] = {
+ -- Here we can set options for neotest-dotnet
+ },
+ },
+ },
+ },
}
diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua
index 3e7f5d59..f1e70548 100644
--- a/lua/lazyvim/plugins/extras/lang/python.lua
+++ b/lua/lazyvim/plugins/extras/lang/python.lua
@@ -9,6 +9,19 @@ local lsp = vim.g.lazyvim_python_lsp or "pyright"
local ruff = vim.g.lazyvim_python_ruff or "ruff_lsp"
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "python",
+ root = {
+ "pyproject.toml",
+ "setup.py",
+ "setup.cfg",
+ "requirements.txt",
+ "Pipfile",
+ "pyrightconfig.json",
+ },
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/ruby.lua b/lua/lazyvim/plugins/extras/lang/ruby.lua
index a7894692..40ff8005 100644
--- a/lua/lazyvim/plugins/extras/lang/ruby.lua
+++ b/lua/lazyvim/plugins/extras/lang/ruby.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "ruby",
+ root = "Gemfile",
+ })
+ end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua
index 6fe9e88e..98a166f5 100644
--- a/lua/lazyvim/plugins/extras/lang/rust.lua
+++ b/lua/lazyvim/plugins/extras/lang/rust.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "rust",
+ root = { "Cargo.toml", "rust-project.json" },
+ })
+ end,
-- Extend auto completion
{
diff --git a/lua/lazyvim/plugins/extras/lang/scala.lua b/lua/lazyvim/plugins/extras/lang/scala.lua
index eca2db45..47c87b87 100644
--- a/lua/lazyvim/plugins/extras/lang/scala.lua
+++ b/lua/lazyvim/plugins/extras/lang/scala.lua
@@ -3,6 +3,12 @@
-- If you like you can setup your own key bindings.
-- For minimalistic setup have a look at https://github.com/scalameta/nvim-metals/discussions/39
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "scala",
+ root = { "build.sbt", "build.sc", "build.gradle", "pom.xml" },
+ })
+ end,
{
"hrsh7th/nvim-cmp",
requires = {
diff --git a/lua/lazyvim/plugins/extras/lang/tailwind.lua b/lua/lazyvim/plugins/extras/lang/tailwind.lua
index 795449ee..17ed92ef 100644
--- a/lua/lazyvim/plugins/extras/lang/tailwind.lua
+++ b/lua/lazyvim/plugins/extras/lang/tailwind.lua
@@ -1,4 +1,18 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ root = {
+ "tailwind.config.js",
+ "tailwind.config.cjs",
+ "tailwind.config.mjs",
+ "tailwind.config.ts",
+ "postcss.config.js",
+ "postcss.config.cjs",
+ "postcss.config.mjs",
+ "postcss.config.ts",
+ },
+ })
+ end,
{
"neovim/nvim-lspconfig",
opts = {
diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua
index b199b4f1..e75a0eca 100644
--- a/lua/lazyvim/plugins/extras/lang/terraform.lua
+++ b/lua/lazyvim/plugins/extras/lang/terraform.lua
@@ -1,4 +1,11 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "terraform", "hcl" },
+ root = ".terraform",
+ })
+ end,
+
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
@@ -18,6 +25,14 @@ return {
},
},
},
+ -- ensure terraform tools are installed
+ {
+ "williamboman/mason.nvim",
+ opts = function(_, opts)
+ opts.ensure_installed = opts.ensure_installed or {}
+ vim.list_extend(opts.ensure_installed, { "tflint" })
+ end,
+ },
{
"nvimtools/none-ls.nvim",
optional = true,
diff --git a/lua/lazyvim/plugins/extras/lang/tex.lua b/lua/lazyvim/plugins/extras/lang/tex.lua
index f8dacfb4..2d1bca56 100644
--- a/lua/lazyvim/plugins/extras/lang/tex.lua
+++ b/lua/lazyvim/plugins/extras/lang/tex.lua
@@ -1,4 +1,10 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = { "tex", "plaintex", "bib" },
+ root = { ".latexmkrc", ".texlabroot", "texlabroot", "Tectonic.toml" },
+ })
+ end,
{
"folke/which-key.nvim",
optional = true,
diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua
index 4bb280d6..373775ce 100644
--- a/lua/lazyvim/plugins/extras/lang/typescript.lua
+++ b/lua/lazyvim/plugins/extras/lang/typescript.lua
@@ -1,4 +1,28 @@
+local inlay_hints_settings = {
+ includeInlayEnumMemberValueHints = true,
+ includeInlayFunctionLikeReturnTypeHints = true,
+ includeInlayFunctionParameterTypeHints = true,
+ includeInlayParameterNameHints = "literal",
+ includeInlayParameterNameHintsWhenArgumentMatchesName = false,
+ includeInlayPropertyDeclarationTypeHints = true,
+ includeInlayVariableTypeHints = false,
+ includeInlayVariableTypeHintsWhenTypeMatchesName = false,
+}
+
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = {
+ "javascript",
+ "javascriptreact",
+ "javascript.jsx",
+ "typescript",
+ "typescriptreact",
+ "typescript.tsx",
+ },
+ root = { "tsconfig.json", "package.json", "jsconfig.json" },
+ })
+ end,
-- add typescript to treesitter
{
@@ -46,8 +70,13 @@ return {
desc = "Remove Unused Imports",
},
},
- ---@diagnostic disable-next-line: missing-fields
settings = {
+ typescript = {
+ inlayHints = inlay_hints_settings,
+ },
+ javascript = {
+ inlayHints = inlay_hints_settings,
+ },
completions = {
completeFunctionCalls = true,
},
@@ -87,6 +116,20 @@ return {
},
}
end
+ if not dap.adapters["node"] then
+ dap.adapters["node"] = function(cb, config)
+ if config.type == "node" then
+ config.type = "pwa-node"
+ end
+ local nativeAdapter = dap.adapters["pwa-node"]
+ if type(nativeAdapter) == "function" then
+ nativeAdapter(cb, config)
+ else
+ cb(nativeAdapter)
+ end
+ end
+ end
+
for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do
if not dap.configurations[language] then
dap.configurations[language] = {
diff --git a/lua/lazyvim/plugins/extras/lang/vue.lua b/lua/lazyvim/plugins/extras/lang/vue.lua
index a943874b..2ce87c03 100644
--- a/lua/lazyvim/plugins/extras/lang/vue.lua
+++ b/lua/lazyvim/plugins/extras/lang/vue.lua
@@ -1,4 +1,11 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "vue",
+ root = { "vue.config.js" },
+ })
+ end,
+
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua
index 9fd88a3b..0aa23a2b 100644
--- a/lua/lazyvim/plugins/extras/lang/yaml.lua
+++ b/lua/lazyvim/plugins/extras/lang/yaml.lua
@@ -1,4 +1,9 @@
return {
+ recommended = function()
+ return LazyVim.extras.wants({
+ ft = "yaml",
+ })
+ end,
-- add yaml specific modules to treesitter
{
diff --git a/lua/lazyvim/plugins/extras/test/core.lua b/lua/lazyvim/plugins/extras/test/core.lua
index e7dbd792..9a91ccc3 100644
--- a/lua/lazyvim/plugins/extras/test/core.lua
+++ b/lua/lazyvim/plugins/extras/test/core.lua
@@ -1,4 +1,6 @@
return {
+ recommended = true,
+ desc = "Neotest support. Requires language specific adapters to be configured. (see lang extras)",
{
"folke/which-key.nvim",
optional = true,
diff --git a/lua/lazyvim/plugins/extras/ui/mini-animate.lua b/lua/lazyvim/plugins/extras/ui/mini-animate.lua
index dd2f8cd7..cca34135 100644
--- a/lua/lazyvim/plugins/extras/ui/mini-animate.lua
+++ b/lua/lazyvim/plugins/extras/ui/mini-animate.lua
@@ -1,37 +1,36 @@
+-- animations
return {
- -- animations
- {
- "echasnovski/mini.animate",
- event = "VeryLazy",
- opts = function()
- -- don't use animate when scrolling with the mouse
- local mouse_scrolled = false
- for _, scroll in ipairs({ "Up", "Down" }) do
- local key = ""
- vim.keymap.set({ "", "i" }, key, function()
- mouse_scrolled = true
- return key
- end, { expr = true })
- end
+ "echasnovski/mini.animate",
+ recommended = true,
+ event = "VeryLazy",
+ opts = function()
+ -- don't use animate when scrolling with the mouse
+ local mouse_scrolled = false
+ for _, scroll in ipairs({ "Up", "Down" }) do
+ local key = ""
+ vim.keymap.set({ "", "i" }, key, function()
+ mouse_scrolled = true
+ return key
+ end, { expr = true })
+ end
- local animate = require("mini.animate")
- return {
- resize = {
- timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
- },
- scroll = {
- timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
- subscroll = animate.gen_subscroll.equal({
- predicate = function(total_scroll)
- if mouse_scrolled then
- mouse_scrolled = false
- return false
- end
- return total_scroll > 1
- end,
- }),
- },
- }
- end,
- },
+ local animate = require("mini.animate")
+ return {
+ resize = {
+ timing = animate.gen_timing.linear({ duration = 100, unit = "total" }),
+ },
+ scroll = {
+ timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
+ subscroll = animate.gen_subscroll.equal({
+ predicate = function(total_scroll)
+ if mouse_scrolled then
+ mouse_scrolled = false
+ return false
+ end
+ return total_scroll > 1
+ end,
+ }),
+ },
+ }
+ end,
}
diff --git a/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua b/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua
new file mode 100644
index 00000000..a7632145
--- /dev/null
+++ b/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua
@@ -0,0 +1,42 @@
+return {
+ -- Active indent guide and indent text objects. When you're browsing
+ -- code, this highlights the current level of indentation, and animates
+ -- the highlighting.
+ {
+ "echasnovski/mini.indentscope",
+ version = false, -- wait till new 0.7.0 release to put it back on semver
+ event = "LazyFile",
+ opts = {
+ -- symbol = "▏",
+ symbol = "│",
+ options = { try_as_border = true },
+ },
+ init = function()
+ vim.api.nvim_create_autocmd("FileType", {
+ pattern = {
+ "help",
+ "alpha",
+ "dashboard",
+ "neo-tree",
+ "Trouble",
+ "trouble",
+ "lazy",
+ "mason",
+ "notify",
+ "toggleterm",
+ "lazyterm",
+ },
+ callback = function()
+ vim.b.miniindentscope_disable = true
+ end,
+ })
+ end,
+ },
+ {
+ "lukas-reineke/indent-blankline.nvim",
+ event = "LazyFile",
+ opts = {
+ scope = { enabled = false },
+ },
+ },
+}
diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua
index 5f5ec9c5..e6078d60 100644
--- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua
+++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua
@@ -63,12 +63,15 @@ return {
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
- callback = function()
+ callback = function(ev)
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
local pad_footer = string.rep(" ", 8)
starter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
- pcall(starter.refresh)
+ -- INFO: based on @echasnovski's recommendation (thanks a lot!!!)
+ if vim.bo[ev.buf].filetype == "starter" then
+ pcall(starter.refresh)
+ end
end,
})
end,
diff --git a/lua/lazyvim/plugins/extras/ui/treesitter-context.lua b/lua/lazyvim/plugins/extras/ui/treesitter-context.lua
new file mode 100644
index 00000000..a1f8d5f3
--- /dev/null
+++ b/lua/lazyvim/plugins/extras/ui/treesitter-context.lua
@@ -0,0 +1,21 @@
+-- Show context of the current function
+return {
+ "nvim-treesitter/nvim-treesitter-context",
+ event = "LazyFile",
+ opts = { mode = "cursor", max_lines = 3 },
+ keys = {
+ {
+ "ut",
+ function()
+ local tsc = require("treesitter-context")
+ tsc.toggle()
+ if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then
+ LazyVim.info("Enabled Treesitter Context", { title = "Option" })
+ else
+ LazyVim.warn("Disabled Treesitter Context", { title = "Option" })
+ end
+ end,
+ desc = "Toggle Treesitter Context",
+ },
+ },
+}
diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua
index 66e34c30..7c887088 100644
--- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua
+++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua
@@ -5,6 +5,8 @@ M.hl = {}
M.plugin = {
"echasnovski/mini.hipatterns",
+ recommended = true,
+ desc = "Highlight colors in your code. Also includes Tailwind CSS support.",
event = "LazyFile",
opts = function()
local hi = require("mini.hipatterns")
diff --git a/lua/lazyvim/plugins/extras/util/startuptime.lua b/lua/lazyvim/plugins/extras/util/startuptime.lua
new file mode 100644
index 00000000..5775b564
--- /dev/null
+++ b/lua/lazyvim/plugins/extras/util/startuptime.lua
@@ -0,0 +1,8 @@
+-- measure startuptime
+return {
+ "dstein64/vim-startuptime",
+ cmd = "StartupTime",
+ config = function()
+ vim.g.startuptime_tries = 10
+ end,
+}
diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua
index 718cb0f9..28dea8ed 100644
--- a/lua/lazyvim/plugins/formatting.lua
+++ b/lua/lazyvim/plugins/formatting.lua
@@ -54,9 +54,7 @@ return {
priority = 100,
primary = true,
format = function(buf)
- local plugin = require("lazy.core.config").plugins["conform.nvim"]
- local Plugin = require("lazy.core.plugin")
- local opts = Plugin.values(plugin, "opts", false)
+ local opts = LazyVim.opts("conform.nvim")
require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf }))
end,
sources = function(buf)
diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua
index 30ef5115..3a6ae964 100644
--- a/lua/lazyvim/plugins/lsp/init.lua
+++ b/lua/lazyvim/plugins/lsp/init.lua
@@ -38,7 +38,7 @@ return {
-- Be aware that you also will need to properly configure your LSP server to
-- provide the inlay hints.
inlay_hints = {
- enabled = false,
+ enabled = true,
},
-- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0
-- Be aware that you also will need to properly configure your LSP server to
@@ -46,6 +46,10 @@ return {
codelens = {
enabled = false,
},
+ -- Enable lsp cursor word highlighting
+ document_highlight = {
+ enabled = true,
+ },
-- add any global capabilities here
capabilities = {},
-- options for vim.lsp.buf.format
@@ -75,6 +79,17 @@ return {
completion = {
callSnippet = "Replace",
},
+ doc = {
+ privateName = { "^_" },
+ },
+ hint = {
+ enable = true,
+ setType = false,
+ paramType = true,
+ paramName = "Disable",
+ semicolon = "Disable",
+ arrayIndex = "Disable",
+ },
},
},
},
@@ -95,8 +110,7 @@ return {
---@param opts PluginLspOpts
config = function(_, opts)
if LazyVim.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))
+ require("neoconf").setup(LazyVim.opts("neoconf.nvim"))
end
-- setup autoformat
@@ -118,36 +132,42 @@ return {
return ret
end
+ LazyVim.lsp.words.setup(opts.document_highlight)
+
-- diagnostics signs
if vim.fn.has("nvim-0.10.0") == 0 then
- for severity, icon in pairs(opts.diagnostics.signs.text) do
- local name = vim.diagnostic.severity[severity]:lower():gsub("^%l", string.upper)
- name = "DiagnosticSign" .. name
- vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
+ if type(opts.diagnostics.signs) ~= "boolean" then
+ for severity, icon in pairs(opts.diagnostics.signs.text) do
+ local name = vim.diagnostic.severity[severity]:lower():gsub("^%l", string.upper)
+ name = "DiagnosticSign" .. name
+ vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
+ end
end
end
- -- inlay hints
- if opts.inlay_hints.enabled then
- LazyVim.lsp.on_attach(function(client, buffer)
- if client.supports_method("textDocument/inlayHint") then
- LazyVim.toggle.inlay_hints(buffer, true)
- end
- end)
- end
+ if vim.fn.has("nvim-0.10") == 1 then
+ -- inlay hints
+ if opts.inlay_hints.enabled then
+ LazyVim.lsp.on_attach(function(client, buffer)
+ if client.supports_method("textDocument/inlayHint") then
+ LazyVim.toggle.inlay_hints(buffer, true)
+ end
+ end)
+ end
- -- code lens
- if opts.codelens.enabled and vim.lsp.codelens then
- LazyVim.lsp.on_attach(function(client, buffer)
- if client.supports_method("textDocument/codeLens") then
- vim.lsp.codelens.refresh()
- --- autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh()
- vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
- buffer = buffer,
- callback = vim.lsp.codelens.refresh,
- })
- end
- end)
+ -- code lens
+ if opts.codelens.enabled and vim.lsp.codelens then
+ LazyVim.lsp.on_attach(function(client, buffer)
+ if client.supports_method("textDocument/codeLens") then
+ vim.lsp.codelens.refresh()
+ --- autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh()
+ vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
+ buffer = buffer,
+ callback = vim.lsp.codelens.refresh,
+ })
+ end
+ end)
+ end
end
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua
index 0f5aecb7..14626afd 100644
--- a/lua/lazyvim/plugins/lsp/keymaps.lua
+++ b/lua/lazyvim/plugins/lsp/keymaps.lua
@@ -39,7 +39,9 @@ function M.get()
end,
desc = "Source Action",
has = "codeAction",
- }
+ },
+ { "]]", function() LazyVim.lsp.words.jump(vim.v.count1) end, has = "documentHighlight", desc = "Next Reference" },
+ { "[[", function() LazyVim.lsp.words.jump(-vim.v.count1) end, has = "documentHighlight", desc = "Next Reference" },
}
if LazyVim.has("inc-rename.nvim") then
M._keys[#M._keys + 1] = {
diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua
index 108582ff..19aef89b 100644
--- a/lua/lazyvim/plugins/treesitter.lua
+++ b/lua/lazyvim/plugins/treesitter.lua
@@ -7,6 +7,7 @@ return {
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
@@ -16,33 +17,6 @@ return {
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end,
- dependencies = {
- {
- "nvim-treesitter/nvim-treesitter-textobjects",
- config = function()
- -- 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,
- },
- },
cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
keys = {
{ "", desc = "Increment Selection" },
@@ -111,30 +85,37 @@ return {
end, opts.ensure_installed)
end
require("nvim-treesitter.configs").setup(opts)
+ vim.schedule(function()
+ require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } })
+ end)
end,
},
- -- Show context of the current function
{
- "nvim-treesitter/nvim-treesitter-context",
- event = "LazyFile",
- enabled = true,
- opts = { mode = "cursor", max_lines = 3 },
- keys = {
- {
- "ut",
- function()
- local tsc = require("treesitter-context")
- tsc.toggle()
- if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then
- LazyVim.info("Enabled Treesitter Context", { title = "Option" })
- else
- LazyVim.warn("Disabled Treesitter Context", { title = "Option" })
+ "nvim-treesitter/nvim-treesitter-textobjects",
+ lazy = true,
+ config = function()
+ -- 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,
- desc = "Toggle Treesitter Context",
- },
- },
+ end
+ end
+ end,
},
-- Automatically add closing tags for HTML and JSX
diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua
index 2cd9496c..1846ba0a 100644
--- a/lua/lazyvim/plugins/ui.lua
+++ b/lua/lazyvim/plugins/ui.lua
@@ -71,9 +71,9 @@ return {
opts = {
options = {
-- stylua: ignore
- close_command = function(n) require("mini.bufremove").delete(n, false) end,
+ close_command = function(n) LazyVim.ui.bufremove(n) end,
-- stylua: ignore
- right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end,
+ right_mouse_command = function(n) LazyVim.ui.bufremove(n) end,
diagnostics = "nvim_lsp",
always_show_bufferline = false,
diagnostics_indicator = function(_, _, diag)
@@ -95,7 +95,7 @@ return {
config = function(_, opts)
require("bufferline").setup(opts)
-- Fix bufferline when restoring a session
- vim.api.nvim_create_autocmd("BufAdd", {
+ vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, {
callback = function()
vim.schedule(function()
pcall(nvim_bufferline)
@@ -219,7 +219,7 @@ return {
char = "│",
tab_char = "│",
},
- scope = { enabled = false },
+ scope = { show_start = false, show_end = false },
exclude = {
filetypes = {
"help",
@@ -237,39 +237,12 @@ return {
},
},
main = "ibl",
- },
-
- -- Active indent guide and indent text objects. When you're browsing
- -- code, this highlights the current level of indentation, and animates
- -- the highlighting.
- {
- "echasnovski/mini.indentscope",
- version = false, -- wait till new 0.7.0 release to put it back on semver
- event = "LazyFile",
- opts = {
- -- symbol = "▏",
- symbol = "│",
- options = { try_as_border = true },
- },
- init = function()
- vim.api.nvim_create_autocmd("FileType", {
- pattern = {
- "help",
- "alpha",
- "dashboard",
- "neo-tree",
- "Trouble",
- "trouble",
- "lazy",
- "mason",
- "notify",
- "toggleterm",
- "lazyterm",
- },
- callback = function()
- vim.b.miniindentscope_disable = true
- end,
- })
+ config = function(_, opts)
+ if vim.fn.has("nvim-0.10.0") == 0 then
+ local utils = require("ibl.utils")
+ utils.tbl_join = vim.tbl_flatten
+ end
+ require("ibl").setup(opts)
end,
},
@@ -322,6 +295,7 @@ return {
{ "snh", function() require("noice").cmd("history") end, desc = "Noice History" },
{ "sna", function() require("noice").cmd("all") end, desc = "Noice All" },
{ "snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" },
+ { "snt", function() require("noice").cmd("telescope") end, desc = "Noice Telescope" },
{ "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll Forward", mode = {"i", "n", "s"} },
{ "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll Backward", mode = {"i", "n", "s"}},
},
diff --git a/lua/lazyvim/plugins/util.lua b/lua/lazyvim/plugins/util.lua
index c3870889..cf5d9e03 100644
--- a/lua/lazyvim/plugins/util.lua
+++ b/lua/lazyvim/plugins/util.lua
@@ -1,14 +1,5 @@
return {
- -- measure startuptime
- {
- "dstein64/vim-startuptime",
- cmd = "StartupTime",
- config = function()
- vim.g.startuptime_tries = 10
- end,
- },
-
-- Session management. This saves your session in the background,
-- keeping track of open buffers, window arrangement, and more.
-- You can restore sessions when returning through the dashboard.
diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua
index 74ab4b4c..773f6b9e 100644
--- a/lua/lazyvim/util/extras.lua
+++ b/lua/lazyvim/util/extras.lua
@@ -16,12 +16,15 @@ local Text = require("lazy.view.text")
---@field desc? string
---@field enabled boolean
---@field managed boolean
+---@field recommended? boolean
---@field row? number
+---@field section? string
---@field plugins string[]
---@field optional string[]
---@class lazyvim.util.extras
local M = {}
+M.buf = 0
---@type LazyExtraSource[]
M.sources = {
@@ -33,6 +36,24 @@ M.ns = vim.api.nvim_create_namespace("lazyvim.extras")
---@type string[]
M.state = nil
+---@param opts {ft?: string|string[], root?: string|string[]}
+---@return boolean
+function M.wants(opts)
+ if opts.ft then
+ opts.ft = type(opts.ft) == "string" and { opts.ft } or opts.ft
+ for _, f in ipairs(opts.ft) do
+ if vim.bo[M.buf].filetype == f then
+ return true
+ end
+ end
+ end
+ if opts.root then
+ opts.root = type(opts.root) == "string" and { opts.root } or opts.root
+ return #LazyVim.root.detectors.pattern(M.buf, opts.root) > 0
+ end
+ return false
+end
+
---@return LazyExtra[]
function M.get()
M.state = M.state or LazyConfig.spec.modules
@@ -74,6 +95,12 @@ function M.get_extra(source, modname)
table.sort(plugins)
table.sort(optional)
+ ---@type boolean|(fun():boolean?)|nil
+ local recommended = require(modname).recommended or false
+ if type(recommended) == "function" then
+ recommended = recommended() or false
+ end
+
---@type LazyExtra
return {
source = source,
@@ -81,6 +108,7 @@ function M.get_extra(source, modname)
module = modname,
enabled = enabled,
desc = require(modname).desc,
+ recommended = recommended,
managed = vim.tbl_contains(Config.json.data.extras, modname) or not enabled,
plugins = plugins,
optional = optional,
@@ -97,6 +125,7 @@ local X = {}
---@return LazyExtraView
function X.new()
local self = setmetatable({}, { __index = X })
+ M.buf = vim.api.nvim_get_current_buf()
self.float = Float.new({ title = "LazyVim Extras" })
self.float:on_key("x", function()
self:toggle()
@@ -186,8 +215,14 @@ function X:render()
:append("", "LazySpecial")
:append(" key", "LazyComment")
:nl()
+ for _, extra in ipairs(self.extras) do
+ extra.section = nil
+ end
self:section({ enabled = true, title = "Enabled" })
- self:section({ enabled = false, title = "Disabled" })
+ self:section({ recommended = true, include = "^lang%.", title = "Recommended Languages", empty = false })
+ self:section({ recommended = true, title = "Recommended Plugins", empty = false })
+ self:section({ title = "Plugins", exclude = "^lang%." })
+ self:section({ title = "Languages" })
end
---@param extra LazyExtra
@@ -206,6 +241,9 @@ function X:extra(extra)
self.text:append(" " .. LazyConfig.options.ui.icons.not_loaded .. " ", hl)
end
self.text:append(extra.name)
+ if extra.recommended then
+ self.text:append(" "):append(LazyConfig.options.ui.icons.favorite or " ", "LazyCommit")
+ end
if extra.source.name ~= "LazyVim" then
self.text:append(" "):append(LazyConfig.options.ui.icons.event .. " " .. extra.source.name, "LazyReasonEvent")
end
@@ -221,16 +259,25 @@ function X:extra(extra)
self.text:nl()
end
----@param opts {enabled?:boolean, title?:string}
+---@param opts {enabled?:boolean, title:string, recommended?:boolean, include?:string, exclude?:string, empty?:boolean}
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
+ return extra.section == nil
+ and (opts.enabled == nil or extra.enabled == opts.enabled)
+ and (opts.recommended == nil or extra.recommended == opts.recommended)
+ and (opts.include == nil or extra.name:find(opts.include))
+ and (opts.exclude == nil or not extra.name:find(opts.exclude))
end, self.extras)
+ if opts.empty == false and #extras == 0 then
+ return
+ end
+
self.text:nl():append(opts.title .. ":", "LazyH2"):append(" (" .. #extras .. ")", "LazyComment"):nl()
for _, extra in ipairs(extras) do
+ extra.section = opts.title
self:extra(extra)
end
end
diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua
index f343c338..d6907a60 100644
--- a/lua/lazyvim/util/init.lua
+++ b/lua/lazyvim/util/init.lua
@@ -72,7 +72,7 @@ end
---@param name string
function M.opts(name)
- local plugin = require("lazy.core.config").plugins[name]
+ local plugin = require("lazy.core.config").spec.plugins[name]
if not plugin then
return {}
end
@@ -170,4 +170,19 @@ function M.safe_keymap_set(mode, lhs, rhs, opts)
end
end
+---@generic T
+---@param list T[]
+---@return T[]
+function M.dedup(list)
+ local ret = {}
+ local seen = {}
+ for _, v in ipairs(list) do
+ if not seen[v] then
+ table.insert(ret, v)
+ seen[v] = true
+ end
+ end
+ return ret
+end
+
return M
diff --git a/lua/lazyvim/util/inject.lua b/lua/lazyvim/util/inject.lua
index 81e0f57a..859afc81 100644
--- a/lua/lazyvim/util/inject.lua
+++ b/lua/lazyvim/util/inject.lua
@@ -31,4 +31,20 @@ function M.get_upvalue(func, name)
end
end
+function M.set_upvalue(func, name, value)
+ local i = 1
+ while true do
+ local n = debug.getupvalue(func, i)
+ if not n then
+ break
+ end
+ if n == name then
+ debug.setupvalue(func, i, value)
+ return
+ end
+ i = i + 1
+ end
+ LazyVim.error("upvalue not found: " .. name)
+end
+
return M
diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua
index e712120a..e2eb82de 100644
--- a/lua/lazyvim/util/lsp.lua
+++ b/lua/lazyvim/util/lsp.lua
@@ -21,7 +21,7 @@ function M.get_clients(opts)
return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret
end
----@param on_attach fun(client, buffer)
+---@param on_attach fun(client:lsp.Client, buffer)
function M.on_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
@@ -125,4 +125,78 @@ function M.format(opts)
end
end
+---@alias LspWord {from:{[1]:number, [2]:number}, to:{[1]:number, [2]:number}, current?:boolean} 1-0 indexed
+M.words = {}
+M.words.ns = vim.api.nvim_create_namespace("vim_lsp_references")
+
+---@param opts? {enabled?: boolean}
+function M.words.setup(opts)
+ opts = opts or {}
+ if not opts.enabled then
+ return
+ end
+ local handler = vim.lsp.handlers["textDocument/documentHighlight"]
+ vim.lsp.handlers["textDocument/documentHighlight"] = function(err, result, ctx, config)
+ if not vim.api.nvim_buf_is_loaded(ctx.bufnr) then
+ return
+ end
+ return handler(err, result, ctx, config)
+ end
+
+ M.on_attach(function(client, buf)
+ if client.supports_method("textDocument/documentHighlight") then
+ vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, {
+ group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }),
+ buffer = buf,
+ callback = function(ev)
+ if not M.words.at() then
+ if ev.event:find("CursorMoved") then
+ vim.lsp.buf.clear_references()
+ else
+ vim.lsp.buf.document_highlight()
+ end
+ end
+ end,
+ })
+ end
+ end)
+end
+
+---@return LspWord[]
+function M.words.get()
+ local cursor = vim.api.nvim_win_get_cursor(0)
+ return vim.tbl_map(function(extmark)
+ local ret = {
+ from = { extmark[2] + 1, extmark[3] },
+ to = { extmark[4].end_row + 1, extmark[4].end_col },
+ }
+ if cursor[1] >= ret.from[1] and cursor[1] <= ret.to[1] and cursor[2] >= ret.from[2] and cursor[2] <= ret.to[2] then
+ ret.current = true
+ end
+ return ret
+ end, vim.api.nvim_buf_get_extmarks(0, M.words.ns, 0, -1, { details = true }))
+end
+
+---@param words? LspWord[]
+---@return LspWord?, number?
+function M.words.at(words)
+ for idx, word in ipairs(words or M.words.get()) do
+ if word.current then
+ return word, idx
+ end
+ end
+end
+
+function M.words.jump(count)
+ local words = M.words.get()
+ local _, idx = M.words.at(words)
+ if not idx then
+ return
+ end
+ local target = words[idx + count]
+ if target then
+ vim.api.nvim_win_set_cursor(0, target.from)
+ end
+end
+
return M
diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua
index 13a2acec..0789b09f 100644
--- a/lua/lazyvim/util/plugin.lua
+++ b/lua/lazyvim/util/plugin.lua
@@ -3,7 +3,6 @@ local Plugin = require("lazy.core.plugin")
---@class lazyvim.util.plugin
local M = {}
-M.use_lazy_file = true
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
---@type table
@@ -11,6 +10,8 @@ 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.",
+ ["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.",
}
M.deprecated_modules = {
@@ -55,83 +56,44 @@ function M.extra_idx(name)
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
+ -- This autocmd will only trigger when a file was loaded from the cmdline.
+ -- It will render the file as quickly as possible.
+ vim.api.nvim_create_autocmd("BufReadPost", {
+ once = true,
+ callback = function(event)
+ -- Skip if we already entered vim
+ if vim.v.vim_did_enter == 1 then
+ return
+ end
+
+ -- Try to guess the filetype (may change later on during Neovim startup)
+ local ft = vim.filetype.match({ buf = event.buf })
+ if ft then
+ -- Add treesitter highlights and fallback to syntax
+ local lang = vim.treesitter.language.get_lang(ft)
+ if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then
+ vim.bo[event.buf].syntax = ft
+ end
+
+ -- Trigger early redraw
+ vim.cmd([[redraw]])
+ end
+ end,
+ })
-- Add support for the LazyFile event
local Event = require("lazy.core.handler.event")
- 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
-
- local events = {} ---@type {event: string, buf: number, data?: any}[]
-
- local done = false
- local function load()
- if #events == 0 or done then
- return
- end
- done = true
- vim.api.nvim_del_augroup_by_name("lazy_file")
-
- ---@type table
- local skips = {}
- for _, event in ipairs(events) do
- local augroups = Event.get_augroups(event.event)
- local groups = vim.tbl_filter(function(t)
- return not vim.tbl_contains({ t }, "filetypedetect")
- end, augroups)
- skips[event.event] = skips[event.event] or groups
- end
-
- vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false })
- for _, event in ipairs(events) do
- if vim.api.nvim_buf_is_valid(event.buf) then
- 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
- end
- vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false })
- 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(M.lazy_file_events, {
- group = vim.api.nvim_create_augroup("lazy_file", { clear = true }),
- callback = function(event)
- table.insert(events, event)
- load()
- end,
- })
+ Event.mappings.LazyFile = { id = "LazyFile", event = M.lazy_file_events }
+ Event.mappings["User LazyFile"] = Event.mappings.LazyFile
end
function M.fix_imports()
Plugin.Spec.import = LazyVim.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."
+ dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning."
LazyVim.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 })
return false
end
diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua
index c8de430d..f1167337 100644
--- a/lua/lazyvim/util/root.lua
+++ b/lua/lazyvim/util/root.lua
@@ -47,7 +47,17 @@ end
function M.detectors.pattern(buf, patterns)
patterns = type(patterns) == "string" and { patterns } or patterns
local path = M.bufpath(buf) or vim.uv.cwd()
- local pattern = vim.fs.find(patterns, { path = path, upward = true })[1]
+ local pattern = vim.fs.find(function(name)
+ for _, p in ipairs(patterns) do
+ if name == p then
+ return true
+ end
+ if p:sub(1, 1) == "*" and name:find(p:sub(2) .. "$") then
+ return true
+ end
+ end
+ return false
+ end, { path = path, upward = true })[1]
return pattern and { vim.fs.dirname(pattern) } or {}
end
diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua
index a377064e..543d4c13 100644
--- a/lua/lazyvim/util/toggle.lua
+++ b/lua/lazyvim/util/toggle.lua
@@ -43,7 +43,9 @@ local enabled = true
function M.diagnostics()
-- if this Neovim version supports checking if diagnostics are enabled
-- then use that for the current state
- if vim.diagnostic.is_disabled then
+ if vim.diagnostic.is_enabled then
+ enabled = vim.diagnostic.is_enabled()
+ elseif vim.diagnostic.is_disabled then
enabled = not vim.diagnostic.is_disabled()
end
enabled = not enabled
@@ -65,7 +67,7 @@ function M.inlay_hints(buf, value)
ih(buf, value)
elseif type(ih) == "table" and ih.enable then
if value == nil then
- value = not ih.is_enabled(buf)
+ value = not ih.is_enabled({ bufnr = buf or 0 })
end
ih.enable(value, { bufnr = buf })
end
diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua
index 91339ca7..a7bdc700 100644
--- a/lua/lazyvim/util/ui.lua
+++ b/lua/lazyvim/util/ui.lua
@@ -208,4 +208,47 @@ function M.foldexpr()
return "0"
end
+---@param buf number?
+function M.bufremove(buf)
+ buf = buf or 0
+ buf = buf == 0 and vim.api.nvim_get_current_buf() or buf
+
+ 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 == 0 then -- Cancel
+ return
+ end
+ if choice == 1 then -- Yes
+ vim.cmd.write()
+ end
+ end
+
+ for _, win in ipairs(vim.fn.win_findbuf(buf)) do
+ vim.api.nvim_win_call(win, function()
+ if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
+ return
+ end
+ -- Try using alternate buffer
+ local alt = vim.fn.bufnr("#")
+ if alt ~= buf and vim.fn.buflisted(alt) == 1 then
+ vim.api.nvim_win_set_buf(win, alt)
+ return
+ end
+
+ -- Try using previous buffer
+ local has_previous = pcall(vim.cmd, "bprevious")
+ if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
+ return
+ end
+
+ -- Create new listed buffer
+ local new_buf = vim.api.nvim_create_buf(true, false)
+ vim.api.nvim_win_set_buf(win, new_buf)
+ end)
+ end
+ if vim.api.nvim_buf_is_valid(buf) then
+ pcall(vim.cmd, "bdelete! " .. buf)
+ end
+end
+
return M
diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm
index 829b2b08..eb048490 100644
--- a/queries/lua/highlights.scm
+++ b/queries/lua/highlights.scm
@@ -2,3 +2,6 @@
((identifier) @namespace.builtin
(#eq? @namespace.builtin "vim"))
+
+((identifier) @namespace.builtin
+ (#eq? @namespace.builtin "LazyVim"))