添加C-q退出窗口快捷键。

This commit is contained in:
2026-02-11 15:10:46 +08:00
parent c0d9448137
commit 49cf119df8

View File

@@ -2,23 +2,25 @@ local Terminal = require("toggleterm.terminal").Terminal
-- 创建通用函数
local function createCMakeTask(action)
return function()
local cwd = vim.fn.getcwd()
local dir_term = Terminal:new({
cmd = "cmake-vsenv -t Debug -a " .. action .. " -r " .. cwd,
direction = "float",
float_opts = {
border = "rounded",
width = 100,
height = 30,
},
hidden = false,
close_on_exit = false,
})
dir_term:toggle()
end
return function()
local cwd = vim.fn.getcwd()
local dir_term = Terminal:new({
cmd = "cmake-vsenv -t Debug -a " .. action .. " -r " .. cwd,
direction = "float",
float_opts = {
border = "rounded",
width = 100,
height = 30,
},
hidden = false,
close_on_exit = false,
})
dir_term:toggle()
end
end
-- vim.keymap.set("t", "q", "<C-\\><C-n>:q<CR>", { desc = "Exit terminal and close window" })
vim.keymap.set("t", "<C-q>", "<cmd>close<CR>", { desc = "Exit terminal and close window" })
-- 设置快捷键
vim.keymap.set("n", "<Leader>mc", createCMakeTask("Config"), { desc = "ConfigDebug" })
vim.keymap.set("n", "<Leader>mb", createCMakeTask("Build"), { desc = "BuildDebug" })