1234567891011121314151617181920212223242526272829303132333435363738394041 |
- -- apply default terminal settings
- vim.api.nvim_create_autocmd('TermOpen', {
- callback = function()
- vim.bo.scrollback = 10000
- vim.opt_local.number = false
- vim.opt_local.relativenumber = false
- vim.b.miniindentscope_disable = true
- end
- })
- -- preserve window structure when exiting terminal via C-d
- vim.api.nvim_create_autocmd('TermClose', {
- callback = function(opts)
- -- don't trigger when force deleting
- if vim.api.nvim_buf_get_option(opts.buf, 'modified') then
- return
- end
- MiniBufremove.delete(opts.buf)
- end,
- -- needed so statusline properly updates
- nested = true,
- })
- -- automatically enter/leave terminal mode
- vim.api.nvim_create_autocmd('TermOpen', { command = 'startinsert' })
- vim.api.nvim_create_autocmd({ 'WinEnter', 'BufWinEnter' }, {
- pattern = 'term://*',
- command = 'startinsert',
- })
- vim.api.nvim_create_autocmd('BufLeave', {
- pattern = 'term://*',
- command = 'stopinsert',
- })
- -- leave insert mode with <ESC><ESC>
- vim.keymap.set('t', '<ESC><ESC>', '<C-\\><C-N>')
- vim.keymap.set('t', '<C-[><C-[>', '<C-\\><C-N>')
- -- opening terminals
- vim.keymap.set('n', '<Leader>tv', '<cmd>vertical term $SHELL<CR>')
- vim.keymap.set('n', '<Leader>to', '<cmd>term $SHELL<CR>')
|