Skip to content

Feature requests: format without saving and default to LSP #8

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

Closed
heygarrett opened this issue Jul 16, 2023 · 7 comments · Fixed by #16
Closed

Feature requests: format without saving and default to LSP #8

heygarrett opened this issue Jul 16, 2023 · 7 comments · Fixed by #16

Comments

@heygarrett
Copy link

heygarrett commented Jul 16, 2023

Hi! I couldn't find a way to run :GuardFmt or require("guard.format").do_fmt() without also saving the changes to the file, so I figured I'd request it as a feature.

Secondly, is there, or could there be, a way to fall back to LSP formatting if guard is not configured for the current filetype? Maybe something like ft("default"):fmt("lsp") or an additional option in the setup call? Another possibility would be for do_fmt() to return some sort of success or failure so I could use that to determine whether I should run my own formatting logic with installed language servers.

Just some thoughts! Thanks.

@glepnir
Copy link
Member

glepnir commented Jul 17, 2023

I couldn't find a way to run :GuardFmt or require("guard.format").do_fmt() without also saving the changes to the file, so I figured I'd request it as a feature.

Sorry I don't understand this. if you set fmt_on_save to false, you can also use GuardFmt to format file or visual select area.

@erikzaadi
Copy link
Contributor

Added the default lsp support in #16

@heygarrett
Copy link
Author

@glepnir I do want to format on save, but I don't want to save on format.

@xsh005
Copy link

xsh005 commented Jul 17, 2023

You can make a pr that removes this line.

@heygarrett
Copy link
Author

heygarrett commented Jul 17, 2023

@xsh005 I could, but I don't want to break someone else's workflow. I suppose I could try adding a save_on_format option. 🤔

Edit: I don't know how to go about doing this myself, unfortunately.

@glepnir
Copy link
Member

glepnir commented Jul 18, 2023

because it's async so there added write command . I think should add save_after_fmt option ?

@heygarrett
Copy link
Author

@glepnir Yeah, that would 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

Successfully merging a pull request may close this issue.

4 participants