update dotfiles

This commit is contained in:
2026-07-19 19:36:54 +08:00
parent b4010fe910
commit aef001a855
38 changed files with 1680 additions and 826 deletions
+84 -89
View File
@@ -1,94 +1,89 @@
-- ============================================================================
-- DAP 调试器
-- ============================================================================
-- =============================================================================
-- dap.lua — DAP 调试器
-- =============================================================================
return {
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
"nvim-neotest/nvim-nio",
"williamboman/mason.nvim",
},
config = function()
local dap = require("dap")
local dapui = require("dapui")
-- 断点图标
vim.fn.sign_define("DapBreakpoint",
{ text = "", texthl = "DapBreakpoint", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition",
{ text = "", texthl = "DapBreakpointCondition", linehl = "", numhl = "" })
vim.fn.sign_define("DapStopped",
{ text = "", texthl = "DapStopped", linehl = "CursorLine", numhl = "" })
-- dap-ui 布局
dapui.setup({
layouts = {
{
elements = {
{ id = "stacks", size = 0.25 },
{ id = "scopes", size = 0.25 },
{ id = "breakpoints", size = 0.25 },
{ id = "watches", size = 0.25 },
},
position = "left",
size = 40,
},
{
elements = {
{ id = "repl", size = 0.5 },
{ id = "console", size = 0.5 },
},
position = "bottom",
size = 10,
},
},
})
-- 调试会话自动打开/关闭 UI
dap.listeners.before.attach.dapui_config = function() dapui.open() end
dap.listeners.before.launch.dapui_config = function() dapui.open() end
dap.listeners.before.event_terminated.dapui_config = function() dapui.close() end
dap.listeners.before.event_exited.dapui_config = function() dapui.close() end
-- codelldb 适配器(Mason 安装路径)
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
command = vim.fn.stdpath("data") .. "/mason/bin/codelldb",
args = { "--port", "${port}" },
},
}
-- C/C++ 调试配置(非 CMake 项目,CMake 项目用 <leader>rd
dap.configurations.c = {
{
name = "Launch",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("可执行文件路径: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
dap.configurations.cpp = dap.configurations.c
end,
{
"mfussenegger/nvim-dap",
dependencies = {
"rcarriga/nvim-dap-ui",
"nvim-neotest/nvim-nio",
"williamboman/mason.nvim",
{ "theHamsta/nvim-dap-virtual-text", opts = {} },
{ "Weissle/persistent-breakpoints.nvim", opts = { load_breakpoints_event = { "BufReadPost" } } },
},
config = function()
local dap = require("dap")
local dapui = require("dapui")
-- Mason DAP 自动安装
-- lazy = false: defaults = { lazy = true } 会使此插件无触发器而永不加载,
-- 导致 ensure_installed 不执行、codelldb 不安装
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" },
lazy = false,
opts = {
ensure_installed = { "codelldb" },
-- 断点图标
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "DapBreakpoint", linehl = "", numhl = "" })
vim.fn.sign_define("DapBreakpointCondition", { text = "", texthl = "DapBreakpointCondition", linehl = "", numhl = "" })
vim.fn.sign_define("DapStopped", { text = "", texthl = "DapStopped", linehl = "CursorLine", numhl = "" })
-- dap-ui 布局
dapui.setup({
layouts = {
{
elements = {
{ id = "stacks", size = 0.25 },
{ id = "scopes", size = 0.25 },
{ id = "breakpoints", size = 0.25 },
{ id = "watches", size = 0.25 },
},
position = "left",
size = 40,
},
{
elements = {
{ id = "repl", size = 0.5 },
{ id = "console", size = 0.5 },
},
position = "bottom",
size = 10,
},
},
},
}
})
-- 调试会话自动打开/关闭 UI
dap.listeners.before.attach.dapui_config = function() dapui.open() end
dap.listeners.before.launch.dapui_config = function() dapui.open() end
dap.listeners.before.event_terminated.dapui_config = function() dapui.close() end
dap.listeners.before.event_exited.dapui_config = function() dapui.close() end
-- codelldb 适配器
dap.adapters.codelldb = {
type = "server",
port = "${port}",
executable = {
command = vim.fn.stdpath("data") .. "/mason/bin/codelldb",
args = { "--port", "${port}" },
},
}
-- C/C++ 调试配置
dap.configurations.c = {
{
name = "Launch",
type = "codelldb",
request = "launch",
program = function()
return vim.fn.input("可执行文件路径: ", vim.fn.getcwd() .. "/", "file")
end,
cwd = "${workspaceFolder}",
stopOnEntry = false,
args = {},
},
}
dap.configurations.cpp = dap.configurations.c
end,
},
-- Mason DAP 自动安装
{
"jay-babu/mason-nvim-dap.nvim",
dependencies = { "williamboman/mason.nvim", "mfussenegger/nvim-dap" },
event = "BufReadPost",
opts = { ensure_installed = { "codelldb" } },
},
}