A Neovim port of Matt Pocock's ts-error-translator for VSCode for turning messy and confusing TypeScript errors into plain English.
To install the plugin, use your preferred Neovim plugin manager.
To install the plugin using lazy.nvim, add the following to your plugin configuration:
{ 'dmmulroy/ts-error-translator.nvim' }
To install the plugin using packer.nvim, add the following to your plugin configuration:
use('dmmulroy/ts-error-translator.nvim',)
To install the plugin using vim-plug, add the following to your plugin configuration:
Plug 'dmmulroy/ts-error-translator.nvim'
Then run :PlugInstall
to install the plugin.
To set up the plugin, add the following line to where you manage your plugins:
require("ts-error-translator").setup()
By default, ts-error-translator.nvim
will attach itself to your tsserver
lsp and automatically start translating errors for you. The following is the
default configuration for the plugin:
{
auto_override_publish_diagnostics = true,
}
If you want to override tsserver
's textDocument/publishDiagnostics
handler
manually, ts-error-translator.nvim
exports a function,
require('ts-error-translator').translate_diagnostics
, that you can
then use to override your lsp handlers. Here is example usage:
vim.lsp.handlers["textDocument/publishDiagnostics"] = function(err, result, ctx, config)
require("ts-error-translator").translate_diagnostics(err, result, ctx, config)
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx, config)
end
If you like this plugin and find it useful, you might also like my plugin, tsc.nvim, a Neovim plugin for seamless, asynchronous project-wide TypeScript type-checking using the TypeScript compiler (tsc)
Feel free to open issues or submit pull requests if you encounter any bugs or have suggestions for improvements. Your contributions are welcome!
This plugin is released under the MIT License. See the LICENSE file for details.
A special thanks to Matt Pocock for creating the ts-error-translator
, providing the foundation for this project.