Merge branch 'LazyVim:main' into fix/extras-lang-kotlin

This commit is contained in:
Arthur 2024-06-06 11:31:27 +08:00 committed by GitHub
commit 87774b4cc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 307 additions and 76 deletions

View file

@ -3,6 +3,11 @@ description: Suggest a new feature
title: "feature: "
labels: [enhancement]
body:
- type: markdown
attributes:
value: |
**IMPORTANT:** ideas or requests related to extras, should go in the [Extra Requests](https://github.com/LazyVim/LazyVim/discussions/categories/extra-requests)
discussion forum.
- type: checkboxes
attributes:
label: Did you check the docs?
@ -10,6 +15,8 @@ body:
options:
- label: I have read all the LazyVim docs
required: true
- label: This is not a request for a new or existing extra (see above)
required: true
- type: textarea
validations:
required: true

View file

@ -1,5 +1,35 @@
# Changelog
## [12.5.0](https://github.com/LazyVim/LazyVim/compare/v12.4.0...v12.5.0) (2024-06-05)
### Features
* **bufferline:** add keymaps for BufferLineMovePrev / BufferLineMoveNext ([#1935](https://github.com/LazyVim/LazyVim/issues/1935)) ([1806ea7](https://github.com/LazyVim/LazyVim/commit/1806ea710fe391d5b00c1916ed9331bf58cfdb49))
* **editor:** added extra for inc-rename.nvim ([#3432](https://github.com/LazyVim/LazyVim/issues/3432)) ([c50018b](https://github.com/LazyVim/LazyVim/commit/c50018b791a6295fb0f3219fe637209a381db4c4))
* enabled `ts-plugin` support for `astro` and `svelte` ([d64d761](https://github.com/LazyVim/LazyVim/commit/d64d7615392d70c2ca1957f66725856d0a306b87))
* **extras:** Add extra for angular lspconfig ([#2806](https://github.com/LazyVim/LazyVim/issues/2806)) ([987bd22](https://github.com/LazyVim/LazyVim/commit/987bd2207f7f2f7f72f65b0e7e811ec04c03aa32))
* **keymaps:** add keymap to close all tab pages except the current one ([#2975](https://github.com/LazyVim/LazyVim/issues/2975)) ([de9e337](https://github.com/LazyVim/LazyVim/commit/de9e337f0dcd27a7621f6ab741ad3a5d769dbd7c))
* **lazydev:** use lazydev with neodev types (not the plugin) on Neovim 0.9.x ([1677b3b](https://github.com/LazyVim/LazyVim/commit/1677b3b84f53d410d50c5a2aca32ca7c5e900917))
* **python:** switch to regexp branch for a rewrite the venv selector plugin ([#3301](https://github.com/LazyVim/LazyVim/issues/3301)) ([1cdb5bd](https://github.com/LazyVim/LazyVim/commit/1cdb5bdf412933bb1be44a3ae5905202124718d9))
* **statuscol:** statuscolumn options for open fold indicator and fold hl ([#2923](https://github.com/LazyVim/LazyVim/issues/2923)) ([fa706b3](https://github.com/LazyVim/LazyVim/commit/fa706b320b4c94da28136bdbab2ee1841974707c))
### Bug Fixes
* cleanup unnecessary treesitter langs and mason lsp servers ([f8268fa](https://github.com/LazyVim/LazyVim/commit/f8268faa7c705cca7047fbaef5984905b47a7324))
* **extra.lang.scala:** Fix the always initializing regardless of file… ([#3455](https://github.com/LazyVim/LazyVim/issues/3455)) ([c1f5fcf](https://github.com/LazyVim/LazyVim/commit/c1f5fcf9c7ed2659c9d5ac41b3bb8a93e0a3c6a0))
* **extras:** added recommended for helm/haskell ([ca0b9ee](https://github.com/LazyVim/LazyVim/commit/ca0b9ee915c7e5ddc4ca828688c2cb87f4f0c438))
* **keymaps:** use root dir for git log ([662e2ff](https://github.com/LazyVim/LazyVim/commit/662e2ffe0ff8f43e15cf97029a5e1ec84bb1e376))
* **lazydev:** add cmd ([ae0d94e](https://github.com/LazyVim/LazyVim/commit/ae0d94e048423903743b657be3a827d9685761c3))
* **lsp:** Enable using `deno.enablePaths` in denols settings ([#3446](https://github.com/LazyVim/LazyVim/issues/3446)) ([9a635ef](https://github.com/LazyVim/LazyVim/commit/9a635ef8d690a3cfcf6d3bf54e8ad61156b9d150))
* **python:** removed the `python-semshi` extra ([e32d191](https://github.com/LazyVim/LazyVim/commit/e32d1918ae676dbab3f5f121a9fa623cb4ee20bd))
* **tex:** remove latex treesitter support since it's not needed with vimtex and it needs treesitter-cli ([3df8af3](https://github.com/LazyVim/LazyVim/commit/3df8af369c49e13763a7c8962a005aef7604d018))
* **toggle:** Restore width/height values when closing while maximized is toggled on ([#3453](https://github.com/LazyVim/LazyVim/issues/3453)) ([8971ea2](https://github.com/LazyVim/LazyVim/commit/8971ea25f953f778c8db999da4de240a07713aaa))
* **toggle:** slightly better maximize ([452b70a](https://github.com/LazyVim/LazyVim/commit/452b70ad15714593a91bed90448313228dd5135a))
* **toggle:** un-maximize when quiting Neovim ([1c58365](https://github.com/LazyVim/LazyVim/commit/1c583650e66b6f468e8ece4292bfe8bd3f7e1c94))
* **util:** don't print warning message in headless ([73c767c](https://github.com/LazyVim/LazyVim/commit/73c767c2f3e43cf7edd2964f951b7e574ee5b283))
## [12.4.0](https://github.com/LazyVim/LazyVim/compare/v12.3.0...v12.4.0) (2024-06-04)

View file

@ -45,12 +45,59 @@ return {
require("mini.files").refresh({ content = { filter = new_filter } })
end
local map_split = function(buf_id, lhs, direction, close_on_file)
local rhs = function()
local new_target_window
local cur_target_window = require("mini.files").get_target_window()
if cur_target_window ~= nil then
vim.api.nvim_win_call(cur_target_window, function()
vim.cmd("belowright " .. direction .. " split")
new_target_window = vim.api.nvim_get_current_win()
end)
require("mini.files").set_target_window(new_target_window)
require("mini.files").go_in({ close_on_file = close_on_file })
end
end
local desc = "Open in " .. direction .. " split"
if close_on_file then
desc = desc .. " and close"
end
vim.keymap.set("n", lhs, rhs, { buffer = buf_id, desc = desc })
end
local files_set_cwd = function()
local cur_entry_path = MiniFiles.get_fs_entry().path
local cur_directory = vim.fs.dirname(cur_entry_path)
if cur_directory ~= nil then
vim.fn.chdir(cur_directory)
end
end
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesBufferCreate",
callback = function(args)
local buf_id = args.data.buf_id
-- Tweak left-hand side of mapping to your liking
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id, desc = "Toggle Hidden Files" })
vim.keymap.set(
"n",
opts.mappings.toggle_hidden or "g.",
toggle_dotfiles,
{ buffer = buf_id, desc = "Toggle hidden files" }
)
vim.keymap.set(
"n",
opts.mappings.change_cwd or "gc",
files_set_cwd,
{ buffer = args.data.buf_id, desc = "Set cwd" }
)
map_split(buf_id, opts.mappings.go_in_horizontal or "<C-w>s", "horizontal", false)
map_split(buf_id, opts.mappings.go_in_vertical or "<C-w>v", "vertical", false)
map_split(buf_id, opts.mappings.go_in_horizontal_plus or "<C-w>S", "horizontal", true)
map_split(buf_id, opts.mappings.go_in_vertical_plus or "<C-w>V", "vertical", true)
end,
})

View file

@ -1,3 +1,16 @@
if lazyvim_docs then
-- By default, prettier will only be used for formatting
-- if a prettier configuration file is found in the project.
-- Set to `false` to always use prettier for supported filetypes.
vim.g.lazyvim_prettier_needs_config = true
end
local needs_config = vim.g.lazyvim_prettier_needs_config ~= false
-- local check = vim.g.lazyvim_prettier
local enabled = {} ---@type table<string, boolean>
return {
{
"williamboman/mason.nvim",
@ -35,6 +48,22 @@ return {
["markdown.mdx"] = { "prettier" },
["graphql"] = { "prettier" },
["handlebars"] = { "prettier" },
["svelte"] = { "prettier" },
},
formatters = {
prettier = {
condition = function(_, ctx)
if not needs_config then
return true
end
if enabled[ctx.filename] == nil then
enabled[ctx.filename] = vim.fs.find(function(name, path)
return name:match("^%.prettierrc%.") or name:match("^prettier%.config%.")
end, { path = ctx.filename, upward = true })[1] ~= nil
end
return enabled[ctx.filename]
end,
},
},
},
},

View file

@ -14,6 +14,13 @@ return {
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "angular", "scss" })
end
vim.filetype.add({
pattern = {
[".*%.component%.html"] = "angular.html",
[".*%.container%.html"] = "angular.html",
},
})
vim.treesitter.language.register("angular", "angular.html")
end,
},

View file

@ -0,0 +1,30 @@
return {
recommended = {
ft = "nix",
root = "flake.nix",
},
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "nix" })
end,
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
nil_ls = {},
},
},
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
nix = { "nixfmt" },
},
},
},
}

View file

@ -0,0 +1,34 @@
return {
recommended = {
ft = "nu",
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
nushell = {},
},
},
},
{
"nvim-treesitter/nvim-treesitter",
dependencies = {
{ "nushell/tree-sitter-nu" },
},
opts = function(_, opts)
---@diagnostic disable-next-line: inject-field
require("nvim-treesitter.parsers").get_parser_configs().nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "nu" })
end
end,
},
}

View file

@ -53,15 +53,7 @@ return {
keys = {
{
"<leader>co",
function()
vim.lsp.buf.code_action({
apply = true,
context = {
only = { "source.organizeImports" },
diagnostics = {},
},
})
end,
LazyVim.lsp.action["source.organizeImports"],
desc = "Organize Imports",
},
},

View file

@ -27,7 +27,20 @@ return {
"neovim/nvim-lspconfig",
opts = {
servers = {
svelte = {},
svelte = {
keys = {
{
"<leader>co",
LazyVim.lsp.action["source.organizeImports"],
desc = "Organize Imports",
},
},
capabilities = {
workspace = {
didChangeWatchedFiles = vim.fn.has("nvim-0.10") == 0 and { dynamicRegistration = true },
},
},
},
},
},
},

View file

@ -13,15 +13,6 @@ return {
})
end,
{
"yioneko/nvim-vtsls",
lazy = true,
opts = {},
config = function(_, opts)
require("vtsls").config(opts)
end,
},
-- correctly setup lspconfig
{
"neovim/nvim-lspconfig",
@ -72,49 +63,50 @@ return {
{
"gD",
function()
require("vtsls").commands.goto_source_definition(0)
local params = vim.lsp.util.make_position_params()
LazyVim.lsp.execute({
command = "typescript.goToSourceDefinition",
arguments = { params.textDocument.uri, params.position },
open = true,
})
end,
desc = "Goto Source Definition",
},
{
"gR",
function()
require("vtsls").commands.file_references(0)
LazyVim.lsp.execute({
command = "typescript.findAllFileReferences",
arguments = { vim.uri_from_bufnr(0) },
open = true,
})
end,
desc = "File References",
},
{
"<leader>co",
function()
require("vtsls").commands.organize_imports(0)
end,
LazyVim.lsp.action["source.organizeImports"],
desc = "Organize Imports",
},
{
"<leader>cM",
function()
require("vtsls").commands.add_missing_imports(0)
end,
LazyVim.lsp.action["source.addMissingImports.ts"],
desc = "Add missing imports",
},
{
"<leader>cu",
function()
require("vtsls").commands.remove_unused_imports(0)
end,
LazyVim.lsp.action["source.removeUnused.ts"],
desc = "Remove unused imports",
},
{
"<leader>cD",
function()
require("vtsls").commands.fix_all(0)
end,
LazyVim.lsp.action["source.fixAll.ts"],
desc = "Fix all diagnostics",
},
{
"<leader>cV",
function()
require("vtsls").commands.select_ts_version(0)
LazyVim.lsp.execute({ command = "typescript.selectTypeScriptVersion" })
end,
desc = "Select TS workspace version",
},

View file

@ -118,6 +118,7 @@ return {
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" },
{ "<leader>tw", function() require("neotest").watch.toggle(vim.fn.expand("%")) end, desc = "Toggle Watch" },
},
},
{

View file

@ -34,6 +34,9 @@ return {
for name, linter in pairs(opts.linters) do
if type(linter) == "table" and type(lint.linters[name]) == "table" then
lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter)
if type(linter.prepend_args) == "table" then
vim.list_extend(lint.linters[name].args, linter.prepend_args)
end
else
lint.linters[name] = linter
end

View file

@ -27,21 +27,7 @@ function M.get()
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } },
{ "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" },
{
"<leader>cA",
function()
vim.lsp.buf.code_action({
context = {
only = {
"source",
},
diagnostics = {},
},
})
end,
desc = "Source Action",
has = "codeAction",
},
{ "<leader>cA", LazyVim.lsp.action.source, desc = "Source Action", has = "codeAction" },
{ "]]", function() LazyVim.lsp.words.jump(vim.v.count1) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end },
{ "[[", function() LazyVim.lsp.words.jump(-vim.v.count1) end, has = "documentHighlight",

View file

@ -37,7 +37,9 @@ M.ns = vim.api.nvim_create_namespace("lazyvim.extras")
---@type string[]
M.state = nil
---@param opts {ft?: string|string[], root?: string|string[]}
---@alias WantsOpts {ft?: string|string[], root?: string|string[]}
---@param opts WantsOpts
---@return boolean
function M.wants(opts)
if opts.ft then
@ -105,10 +107,12 @@ function M.get_extra(source, modname)
table.sort(plugins)
table.sort(optional)
---@type boolean|(fun():boolean?)|nil
---@type boolean|(fun():boolean?)|nil|WantsOpts
local recommended = require(modname).recommended or false
if type(recommended) == "function" then
recommended = recommended() or false
elseif type(recommended) == "table" then
recommended = M.wants(recommended)
end
---@type LazyExtra

View file

@ -324,4 +324,37 @@ function M.words.jump(count, cycle)
end
end
M.action = setmetatable({}, {
__index = function(_, action)
return function()
vim.lsp.buf.code_action({
apply = true,
context = {
only = { action },
diagnostics = {},
},
})
end
end,
})
---@class LspCommand: lsp.ExecuteCommandParams
---@field open? boolean
---@param opts LspCommand
function M.execute(opts)
local params = {
command = opts.command,
arguments = opts.arguments,
}
if opts.open then
require("trouble").open({
mode = "lsp_command",
params = params,
})
else
return vim.lsp.buf_request(0, "workspace/executeCommand", params)
end
end
return M

View file

@ -5,7 +5,6 @@ _G.LazyVim = require("lazyvim.util")
describe("Extra", function()
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
assert(vim.tbl_count(Config.plugins) > 0, "Lazy not properly setup")
---@type {modname:string, modpath:string}[]
@ -19,8 +18,13 @@ describe("Extra", function()
return name:match("%.lua$")
end, { limit = math.huge, type = "file", path = "lua/lazyvim/plugins/extras" })
)
local ignore = { "lazyvim.plugins.extras.ui.treesitter-rewrite" }
extras = vim.tbl_filter(function(extra)
return not vim.tbl_contains(ignore, extra.modname)
end, extras)
local lsp_to_pkg = require("mason-lspconfig.mappings.server").lspconfig_to_package
local pkg_to_lsp = require("mason-lspconfig.mappings.server").package_to_lspconfig
local tsspec = Plugin.Spec.new({
import = "lazyvim.plugins.treesitter",
@ -32,27 +36,37 @@ describe("Extra", function()
assert(type(tsensure) == "table", "No ensure_installed in nvim-treesitter spec")
for _, extra in ipairs(extras) do
it(extra.modname .. " is valid", function()
local mod = require(extra.modname)
local spec = Plugin.Spec.new({
{ "williamboman/mason.nvim", opts = { ensure_installed = {} } },
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
mod,
}, { optional = true })
assert.is_not_nil(mod)
assert(#spec.notifs == 0, "Invalid spec: " .. vim.inspect(spec.notifs))
local name = extra.modname:sub(#"lazyvim.plugins.extras" + 2)
describe(name, function()
---@type any, LazySpecLoader
local mod, spec
it("spec is valid", function()
mod = require(extra.modname)
assert.is_not_nil(mod)
spec = Plugin.Spec.new({
{ "williamboman/mason.nvim", opts = { ensure_installed = {} } },
{ "nvim-treesitter/nvim-treesitter", opts = { ensure_installed = {} } },
mod,
}, { optional = true })
assert(#spec.notifs == 0, "Invalid spec: " .. vim.inspect(spec.notifs))
end)
if extra.modname:find("%.lang%.") then
assert(mod.recommended, "`recommended` not set for " .. extra.modname)
local lspconfig = spec.plugins["nvim-lspconfig"]
it("has recommended set", function()
assert(mod.recommended, "`recommended` not set for " .. extra.modname)
end)
end
if lspconfig then
local lspconfig = spec.plugins["nvim-lspconfig"]
if lspconfig then
it("does not install LSP servers with mason.nvim", function()
local lspconfig_opts = Plugin.values(lspconfig, "opts", false)
local mason = spec.plugins["mason.nvim"]
local mason_opts = Plugin.values(mason, "opts", false)
for lsp in pairs(lspconfig_opts.servers or {}) do
local lsp_pkg = pkg_to_lsp[lsp]
local lsp_pkg = lsp_to_pkg[lsp]
assert(
not (lsp_pkg and vim.tbl_contains(mason_opts.ensure_installed, lsp_pkg)),
"LSP server "
@ -62,15 +76,23 @@ describe("Extra", function()
.. " is installed automatically. Please remove from the mason.nvim spec"
)
end
end
local ts = spec.plugins["nvim-treesitter"]
local opts = Plugin.values(ts, "opts", false)
for _, v in ipairs(opts.ensure_installed) do
assert(
not vim.tbl_contains(tsensure, v),
"TS lang " .. v .. " is already a default. Please remove from the mason.nvim spec"
end)
end
local ts = spec.plugins["nvim-treesitter"]
local opts = Plugin.values(ts, "opts", false)
if not vim.tbl_isempty(opts.ensure_installed) then
it("does not install defaut Treesitter langs", function()
local invalid = vim.tbl_filter(function(v)
return vim.tbl_contains(tsensure, v)
end, opts.ensure_installed or {})
assert.same(
{},
invalid,
"These Treesitter langs are installed by default. Please remove them from the extra."
)
end
end)
end
end)
end

View file

@ -21,6 +21,7 @@ local plugins = {
{ "folke/lazy.nvim" },
"williamboman/mason-lspconfig.nvim",
"williamboman/mason.nvim",
"nvim-treesitter/nvim-treesitter",
}
local function main()