feat: add lspconfig default handler

This commit is contained in:
SamuraX 2023-09-30 23:22:08 -03:00
parent d35558eb2b
commit f19e254a64

View file

@ -70,36 +70,23 @@ return {
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end end
-- configure html server local function default_handler(server_name, capabilities)
lspconfig["html"].setup({ require("lspconfig")[server_name].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
}) })
end
-- configure typescript server with plugin lspconfig.setup_handlers({
lspconfig["tsserver"].setup({ function(server_name)
capabilities = capabilities, default_handler(server_name, capabilities)
on_attach = on_attach, end,
}) -- configure svelte language server
["svelte"] = function()
-- configure css server lspconfig.svelte.setup({
lspconfig["cssls"].setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- configure tailwindcss server
lspconfig["tailwindcss"].setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- configure svelte server
lspconfig["svelte"].setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
on_attach(client, bufnr) on_attach(client, bufnr)
vim.api.nvim_create_autocmd("BufWritePost", { vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*.js", "*.ts" }, pattern = { "*.js", "*.ts" },
callback = function(ctx) callback = function(ctx)
@ -110,38 +97,29 @@ return {
}) })
end, end,
}) })
end,
-- configure prisma orm server
lspconfig["prismals"].setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- configure graphql language server -- configure graphql language server
lspconfig["graphql"].setup({ ["graphql"] = function()
lspconfig.graphql.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" }, filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
}) })
end,
-- configure emmet language server -- configure emmet language server
lspconfig["emmet_ls"].setup({ ["emmet_ls"] = function()
lspconfig.emmet_ls.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" }, filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
}) })
end,
-- configure python server
lspconfig["pyright"].setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- configure lua server (with special settings) -- configure lua server (with special settings)
lspconfig["lua_ls"].setup({ ["lua_ls"] = function()
lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
settings = { -- custom settings for lua settings = {
Lua = { Lua = {
-- make the language server recognize "vim" global -- make the language server recognize "vim" global
diagnostics = { diagnostics = {
@ -158,4 +136,6 @@ return {
}, },
}) })
end, end,
})
end,
} }