chore(nvim): consolidated lsp configs

This commit is contained in:
2023-09-08 00:45:36 +03:00
parent bc608cd578
commit 492cb4dbd8
9 changed files with 64 additions and 113 deletions

View File

@@ -120,26 +120,80 @@ mason_lspconfig.setup_handlers({
end,
})
-- Bash Language Server
require("lsp.bash")
-- eslint_d + prettierd
-- require 'lsp.eslint_d_prettierd'
-- Configure language servers for specific languages
local lspconfig = require("lspconfig")
-- Bash Language Server
lspconfig.bashls.setup({
cmd = {
"bash-language-server",
"start",
},
filetypes = { "sh", "zsh" },
capabilities = CAPABILITIES,
})
-- HTML
require("lsp.html")
lspconfig.html.setup({ capabilities = CAPABILITIES })
-- JSON
require("lsp.json")
lspconfig.jsonls.setup({
settings = {
json = {
schemas = require("schemastore").json.schemas(),
validate = { enable = true },
},
},
capabilities = CAPABILITIES,
})
-- Python
require("lsp.python")
lspconfig.pylsp.setup({})
-- CSS + Less + SCSS
require("lsp.scss")
lspconfig.cssls.setup({
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss", "less" },
-- root_dir = root_pattern("package.json", ".git") or bufdir,
settings = {
css = {
validate = true,
},
less = {
validate = true,
},
scss = {
validate = true,
},
},
single_file_support = true,
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})
-- rome
require("lsp.rome")
local util = require("lspconfig.util")
lspconfig.rome.setup({
root_dir = util.root_pattern("rome.json"),
single_file_support = true,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
capabilities = CAPABILITIES,
})
-- Typescript + Javascript
require("lsp.typescript")
lspconfig.tsserver.setup({
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})
lspconfig.lua_ls.setup({})
lspconfig.yamlls.setup({})

View File

@@ -1,8 +0,0 @@
require("lspconfig").bashls.setup({
cmd = {
"bash-language-server",
"start",
},
filetypes = { "sh", "zsh" },
capabilities = CAPABILITIES,
})

View File

@@ -1,25 +0,0 @@
local eslint = require("eslint")
local null_ls = require("null-ls")
-- local sources = { null_ls.builtins.formatting.prettierd }
null_ls.setup()
eslint.setup({
bin = "eslint_d",
code_actions = {
enable = true,
apply_on_save = {
enable = true,
types = { "directive", "problem", "suggestion", "layout" },
},
disable_rule_comment = {
enable = true,
location = "separate_line", -- or `same_line`
},
},
diagnostics = {
enable = true,
report_unused_disable_directives = false,
run_on = "type", -- or `save`
},
})

View File

@@ -1 +0,0 @@
require("lspconfig").html.setup({ capabilities = CAPABILITIES })

View File

@@ -1,9 +0,0 @@
require("lspconfig").jsonls.setup({
settings = {
json = {
schemas = require("schemastore").json.schemas(),
validate = { enable = true },
},
},
capabilities = CAPABILITIES,
})

View File

@@ -1 +0,0 @@
require("lspconfig").pylsp.setup({})

View File

@@ -1,31 +0,0 @@
local util = require("lspconfig.util")
-- local config = require 'lspconfig.configs'
-- This duplicate exec is just a workaruond, if don't execute at first,
-- the nvim will stuck when you first init rome socket
-- local rome_cmd = { 'rome', 'lsp-proxy' }
-- local merged_table = vim.tbl_extend("keep", {
-- textDocument = {
-- formatting = {
-- dynamicRegistration = true
-- }
-- }
-- }, capabilities);
--
require("lspconfig").rome.setup({
-- cmd = rome_cmd,
-- filetypes = {
-- 'javascript',
-- 'javascriptreact',
-- 'typescript',
-- 'typescriptreact',
-- 'json'
-- },
root_dir = util.root_pattern("rome.json"),
single_file_support = true,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
capabilities = CAPABILITIES,
})

View File

@@ -1,22 +0,0 @@
-- CSS + Less + SASS Language Server
require("lspconfig").cssls.setup({
cmd = { "vscode-css-language-server", "--stdio" },
filetypes = { "css", "scss", "less" },
-- root_dir = root_pattern("package.json", ".git") or bufdir,
settings = {
css = {
validate = true,
},
less = {
validate = true,
},
scss = {
validate = true,
},
},
single_file_support = true,
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})

View File

@@ -1,6 +0,0 @@
require("lspconfig").tsserver.setup({
capabilities = CAPABILITIES,
on_attach = function(client, bufnr)
if client.server_capabilities.documentSymbolProvider then require("nvim-navic").attach(client, bufnr) end
end,
})