[nvim] condtionally load lsp if lsp exists
This commit is contained in:
parent
9adc33e45b
commit
892fc7a2df
|
@ -9,16 +9,7 @@ return {
|
|||
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
|
||||
local border = {
|
||||
{ "╭", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╮", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
{ "╯", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╰", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
}
|
||||
local border = "rounded"
|
||||
|
||||
vim.diagnostic.config({ virtual_text = false, float = { border = border } })
|
||||
|
||||
|
@ -61,40 +52,56 @@ return {
|
|||
vim.lsp.buf.execute_command(params)
|
||||
end
|
||||
|
||||
lspconfig.tsserver.setup({
|
||||
on_attach = on_attach,
|
||||
handlers = handlers,
|
||||
commands = {
|
||||
LspOrganizeImports = {
|
||||
organize_imports,
|
||||
description = "Organize Imports",
|
||||
local servers = {
|
||||
{
|
||||
"tsserver",
|
||||
commands = {
|
||||
LspOrganizeImports = {
|
||||
organize_imports,
|
||||
description = "Organize Imports",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
{ "tailwindcss" },
|
||||
{ "flow" },
|
||||
{ "graphql" },
|
||||
{ "html" },
|
||||
{ "intelephense" },
|
||||
{ "jsonls" },
|
||||
{ "pyright" },
|
||||
{ "vimls" },
|
||||
{ "prismals" },
|
||||
{ "solargraph" },
|
||||
{ "bashls" },
|
||||
{ "dockerls" },
|
||||
{ "gopls", {
|
||||
root_dir = function()
|
||||
return vim.loop.cwd()
|
||||
end,
|
||||
} },
|
||||
{ "yamlls" },
|
||||
{ "cssls" },
|
||||
}
|
||||
|
||||
-- lspconfig.eslint.setup{on_attach = on_attach, capabilities = capabilities, handlers = handlers}
|
||||
lspconfig.tailwindcss.setup({ on_attach = on_attach, capabilities = capabilities, handlers = handlers })
|
||||
lspconfig.flow.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.graphql.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.html.setup({ on_attach = on_attach, capabilities = capabilities, handlers = handlers })
|
||||
-- lspconfig.markdown.setup{on_attach = on_attach, capabilities = capabilities, handlers = handlers}
|
||||
lspconfig.intelephense.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.jsonls.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.pyright.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.vimls.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.prismals.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.solargraph.setup({ on_attach = on_attach, capabilities = capabilities, handlers = handlers })
|
||||
-- lspconfig.stylelint_lsp.setup{on_attach = on_attach, handlers = handlers}
|
||||
lspconfig.bashls.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.dockerls.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.gopls.setup({
|
||||
on_attach = on_attach,
|
||||
handlers = handlers,
|
||||
root_dir = function()
|
||||
return vim.loop.cwd()
|
||||
end,
|
||||
})
|
||||
lspconfig.yamlls.setup({ on_attach = on_attach, handlers = handlers })
|
||||
lspconfig.cssls.setup({ on_attach = on_attach, capabilities = capabilities, handlers = handlers })
|
||||
for _, server in pairs(servers) do
|
||||
local config = lspconfig[server[1]]
|
||||
-- Only setup a language server if we have the binary available!
|
||||
if vim.fn.executable(config.document_config.default_config.cmd[1]) == 1 then
|
||||
local opts = {
|
||||
on_attach = on_attach,
|
||||
handlers = handlers,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
|
||||
-- Add custom config if available
|
||||
for k, v in pairs(server) do
|
||||
if type(k) ~= "number" then
|
||||
opts[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
config.setup(opts)
|
||||
end
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ return {
|
|||
})
|
||||
end
|
||||
end,
|
||||
border = "single",
|
||||
sources = {
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.diagnostics.eslint,
|
||||
|
@ -63,32 +64,24 @@ return {
|
|||
null_ls.builtins.diagnostics.buf,
|
||||
null_ls.builtins.diagnostics.checkmake,
|
||||
null_ls.builtins.diagnostics.codespell,
|
||||
-- null_ls.builtins.diagnostics.cspell,
|
||||
-- null_ls.builtins.diagnostics.editorconfig_checker,
|
||||
null_ls.builtins.diagnostics.fish,
|
||||
null_ls.builtins.diagnostics.flake8,
|
||||
-- null_ls.builtins.diagnostics.gitlint,
|
||||
null_ls.builtins.diagnostics.golangci_lint,
|
||||
-- null_ls.builtins.diagnostics.hadolint,
|
||||
null_ls.builtins.diagnostics.jsonlint,
|
||||
null_ls.builtins.diagnostics.luacheck,
|
||||
null_ls.builtins.diagnostics.markdownlint,
|
||||
null_ls.builtins.formatting.markdownlint,
|
||||
-- null_ls.builtins.diagnostics.misspell,
|
||||
null_ls.builtins.diagnostics.mypy,
|
||||
null_ls.builtins.diagnostics.php,
|
||||
null_ls.builtins.diagnostics.pylint,
|
||||
null_ls.builtins.diagnostics.rubocop,
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
-- null_ls.builtins.diagnostics.standardrb,
|
||||
null_ls.builtins.diagnostics.stylelint,
|
||||
null_ls.builtins.diagnostics.tidy,
|
||||
-- null_ls.builtins.diagnostics.tsc,
|
||||
null_ls.builtins.diagnostics.yamllint,
|
||||
null_ls.builtins.formatting.autopep8,
|
||||
null_ls.builtins.formatting.beautysh,
|
||||
null_ls.builtins.formatting.black,
|
||||
-- null_ls.builtins.formatting.cbfmt,
|
||||
null_ls.builtins.formatting.erb_lint,
|
||||
null_ls.builtins.formatting.eslint,
|
||||
null_ls.builtins.formatting.fish_indent,
|
||||
|
@ -120,7 +113,6 @@ return {
|
|||
},
|
||||
}),
|
||||
null_ls.builtins.formatting.prismaFmt,
|
||||
-- null_ls.builtins.formatting.remark,
|
||||
null_ls.builtins.formatting.rubocop,
|
||||
null_ls.builtins.formatting.rustywind.with({
|
||||
filetypes = {
|
||||
|
@ -135,8 +127,6 @@ return {
|
|||
},
|
||||
}),
|
||||
null_ls.builtins.formatting.shfmt,
|
||||
-- null_ls.builtins.formatting.standardrb,
|
||||
-- null_ls.builtins.formatting.stylelint,
|
||||
null_ls.builtins.formatting.terraform_fmt,
|
||||
null_ls.builtins.formatting.yamlfmt,
|
||||
null_ls.builtins.formatting.tidy,
|
||||
|
|
Loading…
Reference in New Issue