Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofix via documentFormattingProvider #20

Open
chrisgrieser opened this issue Nov 23, 2023 · 4 comments
Open

Autofix via documentFormattingProvider #20

chrisgrieser opened this issue Nov 23, 2023 · 4 comments

Comments

@chrisgrieser
Copy link

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
Copy link
Owner

tekumara commented Nov 23, 2023

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
Copy link
Author

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
Copy link
Owner

tekumara commented Nov 28, 2023

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
Copy link
Author

Yep, enabling it via setting should be good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants