dotfiles/home/config/nvim/nifoc/repl.fnl

56 lines
2 KiB
Text
Raw Normal View History

2022-04-20 14:27:26 +00:00
(let [mod {}
terminal-class (require :toggleterm.terminal)
terminal terminal-class.Terminal]
2022-05-25 20:34:02 +00:00
(fn repl-setup []
(set vim.b.nifoc_shell_mode :REPL))
2022-08-25 22:49:54 +00:00
(fn generic-setup [label]
(set vim.b.nifoc_shell_mode label))
2022-05-25 20:34:02 +00:00
(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
2022-08-25 22:49:54 +00:00
:on_open #(generic-setup :SHELL)
2022-05-25 20:34:02 +00:00
: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}))
2022-04-20 14:27:26 +00:00
;; Map filetype to REPL
(local repl-map {: elixir : erlang : fennel : fish : javascript : nix : ruby})
2022-08-25 22:49:54 +00:00
;; 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}})})
2022-04-20 14:27:26 +00:00
(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))))
2022-08-25 22:49:54 +00:00
(fn mod.toggle-specific-shell [name]
(let [shell (. specific-shell name)]
(shell:toggle)))
2022-04-20 14:27:26 +00:00
mod)