Closed andrew-t-james-core closed 6 months ago
I was wondering the same thing too. The following doesn't work:
return {
"pmizio/typescript-tools.nvim",
config = function()
require("typescript-tools").setup({
-- disable formatting because using `prettier`
on_attach = function(client, bufnr)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
handlers = {
["textDocument/publishDiagnostics"] = require("ts-error-translator").lsp_publish_diagnostics_override(),
},
})
end,
}
Hi, thanks for report and sorry for the issue - just merged a change that you can see here that should help with this: https://github.com/dmmulroy/ts-error-translator.nvim/pull/18
Give it a try with this new api:
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
thanks for taking a look unfortunately that didn't seem to resolve.
require("typescript-tools").setup({
on_attach = function(client)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
client.server_capabilities["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
end,
settings = {
-- array of strings("fix_all"|"add_missing_imports"|"remove_unused"|
-- "remove_unused_imports"|"organize_imports") -- or string "all"
-- to include all supported code actions
-- specify commands exposed as code_actions
expose_as_code_action = { "fix_all", "add_missing_imports", "remove_unused" },
-- spawn additional tsserver instance to calculate diagnostics on it
separate_diagnostic_server = true,
-- "change"|"insert_leave" determine when the client asks the server about diagnostic
publish_diagnostic_on = "insert_leave",
-- specify a list of plugins to load by tsserver, e.g., for support `styled-components`
-- (see 💅 `styled-components` support section)
tsserver_plugins = {},
-- this value is passed to: https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
-- memory limit in megabytes or "auto"(basically no limit)
tsserver_max_memory = "auto",
-- CodeLens
-- WARNING: Experimental feature also in VSCode, because it might hit performance of server.
-- possible values: ("off"|"all"|"implementations_only"|"references_only")
code_lens = "off",
-- by default code lenses are displayed on all referencable values and for some of you it can
-- be too much this option reduce count of them by removing member references from lenses
disable_member_code_lens = true,
-- described below
tsserver_format_options = {
allowIncompleteCompletions = true,
allowRenameOfImportPath = true,
},
tsserver_file_preferences = {
includeCompletionsForModuleExports = true,
includeInlayParameterNameHints = "all",
includeInlayParameterNameHintsWhenArgumentMatchesName = true,
includeInlayFunctionParameterTypeHints = true,
includeInlayVariableTypeHints = true,
includeInlayVariableTypeHintsWhenTypeMatchesName = true,
includeInlayPropertyDeclarationTypeHints = true,
includeInlayFunctionLikeReturnTypeHints = true,
includeInlayEnumMemberValueHints = true,
quotePreference = "auto",
},
handlers = {
-- because I don't want to format on save via typescript-tools
-- prefer other tools over typescript formatting
["textDocument/formatting"] = false,
["textDocument/rangeFormatting"] = false,
["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,
},
},
})
Could you see if #22 resolved this? It should hopefully Just Work™️ without extra config now as diagnostics will get passed onto it internally as a support LSP
I can confirm that it now works fine without any extra config!
return {
"dmmulroy/ts-error-translator.nvim",
config = true,
}
Awesome! Thank you!
Got closer this round, thanks for looking into this so quickly as well. Unfortunately couldn't override the existing lsp diagnostics and hit an error with the translation.
tsserver: Argument of type '{ completionUnit: CompletionUnits; completionAmmount: any; }' is not assignable to parameter of type '{ completionUnit?: CompletionUnits; }'.
Object literal may only specify known properties, but 'completionAmmount' does not exist in type '{ completionUnit?: CompletionUnits; }'. Did you mean to write 'completionUnit'?
TypeScript Error Translation(s):
• Something went wrong while translating your error. Please file an issue at https://github.com/dmmulroy/ts-error-translator.nvim and an example of the code that caused this error.
[2345]
This likely a separate bug related to #17 that I'm actively working on, so I hopefully soon will have fix up 🤞
Any insights on integrations for https://github.com/pmizio/typescript-tools.nvim. I tried overriding
textDocument/publishDiagnostics
as described in the documentation but unfortunately could not see the formatted error message. Curious if there is work to make this happen, happy to contribute if so.For example this is th outpuf of a
tsserver
error diagnostics message before and after attempting to connect this plugin.