Skip to content

Commit

Permalink
progress on vim keybindings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimaoth committed Jan 21, 2024
1 parent ffce6a3 commit 91936fe
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 6 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,13 @@ More details in [Getting Started](docs/getting_started.md)
- finish/revise using string as parameter type for wasm functions (see createWasmWrapper, createHostWrapper)
- fix potential issues because of loading order when loading test-language and test-language-playground

## Vim Keybindings
- Repeat f/t motions with ,/;
- Repeat insert mode commands with .
- Macros
- Search/Replace
- Visual line mode
- More text objects


[Test report](https://nimaoth.github.io/Absytree/testresults.html)
Binary file modified config/absytree_config_wasm.wasm
Binary file not shown.
1 change: 0 additions & 1 deletion config/keybindings_vim.nim
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ proc loadVimKeybindings*() {.scriptActionWasmNims("load-vim-keybindings").} =
addSubCommand "", "move", "^", "vim-move-first", "line-no-indent"

addSubCommandWithCount "", "move", "$", vimMoveToEndOfLine
addSubCommandWithCount "", "move", "<S-$>", vimMoveToEndOfLine
addSubCommandWithCount "", "move", "<END>", vimMoveToEndOfLine

addSubCommand "", "move", "g0", "vim-move-first", "line"
Expand Down
14 changes: 9 additions & 5 deletions src/input.nim
Original file line number Diff line number Diff line change
Expand Up @@ -662,15 +662,19 @@ proc handleNextInput(
let rune = Rune(key.inputCodes.a)
let rune2 = Rune(key.inputCodes.b)
let bIsLower = rune.isLower
if not bIsLower and rune.isUpper:
if not bIsLower:
# echo "| ".repeat(depth) & &" link state {currentState} to {nextState} for {rune.toLower} and {rune.toUpper}"
discard linkStates(dfa, currentState, nextState, rune.toLower.int64..rune2.toLower.int64, key.mods + {Shift}, functionIndex, capture)
discard linkStates(dfa, currentState, nextState, key.inputCodes, key.mods + {Shift}, functionIndex, capture)
if not linkStates(dfa, currentState, nextState, rune.toLower.int64..rune2.toLower.int64, key.mods + {Shift}, functionIndex, capture):
log lvlError, fmt"""Ambigious keybinding '{input.join("")}' at {index} ({inputToString(key.inputCodes, key.mods)})"""
if not linkStates(dfa, currentState, nextState, key.inputCodes, key.mods + {Shift}, functionIndex, capture):
log lvlError, fmt"""Ambigious keybinding '{input.join("")}' at {index} ({inputToString(key.inputCodes, key.mods)})"""

if bIsLower and Shift in key.mods:
# echo "| ".repeat(depth) & &" link state {currentState} to {nextState} for {rune.toLower} and {rune.toUpper}"
discard linkStates(dfa, currentState, nextState, rune.toUpper.int64..rune2.toUpper.int64, key.mods - {Shift}, functionIndex, capture)
discard linkStates(dfa, currentState, nextState, rune.toUpper.int64..rune2.toUpper.int64, key.mods, functionIndex, capture)
if not linkStates(dfa, currentState, nextState, rune.toUpper.int64..rune2.toUpper.int64, key.mods - {Shift}, functionIndex, capture):
log lvlError, fmt"""Ambigious keybinding '{input.join("")}' at {index} ({inputToString(key.inputCodes, key.mods)})"""
if not linkStates(dfa, currentState, nextState, rune.toUpper.int64..rune2.toUpper.int64, key.mods, functionIndex, capture):
log lvlError, fmt"""Ambigious keybinding '{input.join("")}' at {index} ({inputToString(key.inputCodes, key.mods)})"""

nextState

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/input/tinput.nim
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ suite "Input DFA":
commands.add ("aB<A-c><C-ENTER>", "success")
var dfa = buildDFA(commands, @[""])
check dfa.stepString("aB<A-c><C-ENTER>") == "success"

test "<S-:>":
var commands: seq[(string, string)] = @[]
commands.add ("<S-:>", "success")
var dfa = buildDFA(commands, @[""])
writeFile("dfa2.dot", dfa.dumpGraphViz())
check dfa.stepString("<S-:>") == "success"

0 comments on commit 91936fe

Please sign in to comment.