mirror of
https://github.com/josean-dev/dev-environment-files.git
synced 2025-01-09 09:41:19 +01:00
feat: add lspconfig default handler
This commit is contained in:
parent
d35558eb2b
commit
f19e254a64
1 changed files with 60 additions and 80 deletions
|
@ -70,92 +70,72 @@ 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,
|
||||||
capabilities = capabilities,
|
on_attach = function(client, bufnr)
|
||||||
on_attach = on_attach,
|
on_attach(client, bufnr)
|
||||||
})
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
pattern = { "*.js", "*.ts" },
|
||||||
-- configure tailwindcss server
|
callback = function(ctx)
|
||||||
lspconfig["tailwindcss"].setup({
|
if client.name == "svelte" then
|
||||||
capabilities = capabilities,
|
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
|
||||||
on_attach = on_attach,
|
end
|
||||||
})
|
end,
|
||||||
|
})
|
||||||
-- configure svelte server
|
|
||||||
lspconfig["svelte"].setup({
|
|
||||||
capabilities = capabilities,
|
|
||||||
on_attach = function(client, bufnr)
|
|
||||||
on_attach(client, bufnr)
|
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufWritePost", {
|
|
||||||
pattern = { "*.js", "*.ts" },
|
|
||||||
callback = function(ctx)
|
|
||||||
if client.name == "svelte" then
|
|
||||||
client.notify("$/onDidChangeTsOrJsFile", { uri = ctx.file })
|
|
||||||
end
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
})
|
-- configure graphql language server
|
||||||
|
["graphql"] = function()
|
||||||
-- configure prisma orm server
|
lspconfig.graphql.setup({
|
||||||
lspconfig["prismals"].setup({
|
capabilities = capabilities,
|
||||||
capabilities = capabilities,
|
on_attach = on_attach,
|
||||||
on_attach = on_attach,
|
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
|
||||||
})
|
})
|
||||||
|
end,
|
||||||
-- configure graphql language server
|
-- configure emmet language server
|
||||||
lspconfig["graphql"].setup({
|
["emmet_ls"] = function()
|
||||||
capabilities = capabilities,
|
lspconfig.emmet_ls.setup({
|
||||||
on_attach = on_attach,
|
capabilities = capabilities,
|
||||||
filetypes = { "graphql", "gql", "svelte", "typescriptreact", "javascriptreact" },
|
on_attach = on_attach,
|
||||||
})
|
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
||||||
|
})
|
||||||
-- configure emmet language server
|
end,
|
||||||
lspconfig["emmet_ls"].setup({
|
-- configure lua server (with special settings)
|
||||||
capabilities = capabilities,
|
["lua_ls"] = function()
|
||||||
on_attach = on_attach,
|
lspconfig.lua_ls.setup({
|
||||||
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
|
capabilities = capabilities,
|
||||||
})
|
on_attach = on_attach,
|
||||||
|
settings = {
|
||||||
-- configure python server
|
Lua = {
|
||||||
lspconfig["pyright"].setup({
|
-- make the language server recognize "vim" global
|
||||||
capabilities = capabilities,
|
diagnostics = {
|
||||||
on_attach = on_attach,
|
globals = { "vim" },
|
||||||
})
|
},
|
||||||
|
workspace = {
|
||||||
-- configure lua server (with special settings)
|
-- make language server aware of runtime files
|
||||||
lspconfig["lua_ls"].setup({
|
library = {
|
||||||
capabilities = capabilities,
|
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
||||||
on_attach = on_attach,
|
[vim.fn.stdpath("config") .. "/lua"] = true,
|
||||||
settings = { -- custom settings for lua
|
},
|
||||||
Lua = {
|
},
|
||||||
-- make the language server recognize "vim" global
|
|
||||||
diagnostics = {
|
|
||||||
globals = { "vim" },
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
-- make language server aware of runtime files
|
|
||||||
library = {
|
|
||||||
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
|
|
||||||
[vim.fn.stdpath("config") .. "/lua"] = true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
})
|
||||||
},
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue