dbalatero / VimMode.spoon

Adds vim keybindings to all OS X inputs
692 stars 32 forks source link

VSCode command line vs application #37

Closed jtgrenz closed 4 years ago

jtgrenz commented 4 years ago

First off, system-wide vim is super cool, but I still like using VS code because I have a bunch of plugins and I haven't switched to full vim yet. So thanks for open sourcing this!

I did run into a weird bug with VSCode though. If I launch VSCode from the command line with code ., I can enter vim mode and the mode box shows above my cursor, but nothing works. If I instead launch the VSCode from finder or Alfred, everything seems to work fine, but the mode label it at the bottom of the screen.

I need to launch VSCode from the CLI because I'm unable to set the correct environment for my plugins otherwise (plus it way more convenient).

Any idea what could be causing that?

dbalatero commented 4 years ago

@jtgrenz

First off, system-wide vim is super cool, but I still like using VS code because I have a bunch of plugins and I haven't switched to full vim yet. So thanks for open sourcing this!

Agreed! I recommend https://github.com/asvetliakov/vscode-neovim to folks that want neovim inside of VSCode. No need to switch to console Vim (although I am personally faster with it + tmux).

I did run into a weird bug with VSCode though. If I launch VSCode from the command line with code ., I can enter vim mode and the mode box shows above my cursor, but nothing works. If I instead launch the VSCode from finder or Alfred, everything seems to work fine, but the mode label it at the bottom of the screen.

To be clear - are you using vim:disableForApp('Code') to disable Vim mode completely? If not I would really recommend that.

If you are using that already, it's an issue of detection working correctly. #36 is an open issue where the app switcher is silently dying in the background, which is what allows for the disableForApp functionality. I'm going to look into that asap, maybe tonight even.

If I instead launch the VSCode from finder or Alfred, everything seems to work fine, but the mode label it at the bottom of the screen.

This is not made clear via the plugin, but basically:

I need to launch VSCode from the CLI because I'm unable to set the correct environment for my plugins otherwise (plus it way more convenient).

Yeah we should ideally support this!

It's a possibility that vim:disableForApp('Code') is the wrong approach, and we should actually do something more specific like vim:disableForApp('com.microsoft.vscode') or whatever the app bundle identifier is. It's possible that the app matching logic is a bit busted.

dbalatero commented 4 years ago

Also where did you hear about this plugin? I've gotten an influx of GH issues recently.

jtgrenz commented 4 years ago

So I removed vim:disableForApp('Code') because I wanted the functionality to work in VSCode (sometimes I'm feeling vimmy, sometimes I'm not).

I'm guessing there's something funky going on with the accessibility controls because when it doesn't work, the mode box is right above my cursor but when it does work, it's at the bottom of the screen indicating its the fallback. Not sure why the different launch methods would alter the accessibility api. 🤔

Also where did you hear about this plugin? I've gotten an influx of GH issues recently.

I think I searched "system-wide vim osx" or something and stumbled on a medium post about hammerspoon and karabiner and then eventually onto your repo :)

dbalatero commented 4 years ago

I'm guessing there's something funky going on with the accessibility controls because when it doesn't work, the mode box is right above my cursor but when it does work, it's at the bottom of the screen indicating its the fallback.

Yeah this makes sense. If the cursor is in any kind of rich text box, it really screws with the main accessibility-based mode. This is because there is a bunch of extra information/entities/characters/whatever in the text box and all the computations I do to jump to next word/etc are majorly off. Detecting what kind of field we are in is really hard.

One thing I could do is make it so you can configure which apps use which mode by default? So at least you can force VSCode to use fallback mode, for example.

In addition, I can hardcode some sane defaults for each app, and let the user override them as needed. Ideally someone will try to use it in VSCode and it should work to the best of the plugin's ability.

Do either/both of those ideas sound ok?

jtgrenz commented 4 years ago

thats sounds like a good fix to me 👍

dbalatero commented 4 years ago

@jtgrenz I hardcoded VSCode to use fallback mode in cc6f8ab. Thanks!