change toggle term keymap

This commit is contained in:
alice-vu-163 2025-05-06 21:30:03 +07:00
parent 4bdb8920cd
commit 9ced6b0005
3 changed files with 16 additions and 23 deletions

View File

@ -1056,3 +1056,19 @@ require('lazy').setup({
-- The line beneath this is called `modeline`. See `:help modeline` -- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et -- vim: ts=2 sts=2 sw=2 et
local toggleterm = require 'toggleterm'
toggleterm.setup {
open_mapping = 'T', -- press T in normal or terminal to toggle
direction = 'float', -- use a floating window
float_opts = {
border = 'single', -- or "double", "curved", etc.
-- dynamic sizing: 85% of the current editor dimensions
width = function()
return math.floor(vim.o.columns * 0.85)
end,
height = function()
return math.floor(vim.o.lines * 0.85)
end,
},
}

View File

@ -22,26 +22,4 @@ vim.keymap.set('n', 'J', ':m .+1<CR>==', { noremap = true, silent = true })
-- Move current line up with K -- Move current line up with K
vim.keymap.set('n', 'K', ':m .-2<CR>==', { noremap = true, silent = true }) vim.keymap.set('n', 'K', ':m .-2<CR>==', { noremap = true, silent = true })
-- Map <leader>T to toggle terminal
vim.keymap.set('n', 'T', function()
local Terminal = require('toggleterm.terminal').Terminal
local float_term = Terminal:new {
direction = 'float',
hidden = true, -- ensures it doesn't persist visually
}
float_term:toggle()
require('toggleterm').toggle_all()
end, { desc = 'Toggle Floating Terminal' })
vim.keymap.set('n', '<leader>bd', function()
-- Close all open toggleterm terminals
require('toggleterm').toggle_all()
-- Then close the current buffer
vim.cmd 'bdelete!'
end, { desc = 'Close buffer and toggleterm' })
vim.keymap.set('n', '<leader>/', require('telescope.builtin').current_buffer_fuzzy_find, { desc = '[/] Fuzzy search in current buffer' })
vim.keymap.set('t', '<Esc>', [[<C-\><C-n>]], { desc = 'Exit terminal mode' })
return {} return {}

View File

@ -1 +0,0 @@
Line from main branch