Skip to content

LongYinStudio/ts-error-translator-plus.nvim

Repository files navigation

ts-error-translator-plus.nvim

简体中文 | English

截图

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

Installation

To install the plugin, use your preferred Neovim plugin manager.

lazy.nvim

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" },
}

Packer

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.

Setup

It is necessary to have either require("ts-error-translator-plus").setup(opts) or opts = {}.

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 = {

}

Configuration

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)
end

Contributing

Feel free to open issues or submit pull requests if you encounter any bugs or have suggestions for improvements. Your contributions are welcome!

License

This plugin is released under the MIT License. See the LICENSE file for details.

About

将复杂难懂的 TypeScript 错误信息(diagnostic)转换为简明中文和英文

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages