4 files changed,
37 insertions(+),
16 deletions(-)
M
lua/lsp/config.lua
@@ -30,9 +30,14 @@
require("nvim-lsp-installer").on_server_ready(function(server) local opts = { on_attach = on_attach } - local ok, user_opts = pcall(require, "lsp.providers." .. server.name) - if ok then - opts = vim.tbl_deep_extend("force", opts, user_opts) + if server.name == "jsonls" then + opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.jsonls" or {}) + elseif server.name == "yamlls" then + opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.yamlls" or {}) + elseif server.name == "tsserver" then + opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.tsserver" or {}) + elseif server.name == "sumneko_lua" then + opts = vim.tbl_deep_extend("force", opts, require "lsp.providers.sumneko_lua" or {}) end server:setup(opts)
M
lua/lsp/providers/jsonls.lua
@@ -1,3 +1,12 @@
+return { + settings = { + schemas = { + { fileMatch = { "package.json" }, url = "https://json.schemastore.org/package.json" }, + }, + }, +} + +--[[ return { settings = { json = {@@ -35,4 +44,4 @@ },
}, }, }, -} +}]]
A
lua/lsp/providers/tsserver.lua
@@ -0,0 +1,19 @@
+return { + setup = { + handlers = { + ["textDocument/publishDiagnostics"] = function(_, _, p, id, _, cfg) + if p.diagnostics ~= nil then + local i = 1 + while i <= #p.diagnostics do + if p.diagnostics[i].code == 80001 then + table.remove(p.diagnostics, i) + else + i = i + 1 + end + end + end + vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, id, _, cfg) + end, + }, + }, +}