[
  {
    "context": "Pane",
    "bindings": {
      // unbind closing the tab with this
      "ctrl-w": null,
      "ctrl-w ctrl-h": ["workspace::ActivatePaneInDirection", "Left"],
      "ctrl-w ctrl-j": ["workspace::ActivatePaneInDirection", "Down"],
      "ctrl-w ctrl-k": ["workspace::ActivatePaneInDirection", "Up"],
      "ctrl-w ctrl-l": ["workspace::ActivatePaneInDirection", "Right"],
      "ctrl-shift-t": "pane::ReopenClosedItem",
      "ctrl-o": "pane::GoBack",
      "ctrl-i": "pane::GoForward"
      // "shift-escape": null
    }
  },
  {
    "context": "EmptyPane",
    "bindings": {
      ":": "command_palette::Toggle",
      "space p": "file_finder::Toggle"
    }
  },
  {
    "context": "os == macos && Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "cmd-d": "editor::SelectNext"
    }
  },
  {
    "bindings": {
      "ctrl-alt-shift-p": "projects::OpenRecent",
      "ctrl-alt-shift-o": "workspace::Open"
    }
  },
  {
    "context": "os == linux && Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "ctrl-shift-d": "editor::SelectNext"
    }
  },
  {
    "context": "MarkdownPreview || EmptyPane || Diagnostics || Editor && VimControl && !VimWaiting && !menu",
    "bindings": {
      "z space": "editor::FoldAll",
      "z backspace": "editor::FoldFunctionBodies",
      "z enter": "editor::UnfoldAll",

      "space b c": "pane::CloseActiveItem",
      ":": "command_palette::Toggle",
      "space p": "file_finder::Toggle",
      "space o": "pane::DeploySearch",

      "space h": "pane::ActivatePrevItem",
      "space l": "pane::ActivateNextItem",
      "space c space": "editor::ToggleComments",

      // go to search result
      "g space": "editor::OpenExcerpts",
      "space e j": "editor::ExpandExcerptsDown",
      "space e k": "editor::ExpandExcerptsUp",

      // multi-cursor
      "cmd-shift-d": "editor::SelectPrevious",
      "cmd-shift-l": "editor::SelectAllMatches",
      "ctrl-j": "editor::AddSelectionBelow",
      "ctrl-k": "editor::AddSelectionAbove",
      "alt-d": "editor::SelectNext",
      "alt-j": "editor::SelectAllMatches",
      // lsp
      "space m f": "editor::Format",
      "space m s": "project_symbols::Toggle",
      "space m g": "editor::GoToDefinition",
      "space m d": "editor::Hover",
      "space m n": "editor::Rename",
      "space m r": "editor::FindAllReferences",
      "space m t": "editor::GoToTypeDefinition",
      "space m e": "editor::GoToDiagnostic",
      "space m E": "editor::GoToPrevDiagnostic",
      "space m v": "editor::ToggleCodeActions",
      "space m o": "outline::Toggle",
      "space m h": "editor::ShowSignatureHelp",
      // diagnostics
      "space e e": "diagnostics::Deploy",
      "space e w": "diagnostics::ToggleWarnings",
      // view
      "space v n": "editor::ToggleLineNumbers",
      "space v i": "editor::ToggleInlayHints",
      // Git
      "space g b": "editor::ToggleGitBlame"
    }
  },
  {
    "context": "Editor && vim_mode == normal && !VimWaiting && !menu",
    "bindings": {
      "backspace": ["vim::PushOperator", { "Sneak": {} }],
      "return": ["vim::PushOperator", { "SneakBackward": {} }]
    }
  },
  {
    "context": "Editor && vim_mode == insert",
    "bindings": {
      "ctrl-w": "editor::DeleteToPreviousWordStart",
      "alt-tab": "zeta::NextEdit",
      "alt-shift-tab": "zeta::PreviousEdit"
    }
  },
  {
    "context": "os == linux && ((Editor && vim_mode == normal) || Terminal) && !VimWaiting && !menu",
    "bindings": {
      "ctrl-t ctrl-t": "terminal_panel::ToggleFocus",
      "ctrl-t ctrl-n": "workspace::NewTerminal",
      "ctrl-t ctrl-shift-n": "workspace::NewCenterTerminal",
      "ctrl-t ctrl-h": "pane::ActivatePrevItem",
      "ctrl-t ctrl-l": "pane::ActivateNextItem",
      "ctrl-x ctrl-c": "pane::CloseActiveItem",
      "ctrl-t ctrl-c": "pane::CloseActiveItem",

      "alt-j": "workspace::ToggleBottomDock"
    }
  },
  {
    "context": "os == macos && ((Editor && vim_mode == normal) || Terminal) && !VimWaiting && !menu",
    "bindings": {
      "cmd-t cmd-t": "terminal_panel::ToggleFocus",
      "cmd-t cmd-n": "workspace::NewTerminal",
      "cmd-t cmd-shift-n": "workspace::NewCenterTerminal",
      "cmd-t cmd-h": "pane::ActivatePrevItem",
      "cmd-t cmd-l": "pane::ActivateNextItem",
      "cmd-x cmd-c": "pane::CloseActiveItem"
    }
  },
  {
    "context": "os == linux && ((Editor && vim_mode == normal) || Terminal) && !VimWaiting && !menu",
    "bindings": {
      "alt-j": "workspace::ToggleBottomDock",
      "alt-t alt-t": "terminal_panel::ToggleFocus",
      "alt-t alt-n": "workspace::NewTerminal",
      "alt-t alt-shift-n": "workspace::NewCenterTerminal",
      "alt-t alt-h": "pane::ActivatePrevItem",
      "alt-t alt-l": "pane::ActivateNextItem",
      "alt-x alt-c": "pane::CloseActiveItem"
    }
  },
  {
    "context": "Editor && vim_mode == visual && !VimWaiting && !menu",
    "bindings": {
      "n": "editor::SelectLargerSyntaxNode",
      "N": "editor::SelectSmallerSyntaxNode",
      "m": "vim::SelectNext",
      "M": "vim::SelectPrevious",
      ",": "editor::SplitSelectionIntoLines"
    }
  },

  {
    "context": "ProjectSearchBar",
    "bindings": {
      "space b c": "pane::CloseActiveItem",
      "escape escape": "pane::CloseActiveItem"
    }
  },

  // Panel stuff
  {
    "context": "Editor && VimControl && !VimWaiting && !menu || OutlinePanel || ProjectPanel || Assistant || EmptyPane",
    "bindings": {
      "space v h": "workspace::ToggleLeftDock",
      "space v l": "workspace::ToggleRightDock",

      "space v o": "outline_panel::ToggleFocus",
      "space v p": "project_panel::ToggleFocus",
      "space v a": "assistant::ToggleFocus"
    }
  },
  {
    "context": "OutlinePanel",
    "bindings": {
      "space l": "outline_panel::ToggleFocus"
    }
  },
  {
    "context": "ProjectPanel",
    "bindings": {
      "space l": "project_panel::ToggleFocus"
    }
  },
  {
    "context": "Assistant",
    "bindings": {
      "space h": "assistant::ToggleFocus"
    }
  }
]
