mirror of
https://github.com/oxalica/nil.git
synced 2024-11-22 11:22:46 +03:00
Fail textDocument/formatting when no formatter is set (#108)
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.
This commit is contained in:
parent
4775e34c30
commit
510bc6e9b4
@ -221,9 +221,10 @@ pub(crate) fn formatting(
|
|||||||
Ok(stdout)
|
Ok(stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
let Some(cmd) = &snap.config.formatting_command else {
|
let cmd =
|
||||||
return Ok(None);
|
snap.config.formatting_command.as_ref().context(
|
||||||
};
|
"No formatter configured. Set the nil.formatting.command LSP server setting.",
|
||||||
|
)?;
|
||||||
|
|
||||||
let (file_content, line_map) = {
|
let (file_content, line_map) = {
|
||||||
let vfs = snap.vfs();
|
let vfs = snap.vfs();
|
||||||
|
Loading…
Reference in New Issue
Block a user