blob: ca1832713ba62800b713eb4682ba029012a38adf (
plain)
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
|
(import-macros {: keymap} :macros)
(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.cmd.terminal)
(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)))
(keymap [:n :t] :<c-_> toggle-term {:desc "Toggle terminal"})
|