0

I am using Emacs 30.0.5 and eglot 1.16. I found a strange behavior when eglot is enabled in a buffer. When I enter a left parenthesis ( at one side of a function call parameter, the other parenthesis ) will automatically be entered on the other side of the parameter. Let | indicate my cursor position, it behaves like this:

self.vec.push(|aa, bb)

If I enter a left parenthesis (, it turns to:

self.vec.push((|aa), bb)

that ) generates after aa. I did not find the documentation to this behavior in eglot documentations or through web search. But I found if I disable eglot by eglot-shutdown, this behavior disappears and if I repeat the above process after that, it shows this:

self.vec.push((|)aa, bb)

Because I am using electric-pair-mode along with eglot, this is quite annoying as when I enter a ( when selecting a region of text, two )s will be generated. Do you know how I can turn off the eglot parenthesis handling? Thanks!

1 Answer 1

0

Solved. This appears to be a Rust specific problem. The Rust LSP server responded the onTypeFormatting suggestion inserting the parenthesis.

[jsonrpc] e[17:16:16.575] --> textDocument/onTypeFormatting[20] {"jsonrpc":"2.0","id":20,"method":"textDocument/onTypeFormatting","params":{"textDocument":{"uri":"*****/lib.rs"},"options":{"tabSize":2,"insertSpaces":true,"insertFinalNewline":true,"trimFinalNewlines":true},"position":{"line":323,"character":19},"ch":"("}}
[jsonrpc] e[17:16:16.579]   <-- textDocument/onTypeFormatting[20] {"jsonrpc":"2.0","id":20,"result":[{"range":{"start":{"line":323,"character":23},"end":{"line":323,"character":23}},"newText":")"}]}

By adding :documentOnTypeFormattingProvider to eglot-ignored-server-capabilities this is solved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.