tekumara / typos-lsp

Source code spell checker for Visual Studio Code, Neovim and other LSP clients
https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode
MIT License
157 stars 4 forks source link

Autofix via `documentFormattingProvider` #20

Open chrisgrieser opened 7 months ago

chrisgrieser commented 7 months ago

Commonly, LSPs provide formatting capabilities (documentFormattingProvider).

For typos, it could be useful be able to autofix misspellings via LSP-formatting. Essentially what typos --write-changes does, only triggered from inside the IDE.

tekumara commented 7 months ago

Heya, I hadn't thought of this because typos is often used with source code, which typically has its own document formatter. So in most cases I would expect the default formatter to be specific to the file type (eg: prettier for javascript). I can't think of a use-case or file type where you would want to use typos instead of a source code formatter?

chrisgrieser commented 7 months ago

No, not using typos instead of a source code formatter, but rather using typos in addition to the source code formatter. Not familiar with other editors, but in nvim, when I run vim.lsp.buf.format(), all attached LSPs that have formatting capability will run their formatting

tekumara commented 7 months ago

Ah thanks for the elaboration. You are using nvim. I use vscode which AFAIK doesn't have an "apply all formatters" command, so I wasn't aware this was a thing!

Because of the difference between editors, I don't think I'd want this enabled by default, but I can see a new config option that if set would offer the documentFormattingProvider. I presume you'd want this enabled for all file types?

chrisgrieser commented 7 months ago

Yep, enabling it via setting should be good