Closed peter-lyons-kehl closed 9 months ago
For anyone new to this: https://github.com/crate-ci/typos/issues/263.
AFAICT there isn't a way for language servers to talk to each other (when connected to the same client). Nor can I see a way to receive events from the client about the syntax tree.
So unfortunately that leaves:
Thank you so much. I'm subscribing to that rust-analyzer
feature issue & discussion.
Happy New Year.
This is a feature request for typed/compiled languages only (examples below are in Rust). I admit I don't know how this works with/in VS Code, so this may not be easy/feasible.
Since
typos-vscode
mentions LSP, I hope that it could offer an option, when it would check with LSP (rust-analyzer
for Rust) whether a symbol is being defined (rather than used), and it would check the spelling only at definition points. (This would add more CPU load, but it would also reduce CPU load.)The simple examples:
Side note: None of all VS Code spell checkers that I've tried can do this (because they don't work with LSP; the maximum they allow is custom regex filters, but that can't cover nested
{...{...}...}
blocks, plus bracket characters{
and}
in string/char constants, comments....).That would minimize repeated reports, and also eliminate reports of misspellings from 3rd party (std/imported Rust crates).
Example for Rust projects:
let, const, static
variable/place names (but not types) - initially not in any/complex pattern matching,type
alias target (but not the type definition/expansion that this sets the alias to),struct, union
name and field names (but not field types),impl
, but excludingimpl ... for ...
,fn
name, parameter names, body for all the above (but excluded inimpl ... for ...
). Again, no/little pattern matching in function parameters (as feasible).match ... { pattern => ...}
variable/place names in pattern - if, and as, feasibleuse xyz
; yes for source ofuse xyz as pqr
aliases; groupingsuse std::{collections::{...}, ...}
only as feasible).If the above is too complex to do language-agnostic, could
typos-vscode
do it and specialize on per-LSP basis? For example, with Rust, could it talk torust-analyzer
(since it's the only mainstream Rust LSP, and RLS is now deprecated)?And/or, could
rust-analyzer
somehow check withtypos-vscode
instead?