-
-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lsp): add
ts-error-translator.nvim
with nice lazy loading (#774)
- Loading branch information
Showing
2 changed files
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# ts-error-translator.nvim | ||
|
||
A Neovim port of [Matt Pocock's ts-error-translator for VSCode](https://github.com/mattpocock/ts-error-translator) for turning messy and confusing TypeScript errors into plain English. | ||
|
||
**Repository:** <https://github.com/dmmulroy/ts-error-translator.nvim> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
return { | ||
-- TODO: move back to upstream after PR: https://github.com/dmmulroy/ts-error-translator.nvim/pull/18 | ||
-- "dmmulroy/ts-error-translator.nvim", | ||
"mehalter/ts-error-translator.nvim", | ||
branch = "reuse_existing_handler", | ||
lazy = true, | ||
dependencies = { | ||
"AstroNvim/astrolsp", | ||
---@param opts AstroLSPOpts | ||
opts = function(_, opts) | ||
if not opts.lsp_handlers then opts.lsp_handlers = {} end | ||
local event = "textDocument/publishDiagnostics" | ||
local orig = opts.lsp_handlers[event] or vim.lsp.handlers[event] | ||
opts.lsp_handlers[event] = function(err, result, ctx, config) | ||
local client = vim.lsp.get_client_by_id(ctx.client_id) | ||
if client and vim.tbl_contains({ "tsserver", "vtsls" }, client.name) then | ||
require("ts-error-translator").translate_diagnostics(err, result, ctx, config) | ||
end | ||
orig(err, result, ctx, config) | ||
end | ||
end, | ||
}, | ||
opts = { auto_override_publish_diagnostics = false }, | ||
} |