Skip to content

Commit

Permalink
feat(lsp): automatically enable all LSPs installed by mason
Browse files Browse the repository at this point in the history
  • Loading branch information
ecosse3 committed Oct 3, 2023
1 parent dfd83f2 commit 84e9837
Showing 1 changed file with 75 additions and 55 deletions.
130 changes: 75 additions & 55 deletions lua/lsp/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ mason_lsp.setup({
"jsonls",
"lua_ls",
"prismals",
"tailwindcss"
"tailwindcss",
"tsserver"
},
-- Whether servers that are set up (via lspconfig) should be automatically installed if they're not already installed.
-- This setting has no relation with the `ensure_installed` setting.
Expand Down Expand Up @@ -62,60 +63,79 @@ capabilities.textDocument.foldingRange = {
lineFoldingOnly = true,
}

-- Order matters

lspconfig.tailwindcss.setup({
capabilities = require("lsp.servers.tailwindcss").capabilities,
filetypes = require("lsp.servers.tailwindcss").filetypes,
handlers = handlers,
init_options = require("lsp.servers.tailwindcss").init_options,
on_attach = require("lsp.servers.tailwindcss").on_attach,
settings = require("lsp.servers.tailwindcss").settings,
})

lspconfig.cssls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = require("lsp.servers.cssls").on_attach,
settings = require("lsp.servers.cssls").settings,
})

lspconfig.eslint.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = require("lsp.servers.eslint").on_attach,
settings = require("lsp.servers.eslint").settings,
})

lspconfig.jsonls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = on_attach,
settings = require("lsp.servers.jsonls").settings,
})

lspconfig.lua_ls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = on_attach,
settings = require("lsp.servers.lua_ls").settings,
})

lspconfig.vuels.setup({
filetypes = require("lsp.servers.vuels").filetypes,
handlers = handlers,
init_options = require("lsp.servers.vuels").init_options,
on_attach = require("lsp.servers.vuels").on_attach,
settings = require("lsp.servers.vuels").settings,
})

for _, server in ipairs({ "bashls", "emmet_ls", "graphql", "html", "prismals" }) do
lspconfig[server].setup({
on_attach = on_attach,
capabilities = capabilities,
handlers = handlers,
})
end
require("mason-lspconfig").setup_handlers {
-- The first entry (without a key) will be the default handler
-- and will be called for each installed server that doesn't have
-- a dedicated handler.
function(server_name)
require("lspconfig")[server_name].setup {
on_attach = on_attach,
capabilities = capabilities,
handlers = handlers,
}
end,

["tsserver"] = function()
-- Skip since we use typescript-tools.nvim
end,

["tailwindcss"] = function()
lspconfig.tailwindcss.setup({
capabilities = require("lsp.servers.tailwindcss").capabilities,
filetypes = require("lsp.servers.tailwindcss").filetypes,
handlers = handlers,
init_options = require("lsp.servers.tailwindcss").init_options,
on_attach = require("lsp.servers.tailwindcss").on_attach,
settings = require("lsp.servers.tailwindcss").settings,
})
end,

["cssls"] = function()
lspconfig.cssls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = require("lsp.servers.cssls").on_attach,
settings = require("lsp.servers.cssls").settings,
})
end,

["eslint"] = function()
lspconfig.eslint.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = require("lsp.servers.eslint").on_attach,
settings = require("lsp.servers.eslint").settings,
})
end,

["jsonls"] = function()
lspconfig.jsonls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = on_attach,
settings = require("lsp.servers.jsonls").settings,
})
end,

["lua_ls"] = function()
lspconfig.lua_ls.setup({
capabilities = capabilities,
handlers = handlers,
on_attach = on_attach,
settings = require("lsp.servers.lua_ls").settings,
})
end,

["vuels"] = function ()
lspconfig.vuels.setup({
filetypes = require("lsp.servers.vuels").filetypes,
handlers = handlers,
init_options = require("lsp.servers.vuels").init_options,
on_attach = require("lsp.servers.vuels").on_attach,
settings = require("lsp.servers.vuels").settings,
})
end
}

require("ufo").setup({
fold_virt_text_handler = ufo_config_handler,
Expand Down

0 comments on commit 84e9837

Please sign in to comment.