mirror of
https://github.com/DefectingCat/nvim
synced 2025-07-15 16:51:33 +00:00
update plugins breaking changes
This commit is contained in:
@ -11,12 +11,13 @@ local function organize_imports()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local mason_registry = require("mason-registry")
|
local mason_registry = require("mason-registry")
|
||||||
local has_volar, volar = pcall(mason_registry.get_package, "vue-language-server")
|
local has_volar, _ = pcall(mason_registry.get_package, "vue-language-server")
|
||||||
|
|
||||||
-- npm i -g @vue/typescript-plugin
|
-- npm i -g @vue/typescript-plugin
|
||||||
local vue_language_server_path
|
local vue_language_server_path
|
||||||
if has_volar then
|
if has_volar then
|
||||||
vue_language_server_path = volar:get_install_path() .. "/node_modules/@vue/language-server"
|
-- vue_language_server_path = volar:get_install_path() .. "/node_modules/@vue/language-server"
|
||||||
|
vue_language_server_path = vim.fn.expand("$MASON/packages/vue-language-server/node_modules/@vue/language-server")
|
||||||
end
|
end
|
||||||
|
|
||||||
local M = {
|
local M = {
|
||||||
|
@ -5,14 +5,14 @@ return {
|
|||||||
{ "hrsh7th/cmp-nvim-lsp" },
|
{ "hrsh7th/cmp-nvim-lsp" },
|
||||||
-- { "antosha417/nvim-lsp-file-operations", config = true },
|
-- { "antosha417/nvim-lsp-file-operations", config = true },
|
||||||
-- { "folke/neodev.nvim", opts = {} },
|
-- { "folke/neodev.nvim", opts = {} },
|
||||||
"williamboman/mason-lspconfig.nvim",
|
"mason-org/mason-lspconfig.nvim",
|
||||||
},
|
},
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = { document_highlight = { enabled = false } },
|
opts = { document_highlight = { enabled = false } },
|
||||||
config = function()
|
config = function()
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
local mason_lspconfig = require("mason-lspconfig")
|
local mason_lspconfig = require("mason-lspconfig")
|
||||||
local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
-- local cmp_nvim_lsp = require("cmp_nvim_lsp")
|
||||||
local map = vim.keymap.set -- for conciseness
|
local map = vim.keymap.set -- for conciseness
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("LspAttach", {
|
vim.api.nvim_create_autocmd("LspAttach", {
|
||||||
@ -21,19 +21,31 @@ return {
|
|||||||
local opts = { buffer = ev.buf, silent = true }
|
local opts = { buffer = ev.buf, silent = true }
|
||||||
|
|
||||||
opts.desc = "Show LSP references"
|
opts.desc = "Show LSP references"
|
||||||
map("n", "gr", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
|
map("n", "gr", function()
|
||||||
|
require("telescope.builtin").lsp_references()
|
||||||
|
end, opts) -- show definition, references
|
||||||
|
|
||||||
opts.desc = "Go to declaration"
|
opts.desc = "Go to declaration"
|
||||||
map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
|
map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
|
||||||
|
|
||||||
opts.desc = "Show LSP definitions"
|
opts.desc = "Show LSP definitions"
|
||||||
map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
-- map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
|
||||||
|
-- map("n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts) -- show lsp definitions
|
||||||
|
map("n", "gd", function()
|
||||||
|
require("telescope.builtin").lsp_definitions()
|
||||||
|
end, opts) -- show lsp definitions
|
||||||
|
|
||||||
opts.desc = "Show LSP implementations"
|
opts.desc = "Show LSP implementations"
|
||||||
map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
-- map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
|
||||||
|
map("n", "gi", function()
|
||||||
|
require("telescope.builtin").lsp_implementations()
|
||||||
|
end, opts) -- show lsp implementations
|
||||||
|
|
||||||
opts.desc = "Show LSP type definitions"
|
opts.desc = "Show LSP type definitions"
|
||||||
map("n", "<leader>gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
|
-- map("n", "<leader>gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
|
||||||
|
map("n", "<leader>gt", function()
|
||||||
|
require("telescope.builtin").lsp_type_definitions()
|
||||||
|
end, opts) -- show lsp type definitions
|
||||||
|
|
||||||
opts.desc = "See available code actions"
|
opts.desc = "See available code actions"
|
||||||
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
|
||||||
@ -42,7 +54,10 @@ return {
|
|||||||
map("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
map("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
|
||||||
|
|
||||||
opts.desc = "Show buffer diagnostics"
|
opts.desc = "Show buffer diagnostics"
|
||||||
map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
-- map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
|
||||||
|
map("n", "<leader>D", function()
|
||||||
|
require("telescope.builtin").diagnostics()
|
||||||
|
end, opts) -- show diagnostics for file
|
||||||
|
|
||||||
-- opts.desc = "Show line diagnostics"
|
-- opts.desc = "Show line diagnostics"
|
||||||
-- map("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
-- map("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
|
||||||
@ -62,7 +77,7 @@ return {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
local capabilities = cmp_nvim_lsp.default_capabilities()
|
-- local capabilities = cmp_nvim_lsp.default_capabilities()
|
||||||
|
|
||||||
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
local signs = { Error = " ", Warn = " ", Hint = " ", Info = " " }
|
||||||
for type, icon in pairs(signs) do
|
for type, icon in pairs(signs) do
|
||||||
@ -70,117 +85,250 @@ return {
|
|||||||
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
|
||||||
end
|
end
|
||||||
|
|
||||||
mason_lspconfig.setup_handlers({
|
mason_lspconfig.setup({
|
||||||
-- default handler for installed servers
|
automatic_enable = {
|
||||||
function(server_name)
|
exclude = {
|
||||||
lspconfig[server_name].setup({
|
"biome",
|
||||||
capabilities = capabilities,
|
"dockerls",
|
||||||
})
|
"tailwindcss",
|
||||||
end,
|
"rust_analyzer",
|
||||||
["biome"] = function()
|
"taplo",
|
||||||
lspconfig["biome"].setup({
|
"denols",
|
||||||
capabilities = capabilities,
|
"vtsls",
|
||||||
settings = {
|
"jsonls",
|
||||||
cmd = { "biome", "lsp-proxy" },
|
"lua_ls",
|
||||||
filetypes = {
|
},
|
||||||
"astro",
|
},
|
||||||
"css",
|
})
|
||||||
"graphql",
|
vim.lsp.enable("biome")
|
||||||
"javascript",
|
vim.lsp.config("biome", {
|
||||||
"javascriptreact",
|
settings = {
|
||||||
"json",
|
cmd = { "biome", "lsp-proxy" },
|
||||||
"jsonc",
|
filetypes = {
|
||||||
"svelte",
|
"astro",
|
||||||
"typescript",
|
"css",
|
||||||
"typescript.tsx",
|
"graphql",
|
||||||
"typescriptreact",
|
"javascript",
|
||||||
"vue",
|
"javascriptreact",
|
||||||
"markdown",
|
"json",
|
||||||
},
|
"jsonc",
|
||||||
single_file_support = true,
|
"svelte",
|
||||||
},
|
"typescript",
|
||||||
})
|
"typescript.tsx",
|
||||||
end,
|
"typescriptreact",
|
||||||
["dockerls"] = function()
|
"vue",
|
||||||
lspconfig["dockerls"].setup({
|
"markdown",
|
||||||
settings = {
|
},
|
||||||
docker = {
|
single_file_support = true,
|
||||||
languageserver = {
|
},
|
||||||
formatter = {
|
})
|
||||||
ignoreMultilineInstructions = true,
|
vim.lsp.enable("dockerls")
|
||||||
},
|
vim.lsp.config("dockerls", {
|
||||||
},
|
settings = {
|
||||||
|
docker = {
|
||||||
|
languageserver = {
|
||||||
|
formatter = {
|
||||||
|
ignoreMultilineInstructions = true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
end,
|
},
|
||||||
["tailwindcss"] = function()
|
})
|
||||||
lspconfig["tailwindcss"].setup(require("rua.config.tailwindcss"))
|
vim.lsp.enable("tailwindcss")
|
||||||
end,
|
vim.lsp.config("tailwindcss", {
|
||||||
["rust_analyzer"] = function()
|
settings = require("rua.config.tailwindcss"),
|
||||||
-- lspconfig["rust_analyzer"].setup(require("rua.config.rust-analyzer"))
|
})
|
||||||
end,
|
-- vim.lsp.config("rust_analyzer", {})
|
||||||
["taplo"] = function()
|
vim.lsp.enable("taplo")
|
||||||
lspconfig["taplo"].setup({
|
vim.lsp.config("taplo", {
|
||||||
keys = {
|
settings = {
|
||||||
{
|
keys = {
|
||||||
"gh",
|
{
|
||||||
function()
|
"gh",
|
||||||
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
|
function()
|
||||||
require("crates").show_popup()
|
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
|
||||||
else
|
require("crates").show_popup()
|
||||||
vim.lsp.buf.hover()
|
else
|
||||||
end
|
vim.lsp.buf.hover()
|
||||||
end,
|
end
|
||||||
desc = "Show Crate Documentation",
|
end,
|
||||||
},
|
desc = "Show Crate Documentation",
|
||||||
},
|
},
|
||||||
})
|
},
|
||||||
end,
|
},
|
||||||
["denols"] = function()
|
})
|
||||||
lspconfig["denols"].setup({
|
vim.lsp.enable("denols")
|
||||||
-- on_attach = on_attach,
|
vim.lsp.config("denols", {
|
||||||
capabilities = capabilities,
|
settings = {
|
||||||
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
|
root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
|
||||||
})
|
},
|
||||||
end,
|
})
|
||||||
["vtsls"] = function()
|
local vtsls_settings = require("rua.config.vtsls")
|
||||||
lspconfig["vtsls"].setup(require("rua.config.vtsls"))
|
vim.lsp.enable("vtsls")
|
||||||
map("n", "<leader>co", "<cmd> OrganizeImports <CR>", { desc = "Organize imports" })
|
vim.lsp.config("vtsls", vtsls_settings)
|
||||||
end,
|
vim.lsp.enable("jsonls")
|
||||||
["jsonls"] = function()
|
vim.lsp.config("jsonls", {
|
||||||
lspconfig["jsonls"].setup({
|
settings = {
|
||||||
-- lazy-load schemastore when needed
|
json = {
|
||||||
on_new_config = function(new_config)
|
format = {
|
||||||
new_config.settings.json.schemas = new_config.settings.json.schemas or {}
|
enable = true,
|
||||||
vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
|
|
||||||
end,
|
|
||||||
settings = {
|
|
||||||
json = {
|
|
||||||
format = {
|
|
||||||
enable = true,
|
|
||||||
},
|
|
||||||
validate = { enable = true },
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
validate = { enable = true },
|
||||||
end,
|
},
|
||||||
["lua_ls"] = function()
|
},
|
||||||
lspconfig["lua_ls"].setup({
|
on_new_config = function(new_config)
|
||||||
capabilities = capabilities,
|
new_config.settings.json.schemas = new_config.settings.json.schemas or {}
|
||||||
settings = {
|
vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
|
||||||
Lua = {
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
|
||||||
completion = {
|
|
||||||
callSnippet = "Replace",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
vim.lsp.enable("lua_ls")
|
||||||
|
vim.lsp.config("lua_ls", {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Luau = {
|
||||||
|
diagnostics = {
|
||||||
|
globals = { "vim" },
|
||||||
|
},
|
||||||
|
completion = {
|
||||||
|
callSnippet = "Replace",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Nvim 0.11+ (see vim.lsp.config)
|
||||||
|
-- vim.lsp.config('rust_analyzer', {
|
||||||
|
-- -- Server-specific settings. See `:help lsp-quickstart`
|
||||||
|
-- settings = {
|
||||||
|
-- ['rust-analyzer'] = {},
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- Nvim 0.10 (legacy, not supported)
|
||||||
|
-- local lspconfig = require('lspconfig')
|
||||||
|
-- lspconfig.rust_analyzer.setup {
|
||||||
|
-- -- Server-specific settings. See `:help lspconfig-setup`
|
||||||
|
-- settings = {
|
||||||
|
-- ['rust-analyzer'] = {},
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
-- mason_lspconfig.setup_handlers({
|
||||||
|
-- -- default handler for installed servers
|
||||||
|
-- function(server_name)
|
||||||
|
-- lspconfig[server_name].setup({
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["biome"] = function()
|
||||||
|
-- lspconfig["biome"].setup({
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- settings = {
|
||||||
|
-- cmd = { "biome", "lsp-proxy" },
|
||||||
|
-- filetypes = {
|
||||||
|
-- "astro",
|
||||||
|
-- "css",
|
||||||
|
-- "graphql",
|
||||||
|
-- "javascript",
|
||||||
|
-- "javascriptreact",
|
||||||
|
-- "json",
|
||||||
|
-- "jsonc",
|
||||||
|
-- "svelte",
|
||||||
|
-- "typescript",
|
||||||
|
-- "typescript.tsx",
|
||||||
|
-- "typescriptreact",
|
||||||
|
-- "vue",
|
||||||
|
-- "markdown",
|
||||||
|
-- },
|
||||||
|
-- single_file_support = true,
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["dockerls"] = function()
|
||||||
|
-- lspconfig["dockerls"].setup({
|
||||||
|
-- settings = {
|
||||||
|
-- docker = {
|
||||||
|
-- languageserver = {
|
||||||
|
-- formatter = {
|
||||||
|
-- ignoreMultilineInstructions = true,
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["tailwindcss"] = function()
|
||||||
|
-- lspconfig["tailwindcss"].setup(require("rua.config.tailwindcss"))
|
||||||
|
-- end,
|
||||||
|
-- ["rust_analyzer"] = function()
|
||||||
|
-- -- lspconfig["rust_analyzer"].setup(require("rua.config.rust-analyzer"))
|
||||||
|
-- end,
|
||||||
|
-- ["taplo"] = function()
|
||||||
|
-- lspconfig["taplo"].setup({
|
||||||
|
-- keys = {
|
||||||
|
-- {
|
||||||
|
-- "gh",
|
||||||
|
-- function()
|
||||||
|
-- if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
|
||||||
|
-- require("crates").show_popup()
|
||||||
|
-- else
|
||||||
|
-- vim.lsp.buf.hover()
|
||||||
|
-- end
|
||||||
|
-- end,
|
||||||
|
-- desc = "Show Crate Documentation",
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["denols"] = function()
|
||||||
|
-- lspconfig["denols"].setup({
|
||||||
|
-- -- on_attach = on_attach,
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- root_dir = lspconfig.util.root_pattern("deno.json", "deno.jsonc"),
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["vtsls"] = function()
|
||||||
|
-- lspconfig["vtsls"].setup(require("rua.config.vtsls"))
|
||||||
|
-- map("n", "<leader>co", "<cmd> OrganizeImports <CR>", { desc = "Organize imports" })
|
||||||
|
-- end,
|
||||||
|
-- ["jsonls"] = function()
|
||||||
|
-- lspconfig["jsonls"].setup({
|
||||||
|
-- -- lazy-load schemastore when needed
|
||||||
|
-- on_new_config = function(new_config)
|
||||||
|
-- new_config.settings.json.schemas = new_config.settings.json.schemas or {}
|
||||||
|
-- vim.list_extend(new_config.settings.json.schemas, require("schemastore").json.schemas())
|
||||||
|
-- end,
|
||||||
|
-- settings = {
|
||||||
|
-- json = {
|
||||||
|
-- format = {
|
||||||
|
-- enable = true,
|
||||||
|
-- },
|
||||||
|
-- validate = { enable = true },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- ["lua_ls"] = function()
|
||||||
|
-- lspconfig["lua_ls"].setup({
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- settings = {
|
||||||
|
-- Lua = {
|
||||||
|
-- diagnostics = {
|
||||||
|
-- globals = { "vim" },
|
||||||
|
-- },
|
||||||
|
-- completion = {
|
||||||
|
-- callSnippet = "Replace",
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- },
|
||||||
|
-- })
|
||||||
|
-- end,
|
||||||
|
-- })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"williamboman/mason.nvim",
|
"mason-org/mason.nvim",
|
||||||
-- event = "VeryLazy",
|
-- event = "VeryLazy",
|
||||||
cmd = {
|
cmd = {
|
||||||
"Mason",
|
"Mason",
|
||||||
|
Reference in New Issue
Block a user