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

How to format on buffer change? #314

Open
morhaham opened this issue Aug 17, 2024 · 1 comment
Open

How to format on buffer change? #314

morhaham opened this issue Aug 17, 2024 · 1 comment

Comments

@morhaham
Copy link

I have tried to add an hook with after-change-functions but it didn't work.

@raxod502
Copy link
Member

raxod502 commented Sep 1, 2024

This feature would need to be added, as currently the logic for change detection will cause a graceful exit/no-op in the case that the buffer has been modified since the last save.

That said... you'd sure want to be careful with this. You would potentially be starting multiple external processes in parallel on every keystroke. It might be more fruitful to set the formatting to happen on an idle timer, so that reformatting would only happen after the user stops typing for a second or two. Also if you formatted on every keystroke, you'd get a lot of spurious errors from formatters detecting invalid (not-yet-valid) syntax, and possibly dumpstering your in-progress line of code.

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

No branches or pull requests

2 participants