1
0
Fork 0
dotfiles/home/config/nvim/nifoc/repl.fnl

55 lines
2 KiB
Fennel

(let [mod {}
terminal-class (require :toggleterm.terminal)
terminal terminal-class.Terminal]
(fn repl-setup []
(set vim.b.nifoc_shell_mode :REPL))
(fn generic-setup [label]
(set vim.b.nifoc_shell_mode label))
(local elixir (terminal:new {:cmd :iex
:on_open repl-setup
:close_on_exit true}))
(local erlang (terminal:new {:cmd :erl
:on_open repl-setup
:close_on_exit true}))
(local fennel (terminal:new {:cmd "fennel --repl"
:on_open repl-setup
:close_on_exit true}))
(local fish (terminal:new {:cmd :fish
:on_open #(generic-setup :SHELL)
:close_on_exit true}))
(local javascript (terminal:new {:cmd :node
:on_open repl-setup
:close_on_exit true}))
(local nix (terminal:new {:cmd "nix repl"
:on_open repl-setup
:close_on_exit true}))
(local ruby
(terminal:new {:cmd :irb :on_open repl-setup :close_on_exit true}))
;; Map filetype to REPL
(local repl-map {: elixir : erlang : fennel : fish : javascript : nix : ruby})
;; Various specific shell windows
(local specific-shell
{:vcs (terminal:new {:cmd :fish
:on_open #(generic-setup :VCS)
:direction :float
:close_on_exit true
:float_opts {:border :rounded}})})
(fn mod.toggle-shell []
(let [shell (. repl-map :fish)]
(shell:toggle)))
(fn mod.toggle-repl []
(let [ft vim.bo.filetype
repl (. repl-map ft)]
(when (not= repl nil)
(repl:toggle))))
(fn mod.toggle-specific-shell [name]
(let [shell (. specific-shell name)]
(shell:toggle)))
mod)