2024-10-27 16:21:40 +00:00
|
|
|
return {
|
2024-10-28 14:00:13 +00:00
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
event = { "BufReadPre", "BufNewFile" },
|
|
|
|
dependencies = {
|
|
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
|
|
{ "folke/neodev.nvim", opts = {} },
|
|
|
|
},
|
|
|
|
config = function()
|
|
|
|
local nvim_lsp = require("lspconfig")
|
|
|
|
local mason_lspconfig = require("mason-lspconfig")
|
|
|
|
local on_attach = function(client, bufnr)
|
|
|
|
-- format on save
|
|
|
|
if client.server_capabilities.documentFormattingProvider then
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
|
|
group = vim.api.nvim_create_augroup("Format", { clear = true }),
|
|
|
|
buffer = bufnr,
|
|
|
|
callback = function()
|
|
|
|
vim.lsp.buf.format()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
2024-10-27 16:21:40 +00:00
|
|
|
|
2024-10-28 14:00:13 +00:00
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities()
|
|
|
|
mason_lspconfig.setup_handlers({
|
|
|
|
function(server)
|
|
|
|
nvim_lsp[server].setup({
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["ts_ls"] = function()
|
|
|
|
nvim_lsp["ts_ls"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["cssls"] = function()
|
|
|
|
nvim_lsp["cssls"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["html"] = function()
|
|
|
|
nvim_lsp["html"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["jsonls"] = function()
|
|
|
|
nvim_lsp["jsonls"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["eslint"] = function()
|
|
|
|
nvim_lsp["eslint"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
["pyright"] = function()
|
|
|
|
nvim_lsp["pyright"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
2024-10-27 16:21:40 +00:00
|
|
|
|
2024-10-28 14:00:13 +00:00
|
|
|
["marksman"] = function()
|
|
|
|
nvim_lsp["marksman"].setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
2024-10-27 16:21:40 +00:00
|
|
|
}
|