From f387850d19d2207ccae969636ae930efcce52160 Mon Sep 17 00:00:00 2001 From: Wellinton Aracena Date: Sun, 3 Mar 2024 13:44:22 -0500 Subject: [PATCH] added nvchad terminal --- lua/custom/plugins/nvterm.lua | 71 +++++++++-------------------------- 1 file changed, 17 insertions(+), 54 deletions(-) diff --git a/lua/custom/plugins/nvterm.lua b/lua/custom/plugins/nvterm.lua index bc57bab3..589fc0e7 100644 --- a/lua/custom/plugins/nvterm.lua +++ b/lua/custom/plugins/nvterm.lua @@ -2,65 +2,28 @@ return { { 'NvChad/nvterm', config = function() - require('nvterm').setup { - terminals = { - shell = vim.o.shell, - 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 = 0.3 }, - vertical = { location = 'rightbelow', split_ratio = 0.5 }, - }, - }, - behavior = { - autoclose_on_quit = { - enabled = false, - confirm = true, - }, - close_on_exit = true, - auto_insert = true, - }, - } + require('nvterm').setup() end, keys = function() + local map = function(modes, keys, func, desc) + vim.keymap.set(modes, keys, func, { noremap = true, silent = true, desc = 'spawns terminal: ' .. desc }) + end + require('nvterm').setup() local terminal = require 'nvterm.terminal' local toggle_modes = { 'n', 't' } - local mappings = { - { - toggle_modes, - 'th', - function() - terminal.toggle 'horizontal' - Desc = '[S]earch [H]elp' - end, - }, - { - toggle_modes, - 'tv', - function() - terminal.toggle 'vertical' - end, - }, - { - toggle_modes, - 'ti', - function() - terminal.toggle 'float' - end, - }, - } - local opts = { noremap = true, silent = true } - for _, mapping in ipairs(mappings) do - vim.keymap.set(mapping[1], mapping[2], mapping[3], opts) - end + + map(toggle_modes, 'th', function() + terminal.toggle 'horizontal' + end, 'horizontal') + + map(toggle_modes, 'tv', function() + terminal.toggle 'vertical' + end, 'vertical') + + map(toggle_modes, 'ti', function() + terminal.toggle 'float' + end, 'floating') end, }, }