Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(lspconfig): function for default server config #45

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 19 additions & 35 deletions .config/nvim/lua/josean/plugins/lsp/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,26 @@ return {
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end

-- configure html server
lspconfig["html"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure typescript server with plugin
lspconfig["tsserver"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure css server
lspconfig["cssls"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure tailwindcss server
lspconfig["tailwindcss"].setup({
capabilities = capabilities,
on_attach = on_attach,
})
-- configure list of servers with default configs
local servers = {
"html",
"tsserver",
"cssls",
"tsserver",
"tailwindcss",
"prismals",
"pyright",
}

for _, lsp in ipairs(servers) do
lspconfig[lsp].setup({
capabilities = capabilities,
on_attach = on_attach,
})
end

-- Here the servers with custom configs.
--
-- configure svelte server
lspconfig["svelte"].setup({
capabilities = capabilities,
Expand All @@ -111,12 +107,6 @@ return {
end,
})

-- configure prisma orm server
lspconfig["prismals"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure graphql language server
lspconfig["graphql"].setup({
capabilities = capabilities,
Expand All @@ -131,12 +121,6 @@ return {
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
})

-- configure python server
lspconfig["pyright"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure lua server (with special settings)
lspconfig["lua_ls"].setup({
capabilities = capabilities,
Expand Down