From f97b66d258415a046bc61c18788ef8294c0f90b6 Mon Sep 17 00:00:00 2001 From: zbirenbaum Date: Fri, 22 Apr 2022 00:48:53 -0400 Subject: rename modules --- lua/chadterm/init.lua | 68 --------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 lua/chadterm/init.lua (limited to 'lua/chadterm/init.lua') diff --git a/lua/chadterm/init.lua b/lua/chadterm/init.lua deleted file mode 100644 index 2c14e9c..0000000 --- a/lua/chadterm/init.lua +++ /dev/null @@ -1,68 +0,0 @@ -local M = {} - -local terminal = require("chadterm.terminal") - -local defaults = { - terminals = { - list = {}, - type_opts = { - float = { - relative = 'editor', - row = 0.3, - col = 0.25, - width = 0.5, - height = 0.4, - border = "single", - }, - horizontal = { location = "rightbelow", split_ratio = .3, }, - vertical = { location = "rightbelow", split_ratio = .5 }, - } - }, - behavior = { - close_on_exit = true, - auto_insert = true, - }, - mappings = { - toggle = { - { '', function () terminal.new_or_toggle('float') end }, - { '', function () terminal.new_or_toggle('horizontal') end }, - { '', function () terminal.new_or_toggle('vertical') end }, - } - } -} - -local set_behavior = function(behavior) - if behavior.close_on_exit then - vim.api.nvim_create_autocmd({"TermClose"},{ - callback = function() - vim.schedule_wrap(vim.api.nvim_input('')) - end - }) - end - if behavior.auto_insert then - vim.api.nvim_create_autocmd({"BufEnter"}, { - callback = function() vim.cmd('startinsert') end, - pattern = 'term://*' - }) - vim.api.nvim_create_autocmd({"BufLeave"}, { - callback = function() vim.cmd('stopinsert') end, - pattern = 'term://*' - }) - end -end - -local create_mappings = function (mappings) - local opts = { noremap = true, silent = true } - for _, mapping in ipairs(mappings.toggle) do - vim.keymap.set({'n', 't'}, mapping[1], mapping[2], opts) - end -end - -M.setup = function (config) - config = config and vim.tbl_deep_extend("force", config, defaults) or defaults - set_behavior(config.behavior) - create_mappings(config.mappings) - require('chadterm.terminal').init(config.terminals) -end - -return M -- cgit v1.2.3-70-g09d2