godbout / kindaVim.docs

Ultimate Vim Mode for macOS
https://kindavim.app
643 stars 4 forks source link

Microsoft Word and google doc support #34

Closed albert-ying closed 2 years ago

albert-ying commented 2 years ago

I believe most of the people here have many custom configurations in init.vim, and I understand it is super hard for kV to support the full-feature config file for Vim.

But I'm wondering if it is possible to support some simple remapping first? For example, in Vim I remapped $ to L and ^ to H, and developed the muscle memory to it. It would be nice if I can set a similar remapping in kV.

Another idea (maybe in the future) is to let the kV to read the init.vim file, and extract/apply the simple remappings automatically, while ignoring other complex remappings.

Thank you so much!

godbout commented 2 years ago

muscle memory is a bitch isn't it πŸ˜‚οΈ

loading the vimrc (or equivalent) is the ultimate goal and is in the plan. but no ETA. that'd probably be the final thing. from my experience working on kV for a year full time i'd say i'd need another 1.5 to 2 years to finish the various Vim Engines first. proper mapping/config would come after. and tbh even tho the response for kV has been great, the one regarding the subscription has been catastrophic πŸ˜‚οΈπŸ˜‚οΈπŸ˜‚οΈ even from Vim users and/or developers. seems kV is seen as a "small utility" app. which means i'll probably not be able to work full time on it. which means in the plan, but don't except it soon sorry 😬️

godbout commented 2 years ago

wondering tho if there's something possible to do with Karabiner-Elements and/or Hammerspoon? like some kind of integration? currently you could map $ to L etc, but that would also be mapped before you enter kV Normal Mode. maybe something for you to try out and dig into?

albert-ying commented 2 years ago

and tbh even tho the response for kV has been great, the one regarding the subscription has been catastrophic πŸ˜‚οΈπŸ˜‚οΈπŸ˜‚οΈ even from Vim users and/or developers. seems kV is seen as a "small utility" app. which means i'll probably not be able to work full time on it. which means in the plan, but don't except it soon sorry 😬️

Yeah, that's probably because there is usually not so much typing work in the app without vim mode. One use case for me would by Microsoft Word or google doc. But I just noticed that the w b movement doesn't work in Word... I don't see anyone bring this up in the issue. Is it just me or something?

godbout commented 2 years ago

Yeah, that's probably because there is usually not so much typing work in the app without vim mode. One use case for me would by Microsoft Word or google doc.

not sure what you mean here sorry. but i mean, kV is not a Tap and Fartα΅€α΄Ή app. it brings the fucking Vim Engine to macOS . it's a lot of work and not simple (although nobody's business except mine), there's a valid reason why there's nothing close out there πŸ˜‚οΈ i just wrongly thought that at least Vim users would see the value. anyways, always good to be closer to reality. i'm glad about the feedback.

But I just noticed that the w b movement doesn't work in Word... I don't see anyone bring this up in the issue. Is it just me or something?

i don't have Word here. do you see a block cursor when you enter kV Normal Mode? if yes but you can't do anything, then it's probably an Electron app. which means it says you can read the text, but in reality it's sending back crap data. for those you need to enforce Key Mapping Mode in the Preferences. if you don't see a block cursor then it should "work" through key remapping. in any case, maybe try to enforce Key Mapping Mode and see what it does?

godbout commented 2 years ago

ok i see there's free version of Word. will have a look.

godbout commented 2 years ago

But I just noticed that the w b movement doesn't work in Word... I don't see anyone bring this up in the issue. Is it just me or something?

so the reason currently is that

  1. Word doesn't implement the macOS Accessibility (of course)
  2. the Text Area is reported as being a Non Text Element. which means the Key Mapping used is like if it was a dropdown, list, etc.

will see what i can do.

godbout commented 2 years ago

ok so it happens that Word doesn't activate its Accessibility by default. you need somehow to activate it by using the Accessibility Inspector and clicking on a page. see below. it's dumb af but it works.

https://user-images.githubusercontent.com/121373/148370880-e41ea2e2-f908-4914-96ff-afd1156cf714.mp4

will see if i can find a way to active this programmatically.

godbout commented 2 years ago

maybe check the Preferences also: https://support.microsoft.com/en-us/office/accessibility-support-for-word-c014d8b8-4ef3-4a7a-935d-295663f3343c#PickTab=macOS

grayed out here as it seems you need a subscription to change the Preferences.

albert-ying commented 2 years ago

The Accessibility Inspector works. I couldn't find anything in preference related to this. Also, there is a strange thing: it shows the block curser first and I can do things like viw. But when I moved to the second page, the block curser changed to the regular cursor and I cannot do viw anymore...

godbout commented 2 years ago

yeah coz Microsoft does what it does best: build shit apps. when you active the Accessibility through the Accessibility Inspector it's properly activated only for the current page it seems. they render their page as an AXSplitGroup rather a dedicated text so kV doesn't see this as text. i could hack something but that would mean 1) you'll have the kV Key Mapping Mode instead of the Accessibility one, so it's "Vim" through key remapping. subpar. 2) may affect other apps that use AXSplitGroup correctly.

but Word may have ways to activate the Accessibility, can you have a look? https://wiki.albany.edu/display/public/askit/Accessibility+support+for+Word+in+Mac

basically kV is a Screen Reader. as long as an app implements the macOS Accessibility properly (to work with Screen Readers), then kV can do its magic.

godbout commented 2 years ago

But I'm wondering if it is possible to support some simple remapping first? For example, in Vim I remapped $ to L and ^ to H, and developed the muscle memory to it. It would be nice if I can set a similar remapping in kV.

you could achieve that currently with Karabiner-Elements. you can remap keys on a per app basis. this is a low level Virtual Keyboard so the mapping would be done before kV sees the keys. works flawlessly. maybe worth having a look?

albert-ying commented 2 years ago

What I mean before is that, at least for me, I don't usually do a lot of typing/editing outside of vscode and neovim. In the browser, there is an addon calls firenvim, which allows me to use neovim anywhere in browser (this is how I write this).

There are two places the kV could become super useful, as currently there is no way to use vim binding in them: MS Word and Google doc. Because we will inevitably need to write some docs collaboratively with others, who don't do markdown, in our real life.

Unfortunately, the kV doesn't really work well in these two things. (I just tested google doc, it doesn't work; I looked at the link you shared for word as well, didn't find any clue yet..). I believe it will become a big selling point if it can work in just these two things. At least I will definitely buy a plugin that allows me to vim just in word or google doc.

p.s. Maybe you can also do a questionnaire to ask which apps do people want to use kV for, and focus on supporting those apps. Just a suggestion, as I really like this app and really hope it can prosper in the future.

godbout commented 2 years ago

i see. thanks for clarifying, that helps. firenvim is a killer yeah, cannot beat that.

personally i built kV for being able to use the same moves/mindsets everywhere, so that includes UI a lot: go down lists, reward a movie, select emails and delete, etc. and for sure to write/edit in texts. to have proper Vim in texts though the big issue that i can't control is whether the apps implement the macOS Accessibility and/or correctly. as you've experienced, it's a hit and miss. the goal is first to have a proper experience in apps that do the job correctly, then be more specific. handling Electron apps is in the ROADMAP and will probably be a higher priority as they are everywhere and a lot of people are using them (not sure why).

i haven't dug too much yet in Google Doc the fact that kV doesn't move at all would suggest that it's part of the Electron apps family: they say they handle the macOS Accessibility, but all the they do is telling you the caret is at location 0 and the text length is 0. so basically, you can't do shit. for those currently i'd suggest you to put the app you're using for the Google Docs in the Key Mapping Mode in the Preferences. you'll be able to have a little bit of Vim through the Keyboard Strategy. not that great, but better than nothing.

godbout commented 2 years ago

Screen Shot 2022-01-11 at 20 21 55

godbout commented 2 years ago

p.s. Maybe you can also do a questionnaire to ask which apps do people want to use kV for, and focus on supporting those apps. Just a suggestion, as I really like this app and really hope it can prosper in the future.

yeah, but no. building kV on a per app basis would be complete madness. currently to handle proper apps, browsers, UI, not proper but ok apps, it's already 3.5 Vim Engines, 1+ year full-time. i've been gathering feedback for a few months now and the consensus is that kV is worth 10US (for a lifetime license). so, questionnaire time is over πŸ˜‚οΈ it's just not viable. custom Vim Engines on a per app basis while 3US a month is deemed too expensive just make absolutely no sense for me to take requests. still digesting if i open source kV fully, or if go with a "support the development" model. i DO want to work on it full-time though... wait and see.

godbout commented 2 years ago

i haven't dug too much yet in Google Doc the fact that kV doesn't move at all would suggest that it's part of the Electron apps family: they say they handle the macOS Accessibility, but all the they do is telling you the caret is at location 0 and the text length is 0. so basically, you can't do shit. for those currently i'd suggest you to put the app you're using for the Google Docs in the Key Mapping Mode in the Preferences. you'll be able to have a little bit of Vim through the Keyboard Strategy. not that great, but better than nothing.

let me know if that solution for Google Doc is acceptable for now. if it is i can for that AXSplitGroup shit from Word to be considered as text to get the same behavior.

godbout commented 2 years ago

i contacted Microsoft about the AX issue.

For Google Doc, see below:

godbout commented 2 years ago

there's options to set in Google Doc itself to turn the AX on:

Screen Shot 2022-01-12 at 00 54 30

then there's some in your browser (if you don't use Safari, which handles this natively):

Screen Shot 2022-01-12 at 00 53 51

yet still, Google Doc returns a value (text) empty, caret location 0, selected length 0, etc. basically, can't do anything with it.

found some project that brings Vim to Google Docs: https://github.com/matthewsot/docs-vim although there's a part about Google Docs making changes, which may render that project useless: https://github.com/matthewsot/docs-vim#update

not sure if it's already the case and why they send wrong AX data.

so i think your best bet in the short term is to use kv's Keyboard Strategy. it's key remapping, not text manipulation. so it's definitely less precise.

godbout commented 2 years ago

ok there's a temporary fix for Electron stuff in 1b23. Google Docs kinda work. sometimes it even catches the Accessibility Strategy. when not it will use the Key Mapping.

i did some thing for Word but sorry, it's a big pile of crap. can't believe Microsoft hasn't changed in 15 years. anyways, you can use the Key Mapping now. but some moves will not work, like 0 and $ coz they're mapped to the standard macOS control a and control e, but of course those don't work in Word. you may want to use g0 and g$ instead, which goes at the end of screen lines rather than file lines.

albert-ying commented 2 years ago

It looks great! Thank you so much! Best, Albert

On Thu, Jan 20, 2022 at 7:06 AM G. @.***> wrote:

ok there's a temporary fix for Electron stuff in 1b23. Google Docs kinda work. sometimes it even catches the Accessibility Strategy. when not it will use the Key Mapping.

i did some thing for Word but sorry, it's a big pile of crap. can't believe Microsoft hasn't changed in 15 years. anyways, you can use the Key Mapping now. but some moves will not work, like 0 and $ coz they're mapped to the standard macOS control a and control e, but of course those don't work in Word. you may want to use g0 and g$ instead, which goes at the end of screen lines rather than file lines.

β€” Reply to this email directly, view it on GitHub https://github.com/godbout/kindaVim.theapp/issues/34#issuecomment-1017430468, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOIS5MQVLRE2LX3AAKEPYKDUW73D7ANCNFSM5LKCJ2RQ . You are receiving this because you authored the thread.Message ID: @.***>

godbout commented 2 years ago

bad news. the hack for Word is breaking some other apps. the other apps are using the right elements, Word is not, so i'm gonna remove the hack. currently if you'll want to use kV with Word you'll have to go through the Accessibility Inspector trick we talked earlier. sometimes for whatever reason Word will allow the use of the Accessibility, so it'll be nice. sometimes for whatever reason it will not, so it'll revert to the Key Mapping, which is better than nothing.

for the viw that you said you couldn't do earlier, i may add a funk one for the Key Mapping then. but i'm curious, how are you using it? yiw copies the inner word. ciw removes it and copies it also. any special use for the viw?

sorry about the Word thing, but it's just custom garbage. even the standard keyboard shortcuts don't work. things for Google Doc will get improved though once i get the Electron apps to work better (will still not be 100% great coz they're using a lot of custom stuff too).

godbout commented 2 years ago

oh also, i'm not sure if it's because i'm using the free version of Word and then can't change the text, but selection words is not possible with the shift key. if it doesn't work on your version either, it means that Word is doing another custom shit with the shift key, which means we will not able to use Visual Mode in Key Mapping.

godbout commented 2 years ago

you can see how it will work below. not perfect, but currently the best kV can handle:

https://user-images.githubusercontent.com/121373/150401489-c07d1be7-7411-4d44-b724-64dc37793f70.mp4

the fact that we can use the Accessibility when we use the Inspector tells that there should be a way to activate it programmatically. for Electron apps and browsers there are some special Attributes to send to the app. for Word there's no doc. i've sent a couple of emails two or three weeks ago but no answer.

albert-ying commented 2 years ago

Thank you so much for working on this!

For the viw I just use it to test the iw movement without changing the content. As long as the yiw, diw, and ciw works, I think we don't necessarily need viw.

But based on the video you showed, yiw seems not working?

I'm also curious if your previous hack word specific? Is it possible to make a rule to only induce that hack when using the kV in something like word?

albert-ying commented 2 years ago

I just used the previous version in Word. It works very well! I noticed that the cursor moves vertically when I use j and k, which makes it much easier to track the cursor's position. Is it a new feature? As a remember previously the cursor moves based on the character number on that row, which is hard to use for non-mono spaced font.

godbout commented 2 years ago

For the viw I just use it to test the iw movement without changing the content. As long as the yiw, diw, and ciw works, I think we don't necessarily need viw.

yiw and ciw are there for the Keyboard Strategy yes: https://github.com/godbout/kindaVim.theapp#kv-keyboard-strategy diw is missing. i will add it. thanks.

viw i'm a bit reluctant, because it cannot be done properly with key remapping. see below how it's supposed to work:

https://user-images.githubusercontent.com/121373/150722302-69556bec-c496-4c37-b17e-c903dd00591e.mp4

best i could do is selecting the current word, but that's definitely not what iw in Visual Mode is supposed to do, so that might break people's expectations.

But based on the video you showed, yiw seems not working?

yiw worked, but the paste didn't πŸ˜…οΈ coz that's the trial version of Word.

I'm also curious if your previous hack word specific? Is it possible to make a rule to only induce that hack when using the kV in something like word?

i'm adding two new Families in 1b24. one is the 911 Family. it's gonna be for apps that do everything wrong, like Word πŸ˜‚οΈ so you'll be able to add it there, and that will enforce the Keyboard Strategy Text Elements for Word. you'll be able to use it in texts, but it's gonna be funky with UI Elements. that's just because with those apps, nothing can be detected properly. should still help tho.

godbout commented 2 years ago

I just used the previous version in Word. It works very well! I noticed that the cursor moves vertically when I use j and k, which makes it much easier to track the cursor's position. Is it a new feature? As a remember previously the cursor moves based on the character number on that row, which is hard to use for non-mono spaced font.

how the cursor moves depends on the Strategy used. if it's the Accessibility Strategy (text manipulation), kV will calculate which column number it should put the caret on. but you're right, for non-monospaced fonts that may look a bit off, although the column number is correct. for the Keyboard Strategy, pressing j remaps to down, so macOS does the visual calculation itself. can't do this with the Accessibility Strategy.

if you prefer that way, you could force all apps into the Key Mapping family but 1) it's slower 2) lots of moves will not be available, because it's not reading the text.

godbout commented 2 years ago

1b24 out. put Word in the 911 Family and you'll be able to use (some of) the Key Mapping moves.

godbout commented 2 years ago

closing for now. please reopen if you're still finding issues.

albert-ying commented 2 years ago

Hi, I just realized there is a way to make the word plain text editor-like. Do you think it is possible to let kV do more in this mode? https://user-images.githubusercontent.com/59846322/200462271-4f32a5c1-1e4e-4dd9-99c5-b1ef1021690b.mp4

godbout commented 2 years ago

you're in luck. i still have some weeks on a Microsoft plan. i'll check it out ASAP, thanks!

godbout commented 2 years ago

i had a look. so this is just a change of view. before you're using a print layout, then you're switching to the draft layout. but behind the scenes, nothing really changes, only the presentation. the issue with Word is in the way it's built. the place where you type text, in any presentation style, is a layout area. which basically means nothing. it could be a place to draw. a place to show a movie. a place to type (only for lazy dumb dev tho). so that's the issue, layout area is not done for text. you can't ping the value of the text, the length, where is the caret, etc, etc. so it's the same as before, Word needs to be put in the 911 Family, where we remap keys and pray that it works...

albert-ying commented 2 years ago

Ok.. I hate MS word... Thank you for taking a look tho!

godbout commented 2 years ago

same here πŸ˜…οΈ i hadn't touched Windows for ten years but had to for a client. i was kinda excited to see how Windows changed over the last ten years. still same. shit and ugly. what a disappointment.