Skip to content

Commit

Permalink
changed config to work
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredosdpiii committed Sep 5, 2023
1 parent b72024b commit 595c283
Showing 1 changed file with 20 additions and 22 deletions.
42 changes: 20 additions & 22 deletions lua/plugins/typescript.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,31 @@ return {
opts = {
servers = {
tsserver = {
setup = {
handlers = {
["textDocument/publishDiagnostics"] = function(_, result, ctx, config)
if result.diagnostics == nil then
return
end
handlers = {
["textDocument/publishDiagnostics"] = function(_, result, ctx, config)
if result.diagnostics == nil then
return
end

-- ignore some tsserver diagnostics
local idx = 1
while idx <= #result.diagnostics do
local entry = result.diagnostics[idx]
-- ignore some tsserver diagnostics
local idx = 1
while idx <= #result.diagnostics do
local entry = result.diagnostics[idx]

local formatter = require("format-ts-errors")[entry.code]
entry.message = formatter and formatter(entry.message) or entry.message
local formatter = require("format-ts-errors")[entry.code]
entry.message = formatter and formatter(entry.message) or entry.message

-- codes: https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
if entry.code == 80001 then
-- { message = "File is a CommonJS module; it may be converted to an ES module.", }
table.remove(result.diagnostics, idx)
else
idx = idx + 1
end
-- codes: https://github.com/microsoft/TypeScript/blob/main/src/compiler/diagnosticMessages.json
if entry.code == 80001 then
-- { message = "File is a CommonJS module; it may be converted to an ES module.", }
table.remove(result.diagnostics, idx)
else
idx = idx + 1
end
end

vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx, config)
end,
},
vim.lsp.diagnostic.on_publish_diagnostics(_, result, ctx, config)
end,
},
},
},
Expand Down

0 comments on commit 595c283

Please sign in to comment.