From 093c3dc49f745213d0f20ff181780b253da8488d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Dubas?= Date: Sun, 29 Oct 2023 20:46:14 +0000 Subject: [PATCH] chore(neovim): move from iron.nvim to toggleterm (#8) I use the terminal to access `repl` available in a `docker container`, or a remote one available in `kubernetes` or virtual machine. Reviewed-on: https://gitea.dubas.dev/joao.dubas/ide/pulls/8 --- config/nvim/lua/custom/plugins/init.lua | 59 ++++++++++++++++--------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/config/nvim/lua/custom/plugins/init.lua b/config/nvim/lua/custom/plugins/init.lua index 31f9d26..9fd9626 100644 --- a/config/nvim/lua/custom/plugins/init.lua +++ b/config/nvim/lua/custom/plugins/init.lua @@ -69,27 +69,46 @@ return { } end }, + 'nvim-treesitter/nvim-treesitter-context', { - 'Vigemus/iron.nvim', - config = function () - local iron = require('iron.core') - iron.setup({ - config = { - scratch_repl = true, - repl_definition = { - sh = { - command = { 'fish' } - }, - elixir = require('iron.fts.elixir').iex, - javascript = require('iron.fts.javascript').node, - python = require('iron.fts.python').ipython, - typescript = require('iron.fts.typescript').ts - } - }, - highlight = { italic = true }, - ignore_blank_lines = true + 'akinsho/toggleterm.nvim', + opts = { + size = vim.o.lines * 0.3, + open_mapping = [[]], + hide_numbers = true, + shade_filetypes = { }, + shade_terminals = true, + shading_factor = 2, + direction = 'horizontal', + shell = vim.o.shell, + }, + keys = function () + local status_ok, which_key = pcall(require, 'which_key') + if status_ok then + which_key.register({ + ['o'] = { name = 'To[g]gle terminal', _ = 'which_key_ignore' } + }) + end + vim.api.nvim_create_autocmd('TermOpen', { + group = vim.api.nvim_create_augroup('kickstart-custom-term-open-mapping', { clear = true }), + callback = function (args) + local bufnr = args.buf + local opts = { buffer = bufnr } + vim.keymap.set('t', '', [[]], opts) + vim.keymap.set('t', 'jk', [[]], opts) + vim.keymap.set('t', '', [[wincmd h]], opts) + vim.keymap.set('t', '', [[wincmd j]], opts) + vim.keymap.set('t', '', [[wincmd k]], opts) + vim.keymap.set('t', '', [[wincmd l]], opts) + vim.keymap.set('t', '', [[]], opts) + end }) + return { + { 'oh', 'ToggleTerm direction=horizontal size=' .. tostring(vim.o.lines * 0.3) .. '', desc = 'Open terminal horizontally' }, + { 'oc', 'ToggleTermSendCurrentLine', desc = 'Send current line under the cursor' }, + { 'ov', 'ToggleTermSendVisualLines', desc = 'Send all lines visually selected' }, + { 'os', 'ToggleTermSendVisualSelection', desc = 'Send visually selected text' } + } end - }, - 'nvim-treesitter/nvim-treesitter-context' + } }