Closed Picalines closed 6 days ago
updated with:
{
"davidosomething/format-ts-errors.nvim",
config = function()
require("format-ts-errors").setup({
add_markdown = true, -- wrap output with markdown ```ts ``` markers
start_indent_level = 0, -- initial indent
})
end,
}
lmk if that works
It seems like the TS blocks are not indented now
Not entirely sure what's happening, i'll share a better screenshot when i found one
if you could share the file as well it would help
Here's a short example:
type Obj1 = { field: number }
type Obj2 = { field: string }
const x: Obj1 = {field: 123}
const y: Obj2 = x
Current output is:
Type
```ts
Obj1
is not assignable to type
Obj2
Types of property 'field' are incompatible. Type
number
is not assignable to type
string
(2322)
The ` (2322)` is part of [neovim configuration](https://neovim.io/doc/user/diagnostic.html#vim.diagnostic.Opts.Float), it can be fixed on the user side
are you using start_indent_level = 0, -- initial indent
?
The default before this change was 1
are you using
start_indent_level = 0, -- initial indent
? The default before this change was1
Yes, i'm using start_indent_level = 0
remove that line or change it to start_indent_level = 1
to bring back initial indent
remove that line or change it to
start_indent_level = 1
to bring back initial indent
It produces the same result for the example i posted above
i am unable to replicate, can you post a minimal config?
here's what i see with start_indent_level = 1
Sorry, it turn's out that render-markdown plugin removes the indentation in code blocks
That's my output without the plugin:
Type
```ts
Obj1
is not assignable to type
Obj2
Types of property 'field' are incompatible. Type
number
is not assignable to type
string
@davidosomething
Is the `Types of property 'field' are incompatible` indented correctly? You can close the issue if that's intended
---
If anyone stumbles across this, you can turn off render-markdown's `indent` feature to keep the highlighting
Here's how i've configured neovim to render "Diagnostics" as markdown:
```lua
local builtin_open_float = vim.diagnostic.open_float
---@diagnostic disable-next-line: duplicate-set-field
vim.diagnostic.open_float = function(...)
local bufnr, winid = builtin_open_float(...)
if bufnr and winid then
vim.api.nvim_set_option_value('filetype', 'markdown', { buf = bufnr })
end
return bufnr, winid
end
And here's how to tell neovim not to apply DiagnosticError
highlight to the whole popup:
vim.diagnostic.config {
signs = {
-- text & numhl tables
},
float = {
-- NOTE: format can't return the highlight, so we use prefix & suffix without it
format = function() return '' end,
prefix = function(report)
local signs = vim.diagnostic.config().signs or {}
local icon = signs.text[report.severity]
return icon .. ' ', signs.numhl[report.severity]
end,
suffix = function(report)
local hl = 'Normal'
local message = vim.trim(report.user_data.lsp.message)
if string.find(message, '\n') then
return string.format('%s\n^ (%s)', message, report.code), hl
end
return string.format('%s (%s)', message, report.code), hl
end,
},
}
Is the
Types of property 'field' are incompatible
indented correctly? You can close the issue if that's intended
Yea, it comes newline+indented from typescript server.
It's possible to change the output of that as well using some regex to strip the extra indent, but the messaging changes between typescript versions so I'll leave it as an exercise to the user ;P
Thanks for using and following up on the issue!
Hi, great plugin!
It'd be nice if this plugin could wrap TS types in a markdown symbols, like:
Is not assignable to
number
Second approach is more difficult, because we'd need to choose what data to pass in function parameters (is
text
already prettified? How to handle nested indentation?)