redhat-developer / lsp4ij

LSP Client for IntelliJ
Eclipse Public License 2.0
86 stars 17 forks source link

Feature request: A way for languages or language servers to bypass the canFormat check #424

Open FalsePattern opened 2 months ago

FalsePattern commented 2 months ago

In AbstractLSPFormattingService, canFormat checks for the presence of a LanguageFormatting implementation for a language, and if present, doesn't invoke the LSP formatter.

In the case of ZigBrains, I used both the LSP formatter for manual formatting via ZLS when invoking the formatting action, as well as the intellij autoformatter for correct auto-indentation when creating new lines or code blocks. If the zigbrains lang.formatter is removed, auto-indentation breaks, but the ZLS formatter functions.

angelozerr commented 2 months ago

Same issue than https://github.com/redhat-developer/lsp4ij/issues/388

FalsePattern commented 2 months ago

As a temporary workaround until this is solved, I have added a proxy service that bypasses the AbstractLSPFormattingService.canFormat checks for Zig: https://github.com/FalsePattern/ZigBrains/blob/master/modules/zig/src/main/java/com/falsepattern/zigbrains/zig/formatter/ZigAbstractLSPFormattingServiceProxy.java, this seems to fix the issue for ZB.