aboutsummaryrefslogtreecommitdiff
path: root/lua/chadterm/termutil.lua
diff options
context:
space:
mode:
authorzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-22 00:48:53 -0400
committerzbirenbaum <zacharyobirenbaum@gmail.com>2022-04-22 00:49:41 -0400
commitf97b66d258415a046bc61c18788ef8294c0f90b6 (patch)
treea4639c45c5d944bb81ffd299a04cbc65da17bc8d /lua/chadterm/termutil.lua
parentadd README.md (diff)
rename modules
Diffstat (limited to 'lua/chadterm/termutil.lua')
-rw-r--r--lua/chadterm/termutil.lua51
1 files changed, 0 insertions, 51 deletions
diff --git a/lua/chadterm/termutil.lua b/lua/chadterm/termutil.lua
deleted file mode 100644
index 92fc632..0000000
--- a/lua/chadterm/termutil.lua
+++ /dev/null
@@ -1,51 +0,0 @@
-local util = {}
-local a = vim.api
-
-util.calc_float_opts = function(opts)
- return {
- relative = "editor",
- width = math.ceil(opts.width*vim.o.columns),
- height = math.ceil(opts.height*vim.o.lines),
- row = math.floor(opts.row*vim.o.lines),
- col = math.floor(opts.col*vim.o.columns),
- border = opts.border,
- }
-end
-
-util.get_split_dims = function(type, ratio)
- local type_switch = type == "horizontal"
- local type_func = type_switch and a.nvim_win_get_height or a.nvim_win_get_width
- return math.floor(type_func(0) * ratio)
-end
-
-util.execute_type_cmd = function(type, terminals)
- local opts = terminals.type_opts[type]
- local type_cmds = {
- horizontal = function()
- local dims = util.get_split_dims(type, opts.split_ratio)
- vim.cmd(opts.location .. dims .. " split")
- end,
- vertical = function()
- local dims = util.get_split_dims(type, opts.split_ratio)
- vim.cmd(opts.location .. dims .. " vsplit")
- end,
- float = function()
- a.nvim_open_win(0, true, util.calc_float_opts(opts))
- end,
- }
- type_cmds[type]()
-end
-
-
-util.verify_terminals = function (terminals)
- terminals.list = vim.tbl_filter(function(term)
- return vim.api.nvim_buf_is_valid(term.buf)
- end, terminals.list)
- terminals.list = vim.tbl_map(function(term)
- term.open = vim.api.nvim_win_is_valid(term.win)
- return term
- end, terminals.list)
- return terminals
-end
-
-return util