aboutsummaryrefslogtreecommitdiff
path: root/autoload/repl/repl_modes.kak
blob: 6b7550beeee7853b572da4e7d09e448d541812e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
define-repl-mode global s 'Shell' %{ set global xrepl_current_cmd 'kcr shell' }
define-repl-mode global n 'Node' %{ set global xrepl_current_cmd 'node' }
define-repl-mode global a 'AI: Claude' %{ set global xrepl_current_cmd 'claude' }

# Send makecmd to shell
define-repl-mode global M 'Makecmd' %{
  set global xrepl_current_cmd 'kcr shell'
  set global xrepl_current_transform 'cat > /dev/null; echo $kak_opt_makecmd'
}

hook global BufSetOption filetype=haskell %{
  define-repl-mode buffer h 'Haskell: cabal test' %{
    # TODO: maybe use current test file path
    set global xrepl_current_cmd 'cabal test'
    set global xrepl_current_clear_screen true
  }
}

hook global BufSetOption filetype=ruby %{
  define-repl-mode buffer c 'Rails console' %{
    set global xrepl_current_cmd '${KAK_BUNDLE_EXEC:-"bundle exec"} rails console'
  }
  define-repl-mode buffer r 'Rspec' %{
    set global xrepl_current_cmd 'kcr shell'
    set global xrepl_current_transform 'cat > /dev/null
      path=$(realpath -s --relative-to="$PWD" "$kak_buffile")
      if [ "$kak_cursor_line" -gt 5 ]; then path="$path:$kak_cursor_line"; fi
      echo "eval \${KAK_BUNDLE_EXEC:-"bundle exec"} rspec -fd ''$path'' "
    '
    set global xrepl_current_clear_screen true
  }
}

hook global BufSetOption filetype=(?:javascript|typescript|jsx|tsx) %{
  # TODO: Search for root cypress config file and cd into it
  # set global xrepl_current_cmd '(echo "::$kak_config::" | tee foob) && '
  define-repl-mode buffer c 'Cypress' %{
    set global xrepl_current_cmd 'kcr shell'
    set global xrepl_current_transform 'cat > /dev/null
      cypress_config_files="cypress.config.json cypress.config.ts cypress.config.js"
      project=$($kak_config/scripts/utils.sh find_closest "$kak_buffile" $cypress_config_files)
      echo "npx cypress run --headless --e2e -P" "''$project''" "--spec ''$kak_buffile'';"
    '
    set global xrepl_current_clear_screen true
  }
  define-repl-mode global j 'Jest' %{
    set global xrepl_current_cmd 'kcr shell'
    set global xrepl_current_transform 'cat > /dev/null
      echo "sh -c \\"cd ''$(dirname "$kak_buffile")''; npx jest --runTestsByPath ''$kak_buffile''\\";"
    '
    set global xrepl_current_clear_screen true
  }
}

# hook global BufSetOption filetype=clojure %{
#   # TODO: Just temporary for messing around. Remove module name
#   map buffer repl r ': xrepl-send-text %{(require ''[pluribus.core :as p] :reload)}; xrepl-send-keys Enter<ret>' -docstring 'Cljs reload'
#   define-repl-mode buffer j 'Clojurescript repl' %{
#     set global xrepl_current_cmd 'clj -M -m cljs.main --repl-opts "{:launch-browser false}" --compile pluribus.core --repl'
#     set global xrepl_current_split_size 30%%
#     set global xrepl_current_split_vertical true
#   }
# }