oxalica / nil

NIx Language server, an incremental analysis assistant for writing in Nix.
Apache License 2.0
1.28k stars 39 forks source link

Fail textDocument/formatting when no formatter is set #108

Closed Noratrieb closed 11 months ago

Noratrieb commented 11 months ago

Currently, nil silently fails when no formatter is set. This caused me a lot of confusion as to why nothing was formatting when I accidentally misconfigured the formatter.

This makes it so that we return an error instead, alerting the user that something is wrong.

This could be annoying to someone who hasn't configured a formatter on purpose but still causes formatting events, either by format-on-save or muscle memory. I think this is fine, and they should turn off format-on-save or just get a formatter instead. Alternatively, someone could set cat as their formatter.

image

[Error - 8:02:06 PM] Request textDocument/formatting failed. Message: No formatter configured. Set the nil.formatting.command LSP server setting. Code: -32603

oxalica commented 11 months ago

This could be annoying to someone who hasn't configured a formatter on purpose but still causes formatting events, either by format-on-save or muscle memory. I think this is fine, and they should turn off format-on-save or just get a formatter instead. Alternatively, someone could set cat as their formatter.

That's reasonable. Thanks!