Eugleo / magic-racket

The best coding experience for Racket in VS Code
https://marketplace.visualstudio.com/items?itemName=evzen-wybitul.magic-racket
GNU General Public License v3.0
199 stars 29 forks source link

Make whole-word jumping optional #103

Open AndreiDuma opened 1 year ago

AndreiDuma commented 1 year ago

Hi! First of all, thank you for the great extension! I use it daily and it works very well for me.

I have a question/suggestion. In the README one can read the follow aspect:

VS Code recognizes the "words" in Racket correctly, meaning that moving among words using Ctrl+Left and Ctrl+Right works as expected, and so does the double-click word selection

Would it be possible to make this behavior configurable? I use Vim keybindings and I'm so used to the default motion for w and b that I find it hard to adjust when I switch to a Racket project. Thank you!

jryans commented 1 year ago

Thanks for the feedback!

To be honest, I am not quite sure which base VS Code feature the README was referring to here, as Ctrl+Left doesn't seem to do anything on my side... 🤔

I also use the Vim extension as well, so perhaps that's confounding things...

In any case, could you be a bit more specific here? What exactly does the Vim default motion do that you'd like to see restored? Magic Racket currently changes the word separators so that e.g. "foo-bar" becomes a single word, while Vim defaults would treat that as two words: "foo"-"bar". Is this hyphen case the one you mean, or something else?

AndreiDuma commented 1 year ago

Thanks for your quick answer!

[...] as Ctrl+Left doesn't seem to do anything on my side [...]

Maybe it is Alt+Left on your platform? On the Mac I use Option+Left for the same effect.

Indeed it's the word separator! Since in Scheme/Racket it's common to use identifiers-such-as-this-one, it'd be very useful to be able to jump inside the subwords. In Vim we can still use W/B to skip whole words. Do you think it's worth being able to configure this?

jryans commented 1 year ago

Maybe it is Alt+Left on your platform? On the Mac I use Option+Left for the same effect.

Ah right, I am on macOS as well, and Option+Left does indeed work, thanks. (I swear I tried it earlier! 😅)

Indeed it's the word separator! Since in Scheme/Racket it's common to use identifiers-such-as-this-one, it'd be very useful to be able to jump inside the subwords. In Vim we can still use W/B to skip whole words. Do you think it's worth being able to configure this?

Thanks for confirming I understand the issue. There are several bits of Magic Racket currently in your way:

1. Racket language default settings

Magic Racket adds these default values to settings:

      "[racket]": {
        "editor.rulers": [
          102
        ],
        "editor.wordSeparators": "()[]{}\",'`;#|"
      }

This bit you could workaround in your own settings by re-specifying your own value for editor.wordSeparators that re-adds - into the list, but there's also...

2. Racket language configuration

Magic Racket also contains a "language configuration" with a word pattern that might be in your way (even though the docs say it does not affect word-related editor commands), and I am not aware of user-level way to override that.

3. Document symbols

The langserver also marks the entire form (all of "foo-bar") as one symbol, and that may also hamper per-word movement.

Current summary

I am not sure if all of these bits can be tweaked dynamically (via a checkbox as you're suggesting), so I'll have to investigate those details a bit further. If they can be, then it seems reasonable to add a setting for this to me.