Intellij not sending "textDocument/rangeFormatting" request to LSP based language server.

已回答

I'm writing a language server and integrating it with Intellij. Currently, that language server is asking for formatting requests to be sent to itself if certain file extensions match.

Now, full file format requests (textDocument/formatting) are successfully sent to language server. I can also see IntelliJ say “running LSP based formatter”. 

However, Intellij is not sending rangeFormatting requests to my language server and running its own formatter. It is evident by Intellij saying “Formatting code” instead.

Here are the logs denoting intellij successfully registered LSP request for range formatting.

2025-04-10 11:27:15,027 [  16541]   FINE - #c.i.p.l.i.c.Lsp4jServerConnector - <-- OrcaLspServerDescriptor@teachdd: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"  - Document formatting provider: enabled"}}
2025-04-10 11:27:15,027 [  16541]   INFO - #c.i.p.l.i.LspServerImpl - OrcaLspServerDescriptor@teachdd(Initializing;0): window/logMessage Info:   - Document formatting provider: enabled
2025-04-10 11:27:15,028 [  16542]   FINE - #c.i.p.l.i.c.Lsp4jServerConnector - <-- OrcaLspServerDescriptor@teachdd: {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"  - Document range formatting provider: enabled"}}
2025-04-10 11:27:15,028 [  16542]   INFO - #c.i.p.l.i.LspServerImpl - OrcaLspServerDescriptor@teachdd(Initializing;0): window/logMessage Info:   - Document range formatting provider: enabled

I have also overridden shouldFormatThisFileExclusivelyByServer in LspFormattingSupport to signal intellij that language server will take care of the file.

This is probably a bug in intellij where intellij is formatting the range itself and not delegating to language server.

0
正式评论

Hi, Sarthaktiwari306, I see that you've already found a similar issue, and our developer provided an answer in this comment. Please consider following that issue to receive updates.
Let us know if there's anything else we can help you with!

请先登录再写评论。