Feat: Diagnostics table preprocess option.#21
Feat: Diagnostics table preprocess option.#21coreyb-git wants to merge 4 commits intoravibrock:mainfrom
Conversation
…igurable in opts.
…tics table before calling vim.diagnostic.set()
| end | ||
|
|
||
| -- Pre-process, if a function is set in opts to do anything. | ||
| diags = opts.func_preprocess(diags) |
There was a problem hiding this comment.
LGTM, would check length or nil before calling following.
There was a problem hiding this comment.
Should we also pass the bufnr to it?
There was a problem hiding this comment.
I figured if they change it from the default and it breaks then that's on them, and it should break so that they get hit with the errors.
Would you silently let if fail if it isn't assigned to a function? Or do some other one-time alert? I'm not sure the best way to go about this other than just let it fall on its face.
There was a problem hiding this comment.
It is not just about avoiding accidental errors; in fact, users may want to filter out all diagnostics entirely.
I'm not sure if vim.diagnostic.set can handle nil or {} correctly.
There was a problem hiding this comment.
Should we also pass the bufnr to it?
Probably a good idea.
There was a problem hiding this comment.
It is not just about avoiding accidental errors; in fact, users may want to filter out all diagnostics entirely.
I'm not sure if vim.diagnostic.set can handle nil or {} correctly.
I'm at the tail-end of a long day/night... let me know a bit more specifically what you mean, if possible?
There was a problem hiding this comment.
let me know a bit more specifically what you mean, if possible?
My consideration is to include return nil or zero length (empty list) as part of the contractual agreement for this function interface, to express the intent of "users wanting to silence all diagnostics".
There was a problem hiding this comment.
in the other PR I've altered it so that nil is converted to an empty table, where an empty table clears the diagnostics.
| local ft = vim.fn.getbufvar(bufnr, "&filetype") | ||
| if opts.ft_config[ft] == false or (opts.ft_config[ft] == nil and opts.ft_default == false) then | ||
| vim.diagnostic.reset(namespace, bufnr) | ||
| return | ||
| end |
There was a problem hiding this comment.
Maybe I'll just close both PR's and start a new one from my main branch that has the updates from both... this was fixed in the other PR, but is left-behind here by mistake.
| -- Pre-process, if a function is set in opts to do anything. | ||
| diags = opts.func_preprocess(diags) | ||
|
|
||
| -- TODO: Add suffix diagnostics with type of spelling error the way that LSP diagnostics do |
There was a problem hiding this comment.
I just see this here, if suffix present, I won't need different prefix. thx.
There was a problem hiding this comment.
Not sure I follow... that's your own code, or from some older PR :P
There was a problem hiding this comment.
Just realized you aren't ravi... my bad. Regardless, that TODO is not a part of anything I've done. You'll need to ask ravibrock about that.
There was a problem hiding this comment.
haha, Just realized you are not ravibrock too.
Yes, I requested a feat issue about that.
Have a good rest. I would help reviewing some code in PR #22.
|
Replaced by PR #22 |
Added opts.func_preprocess(table) for users who want to dig through the SpellWarn diagnostics and change anything before they are sent to vim.diagnostic.set.
Note: This PR also includes the buftype PR code.