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

47 lines
1.3 KiB
Plaintext
Raw Normal View History

2022-04-20 14:27:26 +00:00
(let [mod {}
wezterm (require :wezterm)]
(fn exe [bin] (vim.fn.exepath bin))
2022-05-25 20:34:02 +00:00
2023-10-15 22:46:09 +00:00
(fn open-split [program-fn]
(let [args [:cli :split-pane :--bottom :--percent :30 "--"]
program (program-fn)]
(each [_ value (ipairs program)]
(table.insert args value))
2023-12-27 23:32:09 +00:00
(wezterm.exec args
(fn [result]
(when (not= result.code 0)
(vim.notify "wezterm: Error opening split window"
vim.log.levels.ERROR []))))))
2022-05-25 20:34:02 +00:00
2023-10-15 22:46:09 +00:00
(local elixir #[(exe :iex)])
(local erlang #[(exe :erl)])
(local fennel #[(exe :fennel) :--repl])
(local fish #[(exe :fish)])
(local java #[(exe :jshell)])
(local javascript #[(exe :node)])
(local nix #[(exe :nix) :repl])
(local ruby #[(exe :irb)])
(local typescript #[(exe :node)])
2022-04-20 14:27:26 +00:00
;; Map filetype to REPL
2023-10-15 22:46:09 +00:00
(local repl-map {: elixir
: erlang
: fennel
: fish
: java
: javascript
: nix
: ruby
: typescript})
2022-04-20 14:27:26 +00:00
(fn mod.open-shell []
2022-04-20 14:27:26 +00:00
(let [shell (. repl-map :fish)]
2023-10-15 22:46:09 +00:00
(open-split shell)))
2022-04-20 14:27:26 +00:00
(fn mod.open-repl []
2022-04-20 14:27:26 +00:00
(let [ft vim.bo.filetype
repl (. repl-map ft)]
(when (not= repl nil)
2023-10-15 22:46:09 +00:00
(open-split repl))))
2022-08-25 22:49:54 +00:00
2022-04-20 14:27:26 +00:00
mod)