oni2 icon indicating copy to clipboard operation
oni2 copied to clipboard

Keybinding Suggestions and Contribution Opportunities

Open glennsl opened this issue 4 years ago • 39 comments

This is the place to be if you want to suggest a keybinding, or find a nice and (usually) easy task to start contributing.

Suggestions

Name Command/
Default
Assignee/
PR/Issue
:heavy_check_mark: ~Save~ workbench.action.files.save
Mod+S
@jakeday
#1426
Focus Tab # workbench.action.openEditorAtIndex[1-9]
Mod+1 - Mod+9
@leavengood
:heavy_check_mark: ~Previous Tab~ workbench.action.previousEditor
Mod+PgUp / Cmd+Shift+[
@leavengood
#778/#1447
:heavy_check_mark: ~Next Tab~ workbench.action.nextEditor
Mod+PgDn / Cmd+Shift+]
@leavengood
#778/#1447
Copy input.copy?
Mod+C
@fanantoxa
#1233
Cut input.cut?
Mod+X
@fanantoxa
#1233
Paste input.paste?
Mod+V
@fanantoxa
#1233
Go to next error editor.action.marker.nextInFiles
F8
#1349
Go to previous error editor.action.marker.prevInFiles
Shift + F8
#1349
Go to next search result search.action.focusNextSearchResult
F4
Go to previous search result search.action.focusPreviousSearchResult
Shift + F4
Open settings workbench.action.openSettings
Cmd+,
:heavy_check_mark: ~Zoom In~ workbench.action.zoomIn
Ctrl++
@ArtemDrozdov
#1556/#1629
:heavy_check_mark: ~Zoom Out~ workbench.action.zoomOut
Ctrl+-
@ArtemDrozdov
#1556/#1629
:heavy_check_mark: ~Zoom Reset~ workbench.action.zoomReset
Ctrl+0
@ArtemDrozdov
#1556/#1629

Do you have other suggestions? Post a comment below! If the keybinding exists in vscode as well, it would be nice if you could post the name, command and default keybinding used there.

How to contribute

Keybindings are defined in KeyBindingsStoreConnector. Here's the keybinding for unfo, for example:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/KeyBindingsStoreConnector.re#L162-L166

When invoked this will generate a Command("undo") action, which needs to be handled in a Store somewhere. The undo comamnd is handled in VimStoreConnector here:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/VimStoreConnector.re#L855

Which invokes the effect defined a bit further up, here:

https://github.com/onivim/oni2/blob/bb2df4cd5d88a4f7e643e1f6b849c0b50ad87874/src/Store/VimStoreConnector.re#L827-L834

A lot of keybindings will be like this, just delegating to libvim to handle it. Some might require a bit more though, but a good place to start is to look into how this is done and vim, and whether it can be delegated in the same manner as this.

If you feel ready to tackle one of the suggestions above, post a comment below to lets us know, then dive in! If you have questions, the best place to ask is in the #dev channel on our Discord server.

glennsl avatar Mar 05 '20 21:03 glennsl

Hello, would be nice if we have something like vim-tmux-navigator which allows user to seamlessly navigate through vim splits/terminals/file trees via ctrl+(h,j,k,l)

would also be nice to alias j and k to down and up for non-input fields too.

thanks for welcoming suggestions!

irevived1 avatar Mar 05 '20 22:03 irevived1

@glennsl Select All already implemented with Selection PR

fanantoxa avatar Mar 05 '20 22:03 fanantoxa

I would like to be able to "kind of import" my mappings from init.vim regarding tabs and splits.

" windows
nnoremap ,z <C-W>\|
nnoremap ,h <C-W>h
nnoremap ,j <C-W>j
nnoremap ,k <C-W>k
nnoremap ,l <C-W>l
nnoremap ,= <C-W>=
nnoremap ,x <C-W>x
nnoremap ,c :close<CR>

" tabs
nnoremap ,tg :tabnew<CR>
nnoremap ,tt :tabn<CR>
nnoremap ,tr :tabc<CR>
nnoremap ,tp :tabp<CR>

escorponox avatar Mar 06 '20 07:03 escorponox

@irevived1 Yeah, that's definitely planned, although probably using Ctrl+W - h/j/k/l. It's a feature that require significantly more work than just adding some keybindings though, since at the moment we have no concept of where parts of the UI are relative to each other. I don't think there's an issue for it, but we have it noted down elsewhere and it's on the top of our minds since it's an essential part of the UX we're aiming for.

@fanantoxa Oh, lol, of course. I just use it all the time! Removed from the list.

@escorponox There's already experimental support for VimL, including remapping. See https://onivim.github.io/docs/configuration/settings#experimental

glennsl avatar Mar 06 '20 09:03 glennsl

@glennsl The save request is handled via #1426 and is good to go!

jakeday avatar Mar 06 '20 14:03 jakeday

Thanks @jakeday. Noted.

glennsl avatar Mar 06 '20 15:03 glennsl

The VSCode actions for focusing tabs by number is workbench.action.openEditorAtIndex[1-9]. And there are key bindings for Ctrl-[num] and Cmd-[num] (on macOS at least.)

I think I will look into adding this and the nextEditor/previousEditor commands.

I will probably will make a loop for defining the commands and key bindings for the numbered ones, and then map those to :b1-:b9. Also :bnext and :bprevious don't seem to be implemented yet, so it might make sense to implement those and just connect nextEditor/previousEditor to them. I don't yet know how to do that though.

leavengood avatar Mar 06 '20 19:03 leavengood

Thanks @leavengood. I've updated the OP and assigned you to those.

Also :bnext and :bprevious don't seem to be implemented yet

I think they are, but they're pretty broken? No idea what the problem might be though. Maybe @bryphe has some ideas.

glennsl avatar Mar 06 '20 21:03 glennsl

I added #1450 for indenting and outdenting with tab and shift tab when in visual mode. Let me know if I need to change anything!

jakeday avatar Mar 09 '20 18:03 jakeday

It'd be nice for the keybinding docs to be updated as well (and then kept up to date with any changes from this issue).

There is a complete list here https://github.com/onivim/oni2/blob/master/src/Store/KeyBindingsStoreConnector.re, which could be used to fill in any default bindings and missing conditions for the documentation.

The website file lives here: https://github.com/onivim/oni2/blob/master/docs/docs/configuration/key-bindings.md

CrossR avatar Apr 17 '20 16:04 CrossR

Is there any way we could get an Xcode-like minimap mark feature? Example here
image

igniscyan avatar May 07 '20 09:05 igniscyan

It's been brought up before, but I can't find that there's any existing issues for it. You should create one for it. It's a cool feature. I can't see how it relates to keybindings though.

glennsl avatar May 07 '20 09:05 glennsl

Does the file explorer currently support keybindings? In vscode, i find it natural to map h,j,k,l to move between files and directories in the explorer tree. Is this a possible configuration for Oni yet, and if not, is it a roadmap or desirable feature?

Edit: Should've searched issues more before commenting 🤦 https://github.com/onivim/oni2/issues/528

lettertwo avatar Aug 15 '20 19:08 lettertwo

It would be nice when you are in Search to be able to select all the text. Perhaps Cmd + a?

Happy to take a stab at this, if there isn't someone assigned to this already.

schinns avatar Aug 26 '20 17:08 schinns

@benschinn There already a implemented. Ctrl + A works on linux/window on all inputs (like Ctrl+P, file search, git, etc) it uses binding <C-a> so it might be working already, if it not please create an issue (I don't have any mac to check)

fanantoxa avatar Aug 26 '20 17:08 fanantoxa

Hey folks. Bought onivim today and loving it so far. Trying to customize everything like I have in neovim.

Current problem I'm seeing: "nnoremap <Space>d YP" I'm trying to have space+d duplicate the current line, or current selection, but this doesn't seem to work at all using experimental.viml

I see that VSCode has support for editor.action.copyLinesDownAction and many other actions here: https://code.visualstudio.com/docs/getstarted/keybindings.

What level of feature parity between VSCode and these actions are we expecting onivim to support?

A few suggestions:

  1. Could we have key remapping available in the keybindings file, given that many of the actions from VSCode aren't available? That could solve my problem above I'm having.
  2. If we plan to support experimental.viml longer term, could we support the editor actions in that? ie: nnoremap <space>w :workbench.action.files.save
  3. Could we add support for "editor.action.commentLine", which would toggle a comment line?
  4. Any chance we could have workbench.action.nextEditor cycle back to beginning when it's reached the end? Same for previousEditor going the other way.
  5. Add support for open last buffer. (most recently visited)

Keep up the great work! Happy to issue PRs for any of these if they aren't too difficult.

jamischarles avatar Aug 28 '20 08:08 jamischarles

I'd love to see the spacevim/spacemacs majestic keybind #756 I think having space keybind combined with VSC support will increase the value of onivim. Both spacemacs and vscode vim emulation have their own drawbacks. And I think oni2 can strike a good balance between them. It's a juicy market of people who wants VSC power but want the efficient keybind of modal editing.

anyway I appreciate you guys for your hard work I don't hesitate in buying for second time if oni2 can deliver :)

reyzavk avatar Aug 30 '20 10:08 reyzavk

I have not found a way to bind a key to close a file/tab, even looking in the file that should have all the keybindings maybe I didn't look thoroughly enough ? Could someone perhaps tell me where I should be looking or is this not implemented yet as a keybinding and would require a PR ?

AkechiShiro avatar Sep 01 '20 12:09 AkechiShiro

@AkechiShiro took me a long time but this is the command {"key": "<space>q", "command": "view.closeEditor", "when": "normalMode && editorTextFocus" },

jamischarles avatar Sep 01 '20 12:09 jamischarles

I'm a big fan of using enter for completion and /<S-tab> to move through suggestion. This actually easier to set in vim than in vim with some autocompletion plugins.

{
      "key":"<S-Tab>",
      "command":"selectPrevSuggestion",
      "when":"editorTextFocus && suggestWidgetVisible"
   },
   {
      "key":"<Tab>",
      "command":"selectNextSuggestion",
      "when":"editorTextFocus && suggestWidgetVisible"
   },
   {
      "key":"<CR>",
      "command":"acceptSelectedSuggestion",
      "when":"suggestWidgetVisible && editorTextFocus"
   }

Th3Whit3Wolf avatar Sep 22 '20 14:09 Th3Whit3Wolf

I think it would be cool if there was a list of all possible values for command so that someone could make a mapping.vim => keybindings.json webapp.

Th3Whit3Wolf avatar Sep 22 '20 14:09 Th3Whit3Wolf

I wish :enew or "workbench.action.files.newUntitledFile" is implemented in keybindings Also, how can I set key bindings when I am focusing on FileExplorer? I tried to find something like listFocus, but could not find one.

spar7453 avatar Oct 17 '20 14:10 spar7453

@spar7453: You can bind to :enew: https://onivim.github.io/docs/configuration/key-bindings#ex-commands

glennsl avatar Oct 18 '20 09:10 glennsl

@glennsl I tried to bind as the following { "key": "< space>fn", "command": ":enew", when: "normalMode" } and it did not work.

I think that we cannot bind every vim commands in this way and also waiting for binding { "key": "< space>b1", "command": ":b2", when: "normalMode" }

(I had to put empty space in front of "s" because the editor removes "< space>")

spar7453 avatar Oct 20 '20 12:10 spar7453

@spar7453 Yeah that does seem broken. When trying it myself I can see from the logs that it's running the command, but then nothing happens. I've created #2604 to track it.

glennsl avatar Oct 21 '20 10:10 glennsl

How about Ctrl+] to toggle the terminal windows? As suggested here: https://discordapp.com/channels/417774914645262338/424012160696582144/785130754446327809

Is there a way we could bind the command :term ++curwin tmux to Ctrl+]?

RilDev avatar Dec 06 '20 19:12 RilDev

The issue should be updated to link to src/Model/State.re for list of all key bindings

marcinkoziej avatar Jan 21 '21 18:01 marcinkoziej

Is #1349 "Go to next error" done? Otherwise I might take a look at it this weekend, would be fun to get into the codebase and start contributing.

Szune avatar Feb 18 '21 23:02 Szune

Hi @Szune ,

Go to next error is not implemented yet - it would be awesome to have though! I find myself wanting it all the time 😄 Let me know if you need help getting started

bryphe avatar Feb 20 '21 00:02 bryphe

Cool @bryphe , I'll try to get started on it when I wake up later today 😃

Is there anything I should look at other than https://onivim.github.io/docs/for-developers/contributing before beginning?

Szune avatar Feb 20 '21 03:02 Szune