diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua
index 2c134f7..ee0d997 100644
--- a/.config/nvim/lua/config/keymaps.lua
+++ b/.config/nvim/lua/config/keymaps.lua
@@ -1,3 +1,17 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
+
+-- Override LazyVim's / : count 99 opens the floating terminal,
+-- everything else stays native (bottom terminal at project root).
+-- Both keys are mapped because terminals differ in which code Ctrl+/ sends.
+local function term_open()
+ if vim.v.count == 99 then
+ require("config.terminal").open_float()
+ else
+ Snacks.terminal.focus(nil, { cwd = LazyVim.root() })
+ end
+end
+
+vim.keymap.set({ "n", "t" }, "", term_open, { desc = "Terminal (Root Dir) | 99 = float" })
+vim.keymap.set({ "n", "t" }, "", term_open, { desc = "Terminal (Root Dir) | 99 = float" })
diff --git a/.config/nvim/lua/config/terminal.lua b/.config/nvim/lua/config/terminal.lua
index d97f644..1a27d4f 100644
--- a/.config/nvim/lua/config/terminal.lua
+++ b/.config/nvim/lua/config/terminal.lua
@@ -5,20 +5,19 @@
-- count, e.g. 2 opens a *separate* terminal #2)
-- fT terminal in the current working directory
--
--- This module adds:
--- open/focus a *dedicated* floating terminal (close it with )
--- ft a picker that lists every live terminal so any contextual
--- terminal can be focused or restored even after its window was
--- closed/hidden.
+-- This module adds (actual key bindings are declared in lua/plugins/terminal.lua):
+-- open_float() open/focus a *dedicated* floating terminal (close it with )
+-- picker() list every live terminal so any contextual terminal can be
+-- focused or restored even after its window was closed/hidden.
local M = {}
--- The floating terminal. Tracked as an upvalue so always re-focuses
+-- The floating terminal. Tracked as an upvalue so the same key always re-focuses
-- the *same* float regardless of which directory the editor is in.
---@type snacks.win?
local float
---- Open or focus the floating terminal, or hide it if already focused.
--- NOTE: currently unused; calls open_float() instead so shell
+--- Open or focus the floating terminal, or hide it if already focused.
+-- NOTE: currently unused; the binding calls open_float() instead so shell
-- tab-completion keeps working while the terminal is open. Kept around for a
-- future explicit open/close toggle.
function M.toggle_float()
@@ -35,17 +34,17 @@ function M.toggle_float()
-- First open: a high fixed count guarantees this terminal never collides with
-- the count-keyed bottom terminals (1, 2, 3 ...), so it is always the *same*
- -- float for no matter the context.
+ -- float for no matter the context.
float = Snacks.terminal(nil, {
count = 99,
win = { position = "float", border = "rounded" },
})
- -- Close it with a single keystroke from inside the shell: hides the
+ -- Close it with a single keystroke from inside the shell: hides the
-- window (buffer-local, so it only affects this floating terminal and never
-- the bottom split, where shell tab-completion must keep working).
if float and float.buf then
- vim.keymap.set("t", "", function()
+ vim.keymap.set("t", "tt", function()
if float and float:win_valid() then
float:hide()
end
@@ -53,8 +52,8 @@ function M.toggle_float()
end
end
---- Open or focus the floating terminal. This never hides the window, so
---- once the float is open falls through to the shell and stays available
+--- Open or focus the floating terminal. This never hides the window, so
+--- once the float is open the key falls through to the shell and stays available
--- for tab-completion. Close the floating terminal with while it is
--- visible (handled by Snacks' native terminal keymap).
function M.open_float()
@@ -71,7 +70,7 @@ function M.open_float()
-- First open: a high fixed count guarantees this terminal never collides with
-- the count-keyed bottom terminals (1, 2, 3 ...), so it is always the *same*
- -- float for no matter the context.
+ -- float for no matter the context.
float = Snacks.terminal(nil, {
count = 99,
win = { position = "float", border = "rounded" },
diff --git a/.config/nvim/lua/plugins/terminal.lua b/.config/nvim/lua/plugins/terminal.lua
index cf30a6b..4ac7335 100644
--- a/.config/nvim/lua/plugins/terminal.lua
+++ b/.config/nvim/lua/plugins/terminal.lua
@@ -5,7 +5,7 @@ return {
"folke/snacks.nvim",
keys = {
{
- "",
+ "tt",
function()
require("config.terminal").open_float()
end,