Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default key binding for "dance.seek.askObject.inner" (alt+i) doesn't work on MacOS #220

Open
yyogo opened this issue Dec 23, 2021 · 10 comments

Comments

@yyogo
Copy link

yyogo commented Dec 23, 2021

Due to microsoft/vscode#41024, this key combination cannot be mapped on MacOS (as well as alt+`,e,n,u and possibly others)

I've remapped it to ctrl+i but I think the defaults should also be adjusted

@wooden-worm
Copy link

I'm having the same issue and had to change the input source to Unicode Hex Input for the shortcut to work.

I think dance can steal the match mode from helix: https://docs.helix-editor.com/keymap.html#match-mode

Essentially in helix you press m to enter its Match mode, which you can then follow by i to get into Match inner. So instead of Alt + i you press mi. Match mode shows a menu of possible options, so way easier to discover.

@zetashift
Copy link

Is there a way/example to configure Dance to use those helix type of keybindings? E.g. mi" for match inner quotation marks?

@yyogo
Copy link
Author

yyogo commented Aug 11, 2022

@zetashift you could remap m i to dance.seek.askObject.inner e.g:

    {
        "key": "m i",
        "command": "dance.seek.askObject.inner",
        "when": "editorTextFocus && dance.mode == 'normal'"
    },

A more advanced approach would be to map m to a custom menu, see e.g https://github.com/71/dance/wiki/Mirror-menu

@zetashift
Copy link

Thank you!

@yyogo
Copy link
Author

yyogo commented Aug 14, 2022

Added the config I'm using here

@zetashift
Copy link

Oh that's very nice, here is mine:

  "key": "m",
    "command": "dance.openMenu",
    "args": {
      "menu": {
        "items": {
          "i": {
            "text": "select inner object",
            "command": "dance.seek.askObject.inner"
          },
          "a": {
            "text": "select object",
            "command": "dance.seek.askObject"
          },
          "s": {
            "text": "surround around object",
            "command": "dance.openMenu",
            "args": {
              "menu": {
                "items": {
                  "(": {
                    "text": "(surround)",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '(' + x + ')')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "(" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": ")" }
                        ]
                      ]
                    }
                  },
                  "{": {
                    "text": "{surround}",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '{' + x + '}')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "{" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": "}" }
                        ]
                      ]
                    }
                  },
                  "[": {
                    "text": "[surround]",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '[' + x + ']')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "[" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": "]" }
                        ]
                      ]
                    }
                  },
                  "<": {
                    "text": "<surround>",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '<' + x + '>')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "<" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": ">" }
                        ]
                      ]
                    }
                  },
                  "\"": {
                    "text": "\"surround\"",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '\"' + x + '\"')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "\"" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": "\"" }
                        ]
                      ]
                    }
                  },
                  "'": {
                    "text": "'surround'",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => `'` + x + `'`)",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "'" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": "'" }
                        ]
                      ]
                    }
                  },
                  "`": {
                    "text": "`surround`",
                    "command": "dance.run",
                    "args": {
                      "input": "await replace((x) => '`' + x + '`')",
                      "commands": [
                        [
                          ".edit.insert",
                          { "where": "start", "shift": "extend", "text": "`" }
                        ],
                        [
                          ".edit.insert",
                          { "where": "end", "shift": "extend", "text": "`" }
                        ]
                      ]
                    }
                  }
                }
              }
            }
          },
          "d": {
            "text": "delete surround",
            "command": "dance.run",
            "args": {
              "input": "await replace((x) => x.slice(1, -1))",
              "commands": [
                ".selections.save",
                ".selections.reduce.edges",
                ".edit.delete",
                ".selections.restore"
              ]
            }
          }
        }
      }
    },
    "when": "editorTextFocus && dance.mode == 'normal'"
  },

@wooden-worm
Copy link

m conflicts with the default match command. @71 would you consider something similar to what @zetashift posted above?

@71
Copy link
Owner

71 commented Sep 9, 2022

For now the default keybindings are Kakoune's on Windows and Linux (though I'd like to change this), so I think we should keep the current command. The wiki is where we can put custom keybindings in the meantime.

@wooden-worm
Copy link

Sorry bad phrasing on my part. I meant would you consider adding a "match menu", which cover seek.Object commands https://github.com/71/dance/tree/master/src/commands#seekobject and probably surround add/delete as posted above? Of course with a different key than m since it's used.

It's just not a custom key binding but a new menu/feature.

@greneholt
Copy link

This StackOverflow answer explains how to completely prevent Option+key from producing special characters on Mac, allowing you to use these combinations for shortcuts in VS Code and various other editors.

In short:

  1. Download this QWERTY keyboard layout file (or generate one yourself using the instructions in the linked answer).
  2. Move it to ~/Library/Keyboard Layouts/
  3. Go to System Settings > Keyboard > Text Input > Input Sources > Edit.
  4. Click + in the bottom left, scroll to the bottom of the list on the left and select Others then select QWERTY no option and click Add.
  5. Either delete your existing layout (probably called U.S.) or just switch to the QWERTY no option layout using the input-source select in the menu bar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants