added toggleterm
This commit is contained in:
parent
f0f1c35740
commit
99e257dbc1
@ -162,6 +162,10 @@ return require('packer').startup(function()
|
|||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
use({
|
||||||
|
'akinsho/toggleterm.nvim',
|
||||||
|
config = get_setup('toggleterm')
|
||||||
|
})
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then
|
||||||
require('packer').sync()
|
require('packer').sync()
|
||||||
end
|
end
|
||||||
|
32
lua/setup/toggleterm.lua
Normal file
32
lua/setup/toggleterm.lua
Normal 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 })
|
Loading…
x
Reference in New Issue
Block a user