diff options
Diffstat (limited to 'autoload/repl.kak')
| -rw-r--r-- | autoload/repl.kak | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/autoload/repl.kak b/autoload/repl.kak index 372a54a..933664e 100644 --- a/autoload/repl.kak +++ b/autoload/repl.kak @@ -1,20 +1,20 @@ declare-option bool xrepl_running false; declare-option str xrepl_current_cmd; declare-option str xrepl_current_transform; +declare-option bool xrepl_current_clear_screen false; # TODO: Add env -# TODO: Add clear screen # TODO: Migrate curly # TODO: Preserve original selection with send paragraph -# TODO: Add prompt -# TODO: Add send c-c -# TODO: Add send buffile declare-user-mode repl-mode-select define-command define-repl-mode -params 3 %{ + # TODO: USe a hidden command and use for keymap map global repl-mode-select %arg{1} -docstring %arg{2} %sh{ kak_escape() { printf "'"; printf '%s' "$1" | sed "s/'/''/g"; printf "'"; } printf ": xrepl-quit<ret>" + printf ": set global xrepl_current_transform \"\"<ret>" + printf ": set global xrepl_current_clear_screen false<ret>" printf ": evaluate-commands $(kak_escape "$(echo "$3" | tr '\n' ';')")<ret>" printf ": xrepl-begin<ret>" } @@ -22,31 +22,39 @@ define-command define-repl-mode -params 3 %{ define-repl-mode n 'Node' %{ set global xrepl_current_cmd 'node' - set global xrepl_current_transform "" } define-repl-mode s 'Shell' %{ set global xrepl_current_cmd '$SHELL' - set global xrepl_current_transform "" } +# TODO: Only cd inside sh define-repl-mode j 'Jest' %{ set global xrepl_current_cmd '$SHELL' set global xrepl_current_transform 'cat > /dev/null - echo "cd \"$(dirname "$kak_buffile")\" && npx jest --runTestsByPath \\\"$kak_buffile\\\";" + echo "sh -c \\"cd ''$(dirname "$kak_buffile")''; npx jest --runTestsByPath ''$kak_buffile''\\";" ' + set global xrepl_current_clear_screen true } define-repl-mode c 'Cypress' %{ set global xrepl_current_cmd '$SHELL' set global xrepl_current_transform 'cat > /dev/null - echo "npx cypress run --headless --e2e --spec $kak_buffile;" + echo "npx cypress run --headless --e2e --spec ''$kak_buffile'';" ' + set global xrepl_current_clear_screen true } define-repl-mode a 'AI: Gemini' %{ set global xrepl_current_cmd 'gemini' - set global xrepl_current_transform "" +} + +define-command xrepl-send-prompt %{ + prompt -buffer-completion 'Send to repl: ' %{ repl-send-text %val{text} } } define-command xrepl-send-command %{ evaluate-commands -draft %sh{ + if [ "$kak_opt_xrepl_current_clear_screen" == "true" ]; then + echo "xrepl-send-keys C-l" + fi + transform="$kak_opt_xrepl_current_transform" value="$kak_selection" if ! [ -z "$transform" ]; then @@ -81,7 +89,7 @@ define-command xrepl-begin %{ init_cmd="$kak_opt_xrepl_current_cmd" if [ -z "$init_cmd" ]; then init_cmd="$SHELL"; fi echo "set-option global xrepl_running true" - echo "repl-new $init_cmd" + echo "repl-new -l 45% $init_cmd" echo "nop %sh{ tmux last-pane }" fi } @@ -96,5 +104,6 @@ map global repl l ': xrepl-send-command<ret>' map global repl r ': xrepl-send-keys Enter<ret>' map global repl c ': xrepl-send-keys C-c<ret>' map global repl q ': xrepl-quit<ret>' -# map global repl <tab> ': xrepl-select<ret>' +map global repl p ': xrepl-send-prompt<ret>' map global repl <tab> ': enter-user-mode repl-mode-select<ret>' + |
