mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-27 03:09:07 +02:00
refactor(lsp): make servers easily configurable in overriding specs
This commit is contained in:
parent
5daf0cbe73
commit
8924f965d1
1 changed files with 14 additions and 16 deletions
|
@ -1,10 +1,3 @@
|
||||||
local servers = require("lazyvim.plugins.lsp.servers")
|
|
||||||
|
|
||||||
local function on_attach(client, bufnr)
|
|
||||||
require("lazyvim.plugins.lsp.format").on_attach(client, bufnr)
|
|
||||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, bufnr)
|
|
||||||
end
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
-- lspconfig
|
-- lspconfig
|
||||||
{
|
{
|
||||||
|
@ -13,16 +6,19 @@ return {
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||||
{ "folke/neodev.nvim", config = true },
|
{ "folke/neodev.nvim", config = true },
|
||||||
{
|
"mason.nvim",
|
||||||
"williamboman/mason.nvim",
|
|
||||||
config = true,
|
|
||||||
cmd = "Mason",
|
|
||||||
keys = { { "<leader>cm", "<cmd>Mason<cr>", desc = "Mason" } },
|
|
||||||
},
|
|
||||||
{ "williamboman/mason-lspconfig.nvim", config = { automatic_installation = true } },
|
{ "williamboman/mason-lspconfig.nvim", config = { automatic_installation = true } },
|
||||||
"hrsh7th/cmp-nvim-lsp",
|
"hrsh7th/cmp-nvim-lsp",
|
||||||
},
|
},
|
||||||
config = function()
|
---@type lspconfig.options
|
||||||
|
servers = nil,
|
||||||
|
config = function(plugin)
|
||||||
|
-- setup formatting and keymaps
|
||||||
|
require("lazyvim.util").on_attach(function(client, buffer)
|
||||||
|
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||||
|
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||||
|
end)
|
||||||
|
|
||||||
-- diagnostics
|
-- diagnostics
|
||||||
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
|
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do
|
||||||
name = "DiagnosticSign" .. name
|
name = "DiagnosticSign" .. name
|
||||||
|
@ -37,9 +33,11 @@ return {
|
||||||
|
|
||||||
-- lspconfig
|
-- lspconfig
|
||||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
|
||||||
|
---@type lspconfig.options
|
||||||
|
local servers = plugin.servers or require("lazyvim.plugins.lsp.servers")
|
||||||
for server, opts in pairs(servers) do
|
for server, opts in pairs(servers) do
|
||||||
opts.capabilities = capabilities
|
opts.capabilities = capabilities
|
||||||
opts.on_attach = on_attach
|
|
||||||
require("lspconfig")[server].setup(opts)
|
require("lspconfig")[server].setup(opts)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -49,10 +47,10 @@ return {
|
||||||
{
|
{
|
||||||
"jose-elias-alvarez/null-ls.nvim",
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
event = "BufReadPre",
|
event = "BufReadPre",
|
||||||
|
dependencies = { "mason.nvim" },
|
||||||
config = function()
|
config = function()
|
||||||
local nls = require("null-ls")
|
local nls = require("null-ls")
|
||||||
nls.setup({
|
nls.setup({
|
||||||
on_attach = on_attach,
|
|
||||||
sources = {
|
sources = {
|
||||||
-- nls.builtins.formatting.prettierd,
|
-- nls.builtins.formatting.prettierd,
|
||||||
nls.builtins.formatting.stylua,
|
nls.builtins.formatting.stylua,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue