You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Enabling onTypeFormatting LSP feature in Ruby LSP causes issues #38
Glad I finally found this, I was about to open a new issue. I thought it might be related to the treesitter queries somehow and was going mad trying to figure out how to stop it. Is there some kind of change that we need to make upstream in Zed to get this to work properly? onTypeFormatting is nice to have, especially to solve #72 , which we can't do ourselves with the current extension API.
The primary issue here is that document/onTypeFormatting LSP request doesn't officially support the snippet syntax, or any way to bring the cursor back after inserting text. Ruby LSP appends the $0 to the response for VSCode, which extends document/onTypeFormatting implementation to support snippet syntax.
Zed doesn't appear to support snippet syntax here, which is technically correct, as it matches the LSP spec. But I think without this it's not possible for Ruby LSP or this extension to properly apply on type formatting features in Zed.
So, either Zed adds support for snippet syntax in document/onTypeFormatting (even though it's not in the LSP spec), or Ruby LSP implements an alternate way to provide the same features (e.g. via diagnostics).
I found a way to support on type formatting in Zed without support for cursor rewinding ($0): Shopify/ruby-lsp#4133
It supports "end" and "heredoc end" insertion everywhere except EOF. I disabled curly brace and pipe autoclose, as those cannot be supported without cursor rewinding, so it's better not to insert anything than to have wrong cursor position (and Zed already supports curly brace autoclose).
I saw that zed-industries/zed#61823 actually made some changes that make this a lot easier, but there is still a bug in both Zed and Ruby LSP. I've opened PRs to fix them that are minimally invasive and tested these locally and all is working 😄
Activity
Hawkbawk commentedon Jul 3, 2025
Glad I finally found this, I was about to open a new issue. I thought it might be related to the treesitter queries somehow and was going mad trying to figure out how to stop it. Is there some kind of change that we need to make upstream in Zed to get this to work properly?
onTypeFormattingis nice to have, especially to solve #72 , which we can't do ourselves with the current extension API.fix(ruby-lsp): Disable `onTypeFormatting` feature
fix(ruby-lsp): Disable `onTypeFormatting` feature
fix(ruby-lsp): Disable `onTypeFormatting` feature
fix(ruby-lsp): Disable `onTypeFormatting` feature (#142)
vitallium commentedon Jul 13, 2025
Hi, until the upstream issue is fixed, the workaround disabling
onTypeFormattingwill now be applied automatically in #142. Thanks.janko commentedon Nov 19, 2025
For those who are looking to re-enable on type formatting to test it out:
{ "lsp": { "ruby-lsp": { "initialization_options": { "enabledFeatures": { "onTypeFormatting": true } } } } }janko commentedon Dec 26, 2025
The primary issue here is that
document/onTypeFormattingLSP request doesn't officially support the snippet syntax, or any way to bring the cursor back after inserting text. Ruby LSP appends the$0to the response for VSCode, which extendsdocument/onTypeFormattingimplementation to support snippet syntax.Zed doesn't appear to support snippet syntax here, which is technically correct, as it matches the LSP spec. But I think without this it's not possible for Ruby LSP or this extension to properly apply on type formatting features in Zed.
So, either Zed adds support for snippet syntax in
document/onTypeFormatting(even though it's not in the LSP spec), or Ruby LSP implements an alternate way to provide the same features (e.g. via diagnostics).janko commentedon Jun 11, 2026
I found a way to support on type formatting in Zed without support for cursor rewinding (
$0): Shopify/ruby-lsp#4133It supports "end" and "heredoc end" insertion everywhere except EOF. I disabled curly brace and pipe autoclose, as those cannot be supported without cursor rewinding, so it's better not to insert anything than to have wrong cursor position (and Zed already supports curly brace autoclose).
JacobNWolf commentedon Oct 18, 2026
I saw that zed-industries/zed#61823 actually made some changes that make this a lot easier, but there is still a bug in both Zed and Ruby LSP. I've opened PRs to fix them that are minimally invasive and tested these locally and all is working 😄
PRs:
Once these merge, I feel pretty confident that a change could be made to this extension to enable on type formatting as a default.
Could we prioritize these in Zed and Ruby LSP? @SomeoneToIgnore @vinistock
JacobNWolf commentedon Oct 20, 2026
Ok, worked with @SomeoneToIgnore to get zed-industries/zed#65769 ready for the release after next (next week's). I've bumped some folks at Shopify on Shopify/ruby-lsp#4242.
Once those two merge, release, and I can test, we can safely merge #351, which I've just opened now.
cc: @vitallium
Fix on-type formatting using a stale position when autoindent is pend…