summaryrefslogtreecommitdiff
path: root/fnl/settings/terminal.fnl
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2026-02-26 22:44:44 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2026-02-26 22:44:44 +0100
commit9b57b887676d7a86936e67d4a8c0bd1d9775ee62 (patch)
tree057dc291101c04b016c3cc50e12d8a4fede28d4e /fnl/settings/terminal.fnl
parent0f145ff5caa411e9c831e3c5c09ef2c8b40be3bf (diff)
Add toggle termHEADmaster
Diffstat (limited to 'fnl/settings/terminal.fnl')
-rw-r--r--fnl/settings/terminal.fnl25
1 files changed, 25 insertions, 0 deletions
diff --git a/fnl/settings/terminal.fnl b/fnl/settings/terminal.fnl
new file mode 100644
index 0000000..16464ee
--- /dev/null
+++ b/fnl/settings/terminal.fnl
@@ -0,0 +1,25 @@
+(local state {:buf -1 :win -1})
+
+(fn hide-term []
+ (vim.api.nvim_win_hide state.win))
+
+(fn open-term []
+ (let [height (math.floor (* vim.o.lines 0.3))]
+ (vim.cmd (.. "botright " height :new))
+ (set state.win (vim.api.nvim_get_current_win))
+ (if (not (vim.api.nvim_buf_is_valid state.buf))
+ (do
+ (set state.buf (vim.api.nvim_get_current_buf))
+ (vim.fn.termopen vim.o.shell)
+ (set vim.opt_local.number false)
+ (set vim.opt_local.relativenumber false)
+ (set vim.opt_local.signcolumn :no))
+ (vim.api.nvim_win_set_buf state.win state.buf))
+ (vim.cmd :startinsert)))
+
+(fn toggle-term []
+ (if (vim.api.nvim_win_is_valid state.win)
+ (hide-term)
+ (open-term)))
+
+(vim.keymap.set [:n :t] :<c-_> toggle-term {:desc "Toggle terminal"})