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

autofixers #1212

Open
EvanCarroll opened this issue Apr 6, 2021 · 7 comments
Open

autofixers #1212

EvanCarroll opened this issue Apr 6, 2021 · 7 comments

Comments

@EvanCarroll
Copy link

Describe the solution you'd like

The ability to have :w run a "fixer" before hand.

Describe alternatives you've considered

If using using this project to replace ALE I can go to Formatting under the F5 tool and it'll run everything through rustfmt. I would like the ability to configure that to happen every time on :w though.

@martskins
Copy link
Collaborator

You should be able to configure an autocmd for that.
For example:
autocmd BufWritePre *.go,*.rust call LanguageClient#textDocument_formatting_sync() would run formatting on save for rust and go files.

@EvanCarroll
Copy link
Author

Cool for comparison in ale it looks like this,

let g:ale_fix_on_save = 1

@martskins
Copy link
Collaborator

Yeah, we could probably set something like that up, shouldn't be too hard. I think it was mostly a design decision, but I'm not opposed to the idea, I think it makes sense to make that easier for users considering how much everyone uses it.

@EvanCarroll
Copy link
Author

EvanCarroll commented Apr 6, 2021

I can see merit in providing the functionality or forcing people to do it the native vim way, but I'd document it either way. I looked for it before asking but I may have missed it.

@martskins
Copy link
Collaborator

Fwiw, adding the option would ultimately do it the same way, so it's not much of a big deal, it wouldn't be any different from any of the other options we provide already. Will see if I can add that at some point this week.

@EvanCarroll
Copy link
Author

EvanCarroll commented Apr 6, 2021

For reference when adding the option, I think the two variants that work

autocmd FileType rust autocmd BufWritePre <buffer> call LanguageClient#textDocument_formatting_sync()

or (with the extension)

autocmd BufWritePre *.rs call LanguageClient#textDocument_formatting_sync()

The method you provided didn't work for me.

@martskins
Copy link
Collaborator

@EvanCarroll See #1216 . As mentioned there, I think this needs a proper test ride, I think it should work, but there may be cases where the async nature of that call causes some issues. If you want to give that a try that'd be great.

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