zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
49.55k stars 3.03k forks source link

vim: press % to go to corresponding opening/closing bracket #15963

Open lucascherzer opened 3 months ago

lucascherzer commented 3 months ago

Check for existing issues

Describe the feature

In vim, pressing % when the cursor is on an opening or closing bracket, it will jump to its corresponding closing/opening bracket.

If applicable, add mockups / screenshots to help present your vision of the feature

https://asciinema.org/a/bGrzqxXUdGY1Mk8BeREW1prT4

sleeping-at-night commented 3 months ago

I am currently running Zed zed 0.146.5-2, in most of the time and most of the languages, the function of % working perfectly as indented. Could it be that this is a language specific problem?

baldwindavid commented 3 months ago

Yeah, I've been using Zed since earlier this year and % has always worked in at least elixir, js, and json.

JosephTLyons commented 3 months ago

Hey @lucascherzer, can you give me some more details on this? What languages are you trying to use this in and what OS are you using?

bww commented 2 months ago

For what it's worth: while this typically works as I expect in the "main" source, I frequently have problems with % (and some other motions), which don't do what they should in "secondary" text, i.e., in string literals, here-docs, etc.

It seems like this is generally a consequence of trying to be too clever about the source context when just scanning the literal surrounding text would produce the desired result.

lucascherzer commented 2 months ago

I just tried it again in Zed 0.147.2 on MacOS.

Within a rust buffer, this feature worked as expected. I suspect this is because I was previously attempting to use it in a text buffer, which vim supports, but zed does not. So this is not about adding support in general, which already exists but whether to enable this feature on buffers that do not have a strictly defined syntax like plain text. As I already said, vim does support the % hotkey in txt buffers, but imo it would be more elegant to let the user decide via the config. Does anyone have thoughts about that?

gordio commented 1 month ago

IMHO: It's some how related to lsp or tree-sitter. In my case I can't jump to paired bracket in csharp probably because missing tree-sitter or fully functional lsp, something… After vim its a bit disappointing :`(