diff --git a/config/absytree_config_wasm.wasm b/config/absytree_config_wasm.wasm index 3499ecaa..38bcde99 100755 Binary files a/config/absytree_config_wasm.wasm and b/config/absytree_config_wasm.wasm differ diff --git a/config/keybindings_vim.nim b/config/keybindings_vim.nim index d50fd38c..fd9f6857 100644 --- a/config/keybindings_vim.nim +++ b/config/keybindings_vim.nim @@ -416,7 +416,8 @@ proc moveSelectionEnd(editor: TextDocumentEditor, move: string, backwards: bool break else: continue - if editor.getLine(selection.last.line)[selection.last.column] notin Whitespace: + if selection.last.column < editor.lineLength(selection.last.line) and + editor.getLine(selection.last.line)[selection.last.column] notin Whitespace: res = cursor break res.toSelection(it, which) @@ -532,7 +533,14 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = setModeChangedHandler proc(editor, oldMode, newMode: auto) = # infof"vim: handle mode change {oldMode} -> {newMode}" - if newMode != "normal": + if newMode == "normal": + if not isReplayingCommands(): + stopRecordingCommands(".") + else: + if oldMode == "normal" and not isReplayingCommands(): + editor.recordCurrentCommand() + setRegisterText("", ".") + startRecordingCommands(".") editor.clearCurrentCommandHistory(retainLast=true) if newMode == "visual-line": @@ -567,6 +575,9 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = addTextCommandBlock "", "": editor.setMode("normal") addTextCommandBlock "", "": editor.setMode("normal") + addTextCommandBlock "", "s": replayCommands(".") + addTextCommandBlock "", ".": replayCommands(".") + # windowing proc defineWindowingCommands(prefix: string) = withKeys prefix: @@ -623,11 +634,15 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = addSubCommandWithCount "", "move", "h", "vim-move-cursor-column", -1 addSubCommandWithCount "", "move", "", "vim-move-cursor-column", -1 - addSubCommandWithCount "", "move", "", "vim-move-cursor-column", -1 + + # todo: this clashes with insert mode because it ises and binds directly + # addSubCommandWithCount "", "move", "", "vim-move-cursor-column", -1 addSubCommandWithCount "", "move", "l", "vim-move-cursor-column", 1 addSubCommandWithCount "", "move", "", "vim-move-cursor-column", 1 - addSubCommandWithCount "", "move", "", "vim-move-cursor-column", 1 + + # todo: this clashes with insert mode because it ises and binds directly + # addSubCommandWithCount "", "move", "", "vim-move-cursor-column", 1 addSubCommand "", "move", "0", "vim-move-first", "line" addSubCommand "", "move", "", "vim-move-first", "line" @@ -654,7 +669,8 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = addSubCommandWithCount "", "move", "j", "vim-move-cursor-line", 1 addSubCommandWithCount "", "move", "", "vim-move-cursor-line", 1 - addSubCommandWithCount "", "move", "", "vim-move-cursor-line", 1 + # todo: this clashes with insert mode because it ises and binds directly + # addSubCommandWithCount "", "move", "", "vim-move-cursor-line", 1 addSubCommandWithCount "", "move", "", "vim-move-cursor-line", 1 addSubCommandWithCount "", "move", "", "vim-move-cursor-line", 1 @@ -759,26 +775,27 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = # Mode switches addTextCommandBlock "normal", "a": - editor.selections = editor.selections.mapIt(editor.doMoveCursorColumn(it.last, 1).toSelection) + editor.selections = editor.selections.mapIt(editor.doMoveCursorColumn(it.last, 1, wrap=false).toSelection) editor.setMode "insert" addTextCommandBlock "", "A": - editor.moveLast "line" + editor.moveLast "line", Both + editor.setMode "insert" + addTextCommandBlock "normal", "i": editor.setMode "insert" - addTextCommand "normal", "i", "set-mode", "insert" addTextCommandBlock "", "I": - editor.moveFirst "line-no-indent" + editor.moveFirst "line-no-indent", Both editor.setMode "insert" addTextCommandBlock "normal", "gI": - editor.moveFirst "line" + editor.moveFirst "line", Both editor.setMode "insert" addTextCommandBlock "normal", "o": - editor.moveLast "line" + editor.moveLast "line", Both editor.insertText "\n" editor.setMode "insert" addTextCommandBlock "normal", "O": - editor.moveFirst "line" + editor.moveFirst "line", Both editor.insertText "\n" editor.vimMoveCursorLine -1 editor.setMode "insert" @@ -879,6 +896,7 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} = addTextCommand "insert", "", "indent" addTextCommand "insert", "", "unindent" + addTextCommand "insert", "", "vim-select-last " # Visual mode addTextCommandBlock "", "v":