A Neovim plugin that converts complex and hard-to-understand TypeScript error messages into concise Chinese and English. Inspired by dmmulroy/ts-error-translator.nvim
To install the plugin, use your preferred Neovim plugin manager.
To install the plugin using lazy.nvim, add the following to your plugin configuration:
{
'LongYinStudio/ts-error-translator-plus.nvim'
opts = {
lang = "en", -- or zh-CN
auto_override_publish_diagnostics = true,
},
ft = { "typescript", "typescriptreact", "javascript", "javascriptreact", "vue" },
}To install the plugin using packer.nvim, add the following to your plugin configuration:
use{
'LongYinStudio/ts-error-translator-plus.nvim'
config = function()
require("ts-error-translator-plus").setup({
lang = "en", -- or zh-CN
auto_override_publish_diagnostics = true,
})
end
}It is recommended to install rachartier/tiny-inline-diagnostic.nvim.
It is necessary to have either
require("ts-error-translator-plus").setup(opts)oropts = {}.
To set up the plugin, add the following line to where you manage your plugins:
require("ts-error-translator-plus").setup(opts)
-- or lazy.nvim
opts = {
}By default, ts-error-translator-plus.nvim will attach itself to your typescript
lsp and automatically start translating errors for you. The following is the
default configuration for the plugin:
{
lang = "en",
auto_override_publish_diagnostics = true,
}If you want to override tyscript lsp's textDocument/publishDiagnostics handler
manually, ts-error-translator-plus.nvim exports a function,
require('ts-error-translator-plus').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)
require("ts-error-translator-plus").translate_diagnostics(err, result, ctx)
vim.lsp.diagnostic.on_publish_diagnostics(err, result, ctx)
endFeel 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.
