boltex / leointeg

Leo Editor Integration with VS Code
https://marketplace.visualstudio.com/items?itemName=boltex.leointeg
MIT License
73 stars 6 forks source link

Help with keyboard shortcuts #238

Open kghenderson opened 2 years ago

kghenderson commented 2 years ago

Hi Felix, this project and plugin are amazing and I'm very excited about it! Thank you!

Step 1 for me really using it in earnest though is that I have to use, align and test my heavily customized key bindings.

Obviously I can go through and set these myself (and in a perfect world I'd set them once here in VSCode), but here's my issue. It seems that when I remove a binding in VSCode, it also removes the 'when' conditions with it, and doesn't seem to provide the default value again after you remove it, but obviously these conditions are really important!

If I have a Leo pane, a code pane, and a preview pane open then it's going to be absolutely critical that these are in sync, because there are specific commands to update the outline (always), and separate ones to manipulate the text in the editor pane, and the preview pane needs to stay in sync.

I'm not exactly sure how we solve this, I was considering whether we could someday extract the bindings (all the bindings?) into a Leo outline with clones & alternate hierarchies which could serve as a bit of a leoInteg showcase. I can imagine 3+ hierarchies; one by the command name (the vscode default), one by the context (when: resource scheme, focused area, etc), and one based on the key binding combinations. This could also be extracted/applied to say an @file in markdown which could be previewed/printed/shared in a nicer way to show that functionality off too.

Something else to consider, while I'm on a ramble, is that we could read in the VsCode default bindings and just map them straight to the leoInteg bindings (unless they've been overridden) with the resourceScheme & Focus appended to the command, so the same binding would apply even though different things are happening under the hood.

My only ask for this ticket is if the default bindings which you've clearly taken the time to figure out, could just be maybe written out in readme or in a separate document (leo outline?), so I can go through and recreate them but setting my own bindings. i.e. I'd prefer to scrap all of them and recreate them one by one as I go as a form of self tutorial.

Anyway, thanks for considering, can't wait to dig in.

Kevin

boltex commented 2 years ago

@kghenderson Hi Kevin, I'm so happy to know other Leo users are using and appreciating the extension I made! The pleasure is all mine!

Thanks for your contributions and suggestions! those are great questions and ideas!

It's also great to have those issues raised for other people, who might not have dared to post those kinds of concerns: if you have those issues, you're probably not the only one. :)

Note: Screenshots below can be clicked on to zoom on them 'fullscreen'.

I also like to edit my markdown files with the body pane on the left, the generated code in the middle, and vscode's live preview on the right like so (live preview changes in real time if either body pane or external file is edited, body pane also refreshes automatically if the external file is edited, as is expected of Leo) : Screenshot from 2022-01-15 20-17-00

Or even better: sometimes I only work with Leo's body pane and the preview on the right: Screenshot from 2022-01-15 20-17-10

But I'm not sure what you mean by "...the text in the editor pane, and the preview pane needs to stay in sync..." because the markdown preview window in vscode needs no keypresses at all, and refreshes automatically upon saving the external file (with a regular ctrl+s obviously). either from leointeg's body pane/outline, or in the vscode's editor panel for this external file.

Anyways, great to know other people are also using leointeg to edit and preview all kinds of file types! (vscode can do live rendering of other kinds of files too such as svg graphic files and many others!)

Although your questions are related to vscode and are technically not related to leointeg per-say, it's important to address those concerns here regardless because old-time Leo users will not know that distinction, and will be looking here in the leointeg issues just like you did :)

Here's how I changed some default Leo/LeoInteg keybindings:

But first, the most important shortcut in vscode that you should knwo about is [CTRL+SHIFT+P] (the equivalent of minibuffer in Leo) because it opens a 'command palette' that shows all available commands with a lazy-search input box to type in.

(use that [CTRL+SHIFT+P] command palette to directly open the panels, or files, for setting / viewing keyboard shortcuts.)

So go ahead and do ctrl+shift+p and start typing 'keyboard shortcut', after a few letters of typing it will propose this choice, go ahead and press enter on that.

In the 'Keyboard Shortcut' panel, there's a text input at the top, write 'leo' in there to restrict the immense list of vscode keybindings to those coming from the leointeg expansion only.

Now the point is to not delete the shortcuts, as you will loose the very important 'when' conditions. You want to select an entry and press enter, this will prompt you for a new keybinding to press. This will keep the 'when' condition while changing the keybinding to your new preference.

You can also right click on those keybindings to reset them. (and other actions)

Also, you can view the results of your modifications in the actual 'keybinding.json' vscode setting file, (good to at least look at it to get a better understanding) and maybe modify some there themselves if you're comfortable with this. Here's how to access it:

In the Keyboard Shortcuts panel, There is a triple-dot (...) at the top-right hand corner. Click on that and select "Show User Keybindings". (you could also instead open the keybindings.json with the ctrl+shift+p shortcut mentionned earlier, by typing 'keybindings.json' in the given command pallete input box)

In this screenshot, you can see the 'Keyboards Shortcut' panel on the right, and the json it generates in keybindings.json on the left. Screenshot from 2022-01-15 21-03-51

A way to reset all the keybindings you may have lost/modified/corrupted according to this quick search : https://stackoverflow.com/questions/49313485/how-to-reset-visual-studio-code-key-bindings is to open that keybindings.json with the ctrl+shift+p shortcut mentionned earlier and delete your listed keybindings.

Now, to adress you questions about possible lists of leointeg keybindings that I reproduced from Leo's default keybindings, you'll be happy to know there is already a somewhat categorized Leo file and outline for them:

From leointeg's repo, the place to look for in the leointeg.leo file is the node : "@clean package.json".

I think this last little info about where to look will help you greatly in you endeavor. Check out this screenshot to help you locate it: Screenshot from 2022-01-15 23-45-51

Lastly, as I have once or twice proposed in the Leo's google group forums, is to look on for vscode's official training and feature showcase videos for vscode, and to use vscode to practice using it with some or your existing projects WITHOUT using leointeg at all for a couple days just to get a better overview of its basic functions with code editing, file browsing and git integration, etc... (if your agenda allows for this - it will not be time lost in long run) Some unofficial videos are also very good, such as this one for example: https://www.youtube.com/watch?v=WPqXP_kLzpo - this one focuses on keybindings: https://www.youtube.com/watch?v=pZGtKVYnzfI

Hope this helps and don't hesitate for any subsequent questions or clarifications! Thanks again! :)

-- Félix