diff --git a/config/default_config.nim b/config/default_config.nim index 1d8c56ab..c7a70fc9 100644 --- a/config/default_config.nim +++ b/config/default_config.nim @@ -1,14 +1,6 @@ import absytree_runtime import std/[strutils, sugar, sequtils, macros, json] -import keybindings_vim -import keybindings_helix -import keybindings_normal - -export keybindings_vim -export keybindings_helix -export keybindings_normal - import languages # Only when compiled to wasm. @@ -183,10 +175,6 @@ proc loadDefaultKeybindings*(clearExisting: bool = false) = setOption("editor.text.line-numbers", LineNumbers.Relative) requestRender(true) - addCommand "editor", "kn", () => loadNormalKeybindings() - addCommand "editor", "kv", () => loadVimKeybindings() - addCommand "editor", "kh", () => loadHelixKeybindings() - addCommandBlock "editor", "dl": lspLogVerbose(true) addCommandBlock "editor", "dL": lspLogVerbose(false) @@ -209,63 +197,61 @@ proc loadDefaultKeybindings*(clearExisting: bool = false) = addCommand "popup.selector", "", "prev-x" addCommand "popup.selector", "", "next-x" - loadNormalKeybindings() - - addCommand "editor.text", "ts", "reload-treesitter" - - setHandleInputs("editor.model", true) - addCommand("editor.model", "", "move-cursor-left-line") - addCommand("editor.model", "", "move-cursor-right-line") - addCommand("editor.model", "", "move-cursor-left") - addCommand("editor.model", "", "move-cursor-right") - addCommand("editor.model", "", "move-cursor-up") - addCommand("editor.model", "", "move-cursor-down") - addCommand("editor.model", "", "select-node") - addCommand("editor.model", "", "move-cursor-down") - addCommand("editor.model", "", "move-cursor-left-cell") - addCommand("editor.model", "", "move-cursor-right-cell") - addCommand("editor.model", "", "move-cursor-line-start") - addCommand("editor.model", "", "move-cursor-line-end") - addCommand("editor.model", "", "move-cursor-line-start-inline") - addCommand("editor.model", "", "move-cursor-line-end-inline") - - addCommand("editor.model", "", "move-cursor-left-line", true) - addCommand("editor.model", "", "move-cursor-right-line", true) - addCommand("editor.model", "", "move-cursor-left", true) - addCommand("editor.model", "", "move-cursor-right", true) - addCommand("editor.model", "", "move-cursor-up", true) - addCommand("editor.model", "", "move-cursor-down", true) - addCommand("editor.model", "", "move-cursor-up", true) - addCommand("editor.model", "", "move-cursor-down", true) - addCommand("editor.model", "", "move-cursor-left-cell", true) - addCommand("editor.model", "", "move-cursor-right-cell", true) - addCommand("editor.model", "", "move-cursor-line-start", true) - addCommand("editor.model", "", "move-cursor-line-end", true) - addCommand("editor.model", "", "move-cursor-line-start-inline", true) - addCommand("editor.model", "", "move-cursor-line-end-inline", true) - - addCommand("editor.model", "", "undo") - addCommand("editor.model", "", "redo") - addCommand("editor.model", "", "replace-left") - addCommand("editor.model", "", "replace-right") - addCommand("editor.model", "", "insert-text-at-cursor", " ") - addCommand("editor.model", "", "create-new-node") - addCommand("editor.model", "", "select-next-placeholder") - addCommand("editor.model", "", "select-prev-placeholder") - - addCommand("editor.model", "", "show-completions") - - addCommand("editor.model", "mr", "run-selected-function") - addCommand("editor.model", "md", "toggle-use-default-cell-builder") - - addCommand("editor.model.completion", "", "finish-edit", true) - addCommand("editor.model.completion", "", "hide-completions") - addCommand("editor.model.completion", "", "select-prev-completion") - addCommand("editor.model.completion", "", "select-next-completion") - addCommand("editor.model.completion", "", "move-cursor-start") - addCommand("editor.model.completion", "", "apply-selected-completion") - - addCommand "editor.model.goto", "", "end" + # addCommand "editor.text", "ts", "reload-treesitter" + + # setHandleInputs("editor.model", true) + # addCommand("editor.model", "", "move-cursor-left-line") + # addCommand("editor.model", "", "move-cursor-right-line") + # addCommand("editor.model", "", "move-cursor-left") + # addCommand("editor.model", "", "move-cursor-right") + # addCommand("editor.model", "", "move-cursor-up") + # addCommand("editor.model", "", "move-cursor-down") + # addCommand("editor.model", "", "select-node") + # addCommand("editor.model", "", "move-cursor-down") + # addCommand("editor.model", "", "move-cursor-left-cell") + # addCommand("editor.model", "", "move-cursor-right-cell") + # addCommand("editor.model", "", "move-cursor-line-start") + # addCommand("editor.model", "", "move-cursor-line-end") + # addCommand("editor.model", "", "move-cursor-line-start-inline") + # addCommand("editor.model", "", "move-cursor-line-end-inline") + + # addCommand("editor.model", "", "move-cursor-left-line", true) + # addCommand("editor.model", "", "move-cursor-right-line", true) + # addCommand("editor.model", "", "move-cursor-left", true) + # addCommand("editor.model", "", "move-cursor-right", true) + # addCommand("editor.model", "", "move-cursor-up", true) + # addCommand("editor.model", "", "move-cursor-down", true) + # addCommand("editor.model", "", "move-cursor-up", true) + # addCommand("editor.model", "", "move-cursor-down", true) + # addCommand("editor.model", "", "move-cursor-left-cell", true) + # addCommand("editor.model", "", "move-cursor-right-cell", true) + # addCommand("editor.model", "", "move-cursor-line-start", true) + # addCommand("editor.model", "", "move-cursor-line-end", true) + # addCommand("editor.model", "", "move-cursor-line-start-inline", true) + # addCommand("editor.model", "", "move-cursor-line-end-inline", true) + + # addCommand("editor.model", "", "undo") + # addCommand("editor.model", "", "redo") + # addCommand("editor.model", "", "replace-left") + # addCommand("editor.model", "", "replace-right") + # addCommand("editor.model", "", "insert-text-at-cursor", " ") + # addCommand("editor.model", "", "create-new-node") + # addCommand("editor.model", "", "select-next-placeholder") + # addCommand("editor.model", "", "select-prev-placeholder") + + # addCommand("editor.model", "", "show-completions") + + # addCommand("editor.model", "mr", "run-selected-function") + # addCommand("editor.model", "md", "toggle-use-default-cell-builder") + + # addCommand("editor.model.completion", "", "finish-edit", true) + # addCommand("editor.model.completion", "", "hide-completions") + # addCommand("editor.model.completion", "", "select-prev-completion") + # addCommand("editor.model.completion", "", "select-next-completion") + # addCommand("editor.model.completion", "", "move-cursor-start") + # addCommand("editor.model.completion", "", "apply-selected-completion") + + # addCommand "editor.model.goto", "", "end" proc exampleScriptAction*(a: int, b: string): string {.scriptActionWasmNims("example-script-action").} = ## Test documentation stuff diff --git a/config/keybindings_vim.nim b/config/keybindings_vim.nim index 30e733a9..735f4da5 100644 --- a/config/keybindings_vim.nim +++ b/config/keybindings_vim.nim @@ -2,6 +2,9 @@ import std/[strutils, setutils] import absytree_runtime, keybindings_normal import misc/[timer] + +infof"import vim keybindings" + proc getVimLineMargin*(): float = getOption[float]("editor.text.vim.line-margin", 5) proc getVimClipboard*(): string = getOption[string]("editor.text.vim.clipboard", "") proc getVimDefaultRegister*(): string = @@ -272,6 +275,7 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = setOption "editor.text.cursor.wide.", true setModeChangedHandler proc(editor, oldMode, newMode: auto) = + # infof"vim: handle mode change {oldMode} -> {newMode}" if newMode != "normal": editor.clearCurrentCommandHistory(retainLast=true) @@ -310,6 +314,25 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = editor.setMode("normal") editor.selection = editor.selection.last.toSelection + # windowing + addCommand "editor", "", "prev-view" + addCommand "editor", "h", "prev-view" + addCommand "editor", "", "prev-view" + addCommand "editor", "", "next-view" + addCommand "editor", "l", "next-view" + addCommand "editor", "", "next-view" + addCommand "editor", "w", "next-view" + addCommand "editor", "", "next-view" + addCommand "editor", "p", "open-previous-editor" + addCommand "editor", "", "open-previous-editor" + addCommand "editor", "p", "open-previous-editor" + addCommand "editor", "", "open-previous-editor" + + # not very vim like, but the windowing system works quite differently + addCommand "editor", "H", "move-current-view-prev" + addCommand "editor", "L", "move-current-view-next" + addCommand "editor", "W", "move-current-view-to-top" + # navigation (horizontal) addTextCommand "", "h", "vim-move-cursor-column", -1