added toggleterm

This commit is contained in:
Oliver Hartmann 2022-04-02 02:22:16 +02:00
parent f0f1c35740
commit 99e257dbc1
2 changed files with 36 additions and 0 deletions

View File

@ -162,6 +162,10 @@ return require('packer').startup(function()
})
end,
})
use({
'akinsho/toggleterm.nvim',
config = get_setup('toggleterm')
})
if packer_bootstrap then
require('packer').sync()
end

32
lua/setup/toggleterm.lua Normal file
View File

@ -0,0 +1,32 @@
require('toggleterm').setup({})
local Terminal = require('toggleterm.terminal').Terminal
function _G.set_terminal_keymaps()
local opts = { noremap = true }
vim.api.nvim_buf_set_keymap(0, 't', '<esc>', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', 'jk', [[<C-\><C-n>]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-h>', [[<C-\><C-n><C-W>h]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-j>', [[<C-\><C-n><C-W>j]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-k>', [[<C-\><C-n><C-W>k]], opts)
vim.api.nvim_buf_set_keymap(0, 't', '<C-l>', [[<C-\><C-n><C-W>l]], opts)
end
-- Disbled for the moment because it is also set for lazygit
-- vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()')
local lazygit = Terminal:new({
cmd = 'lazygit',
-- dir = vim.fn.getcwd(),
hidden = true,
direction = 'float',
on_open = function(term)
vim.api.nvim_buf_set_keymap(term.bufnr, "n", "q", "<cmd>close<CR>", {noremap = true, silent = true})
end,
})
function _lazygit_toggle()
lazygit:toggle()
end
vim.api.nvim_set_keymap('n', '<Space>g', '<cmd>lua _lazygit_toggle()<CR>', { noremap = true, silent = true })