Files
nvim/lua/config/keymaps.lua

28 lines
1.0 KiB
Lua
Raw Normal View History

2026-02-09 17:22:57 +08:00
local Terminal = require("toggleterm.terminal").Terminal
2026-02-11 14:15:11 +08:00
-- 创建通用函数
local function createCMakeTask(action)
2026-02-11 15:10:46 +08:00
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
2026-02-11 14:15:11 +08:00
end
2026-02-11 15:10:46 +08:00
-- 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" })
2026-02-11 14:15:11 +08:00
-- 设置快捷键
vim.keymap.set("n", "<Leader>mc", createCMakeTask("Config"), { desc = "ConfigDebug" })
vim.keymap.set("n", "<Leader>mb", createCMakeTask("Build"), { desc = "BuildDebug" })
vim.keymap.set("n", "<Leader>mr", createCMakeTask("Clear"), { desc = "RemoveBuild" })