Created
November 9, 2025 10:34
-
-
Save danielres/6b75da2119258fdc0a6be2802a305b6d to your computer and use it in GitHub Desktop.
Lazyvim buffer terminals
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| return { | |
| { | |
| "LazyVim/LazyVim", | |
| keys = { | |
| -- terminal in the current window (new terminal buffer) | |
| { | |
| "<leader>to", | |
| function() | |
| vim.cmd("terminal") | |
| end, | |
| desc = "Terminal (here)", | |
| }, | |
| -- terminal in a horizontal split | |
| { | |
| "<leader>ts", | |
| function() | |
| vim.cmd("split | terminal") | |
| end, | |
| desc = "Terminal (split)", | |
| }, | |
| -- terminal in a vertical split | |
| { | |
| "<leader>tv", | |
| function() | |
| vim.cmd("vsplit | terminal") | |
| end, | |
| desc = "Terminal (vsplit)", | |
| }, | |
| -- terminal in a new tab | |
| { | |
| "<leader>tt", | |
| function() | |
| vim.cmd("tabnew | terminal") | |
| end, | |
| desc = "Terminal (tab)", | |
| }, | |
| }, | |
| init = function() | |
| vim.api.nvim_create_autocmd("TermOpen", { | |
| pattern = "*", | |
| callback = function() | |
| vim.cmd("startinsert") -- enter insert mode | |
| vim.bo.buflisted = true -- list terminal buffers | |
| vim.keymap.set("t", "<Esc>", [[<C-\><C-n>]], { buffer = true, silent = true }) | |
| vim.keymap.set("t", "<C-h>", [[<C-\><C-n><C-w>h]], { buffer = true, silent = true }) | |
| vim.keymap.set("t", "<C-j>", [[<C-\><C-n><C-w>j]], { buffer = true, silent = true }) | |
| vim.keymap.set("t", "<C-k>", [[<C-\><C-n><C-w>k]], { buffer = true, silent = true }) | |
| vim.keymap.set("t", "<C-l>", [[<C-\><C-n><C-w>l]], { buffer = true, silent = true }) | |
| end, | |
| }) | |
| end, | |
| }, | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment