Skip to content
Tom Short edited this page Oct 29, 2021 · 1 revision

edamagit is a cool extension that mimics magit, a famous git interface for Emacs. This extension opens read-only buffers with status information, and the user can press keys to trigger git actions. Here are options to integrate this with Dance:

  1. Use a Dance menu. The menu makes it easier to find less-used commands.
  2. Support magit keys in the magit status buffer. Adding keys to keybindings.json by pasting in these key settings. Copy only the keys you want, or comment out unwanted keys.

Here are the edamagit keys:

Popup and dwim commands
  A Cherry-pick      b Branch           c Commit
  d Diff             f Fetch            F Pull
  I Ignore           l Log              m Merge
  M Remote           P Push             r Rebase
  t Tag              V Revert           X Reset
  y Show Refs        z Stash            shift+1 Run
  shift+5 Worktree   o Submodules       shift+4 Process Log

Applying changes
  a Apply          s Stage          u Unstage
  v Reverse        S Stage all      U Unstage all
  k Discard

Essential commands
  g        refresh current buffer
  TAB      toggle section at point
  RET      visit thing at point
  shift+4  show git process view
  q        exit / close magit view

  ctrl+j Move cursor to next entity
  ctrl+k Move cursor to previous entity

Magit menu

Here is a Dance menu for use in magit buffers (defined in settings.json):

    "dance.menus": {
        "magit": {
            "items": {
                "g": { "text": "refresh", "command": "magit.refresh" },
                "f": { "text": "fetching", "command": "magit.fetching" },
                "b": { "text": "branching", "command": "magit.branching" },
                "m": { "text": "merging", "command": "magit.merging" },
                "r": { "text": "rebasing", "command": "magit.rebasing" },
                "P": { "text": "pushing", "command": "magit.pushing" },
                "F": { "text": "pulling", "command": "magit.pulling" },
                "z": { "text": "stashing", "command": "magit.stashing" },
                "x": { "text": "reset-mixed", "command": "magit.reset-mixed" },
                "X": { "text": "resetting", "command": "magit.resetting" },
                "H": { "text": "reset-hard", "command": "magit.reset-hard" },
                "c": { "text": "commit", "command": "magit.commit" },
                "M": { "text": "remoting", "command": "magit.remoting" },
                "l": { "text": "logging", "command": "magit.logging" },
                "y": { "text": "show-refs", "command": "magit.show-refs" },
                "d": { "text": "diffing", "command": "magit.diffing" },
                "t": { "text": "tagging", "command": "magit.tagging" },
                "A": { "text": "cherry-picking", "command": "magit.cherry-picking" },
                "V": { "text": "reverting", "command": "magit.reverting" },
                "i": { "text": "ignoring", "command": "magit.ignoring" },
                "!": { "text": "running", "command": "magit.running" },
                "%": { "text": "worktree", "command": "magit.worktree" },
                "o": { "text": "submodules", "command": "magit.submodules" },
                "k": { "text": "discard", "command": "magit.discard-at-point" },
                "a": { "text": "apply", "command": "magit.apply-at-point" },
                "v": { "text": "reverse", "command": "magit.reverse-at-point" },
                "s": { "text": "stage", "command": "magit.stage" },
                "S": { "text": "stage-all", "command": "magit.stage-all" },
                "u": { "text": "unstage", "command": "magit.unstage" },
                "U": { "text": "unstage-all", "command": "magit.unstage-all" },
                "$": { "text": "process-log", "command": "magit.process-log" },
                "?": { "text": "help", "command": "magit.help" },
                "q": { "text": "quit", "command": "magit.quit" },
            }
        },
    ...
    }

Key bindings

Here are some keys that can be defined in magit buffers in keybindings.json. The main conflicts where Dance/Kakoune keys should prevail are: k and x/X. Important magit keys to use in the magit buffers include at least: TAB, Enter, q, s, S, u, U, b, and c. Here are some common keys defined. See these key settings for more. You also need a key binding for magit.status, the command that launches the magit status buffer. That can be a normal key binding or a call from a Dance menu.

      {
        "key": "m",
        "command": "dance.openMenu",
        "args": { "input": "magit" },
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.toggle-fold",
        "key": "tab",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.quit",
        "key": "q",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.visit-at-point",
        "key": "enter",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.apply-at-point",
        "key": "a",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.reverse-at-point",
        "key": "v",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.commit",
        "key": "c",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.branching",
        "key": "b",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.stage",
        "key": "s",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.stage-all",
        "key": "shift+s",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.unstage",
        "key": "u",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },
      {
        "command": "magit.unstage-all",
        "key": "shift+u",
        "when": "editorTextFocus && editorLangId == 'magit'"
      },