-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Ruby LSP has a feature to automatically add end
s, e.g. after def method_name
. It uses the textDocument/onTypeFormatting
language server request.
In Zed, this doesn't work. I suspect this is a bug in Zed rather than the extension, but I'm logging it here first until I learn more.
Example (comparing with VS Code)
In Ruby LSP with VS Code, enable verbose logging.
You'll also need to enable "editor.formatOnType": true
since it's disabled by default.
Now type the following:
def foo
The logs will show a request:
Sending request 'textDocument/onTypeFormatting - (41)'.
{
"textDocument": { "uri": "file:///Users/andy/src/github.com/Shopify/ruby-lsp/x.rb" },
"position": { "line": 3, "character": 1 },
"ch": "d",
"options": { "tabSize": 2, "insertSpaces": true }
}
and an empty response
Received response 'textDocument/onTypeFormatting - (41)' in 1ms.
Now press return and you'll see a second request:
Sending request 'textDocument/onTypeFormatting - (48)'.
{
"textDocument": { "uri": "file:///Users/andy/src/github.com/Shopify/ruby-lsp/x.rb" },
"position": { "line": 4, "character": 2 },
"ch": "\n",
"options": {
"tabSize": 2,
"insertSpaces": true
}
}
and a response, which causes an end
to be added:
[
{
"range": {
"start": { "line": 4, "character": 2 },
"end": { "line": 4, "character": 2 }
},
"newText": "\n"
},
{
"range": {
"start": { "line": 4, "character": 2 },
"end": { "line": 4, "character": 2 }
},
"newText": "end"
},
{
"range": {
"start": { "line": 4, "character": 2 },
"end": { "line": 4, "character": 2 }
},
"newText": "$0"
}
]
In Zed, we see the first request:
// Send:
{"jsonrpc":"2.0","id":39,"method":"textDocument/onTypeFormatting",
"params":{"textDocument":{"uri":"file:///Users/andy/src/github.com/Shopify/ruby-lsp/x.rb"},"position":{"line":0,"character":1},
"ch":"d",
"options":{"tabSize":2,"insertSpaces":true,"trimTrailingWhitespace":true,"insertFinalNewline":true,"trimFinalNewlines":true}}}
// Receive:
{"id":39,"result":[],"jsonrpc":"2.0"}
but after pressing return, there is no second request.
#38 may be related.
Flink and goetzc
Metadata
Metadata
Assignees
Labels
No labels