2022-12-30 17:30:52 +01:00
|
|
|
local servers = require("user.plugins.lsp.servers")
|
2022-12-30 23:35:27 +01:00
|
|
|
|
2022-12-30 17:30:52 +01:00
|
|
|
local function on_attach(client, bufnr)
|
|
|
|
require("user.plugins.lsp.format").on_attach(client, bufnr)
|
2022-12-30 18:56:34 +01:00
|
|
|
require("user.plugins.lsp.keymaps").on_attach(client, bufnr)
|
2022-12-30 17:30:52 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
-- lspconfig
|
|
|
|
{
|
|
|
|
"neovim/nvim-lspconfig",
|
|
|
|
event = "BufReadPre",
|
|
|
|
dependencies = {
|
|
|
|
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
|
|
|
{ "folke/neodev.nvim", config = true },
|
|
|
|
{ "williamboman/mason.nvim", config = true },
|
|
|
|
{ "williamboman/mason-lspconfig.nvim", config = { ensure_installed = vim.tbl_keys(servers) } },
|
|
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
|
|
},
|
|
|
|
config = function()
|
2022-12-30 23:35:27 +01:00
|
|
|
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
2022-12-30 17:30:52 +01:00
|
|
|
for server, opts in pairs(servers) do
|
2022-12-30 23:35:27 +01:00
|
|
|
opts.capabilities = capabilities
|
|
|
|
opts.on_attach = on_attach
|
2022-12-30 17:30:52 +01:00
|
|
|
require("lspconfig")[server].setup(opts)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
|
|
|
|
-- formatters
|
|
|
|
{
|
|
|
|
"jose-elias-alvarez/null-ls.nvim",
|
|
|
|
event = "BufReadPre",
|
|
|
|
config = function()
|
|
|
|
local nls = require("null-ls")
|
|
|
|
nls.setup({
|
|
|
|
on_attach = on_attach,
|
|
|
|
sources = {
|
|
|
|
-- nls.builtins.formatting.prettierd,
|
|
|
|
nls.builtins.formatting.stylua,
|
|
|
|
nls.builtins.diagnostics.flake8,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|