feat(debug): add C/C++ codelldb profile and textobject selects
Add additive C/C++ DAP launch defaults and treesitter select textobjects to speed structural editing while preserving existing keymaps and DAP controls.
This commit is contained in:
parent
a06b051e6d
commit
1da7fbeaf3
|
|
@ -62,6 +62,7 @@ nvim --headless "+MasonToolsInstallSync" "+qa"
|
|||
- `<leader>jm` / `<leader>jk`: next/previous function start
|
||||
- `<leader>jM` / `<leader>jK`: next/previous function end
|
||||
- `<leader>jc` / `<leader>jC`: next/previous class start
|
||||
- Textobject select (operator-pending/visual): `af`/`if` for function, `ac`/`ic` for class
|
||||
|
||||
### Tests and debug
|
||||
|
||||
|
|
@ -119,7 +120,8 @@ Existing DAP keys are unchanged:
|
|||
- Core: `nvim-dap`, `nvim-dap-ui`, `mason-nvim-dap`, `nvim-dap-go`.
|
||||
- JS/TS: `nvim-dap-vscode-js` configured with `js-debug-adapter` and
|
||||
`pwa-node` launch/attach defaults.
|
||||
- C/C++: `codelldb` installation added through Mason DAP setup.
|
||||
- C/C++: `codelldb` installation via Mason and baseline launch profile
|
||||
(`Launch current file (codelldb)`).
|
||||
|
||||
### Testing
|
||||
|
||||
|
|
@ -179,7 +181,7 @@ Check with `:Mason` and install manually if needed.
|
|||
|
||||
1. Navigate symbols with `<leader>jm/jk/jc/jC`.
|
||||
2. Build/test with CMake mappings if project uses CMake.
|
||||
3. Debug using existing DAP keys with `codelldb` installed.
|
||||
3. Debug using existing DAP keys and select `Launch current file (codelldb)`.
|
||||
4. Run gtest via neotest after `:ConfigureGtest` setup.
|
||||
|
||||
### Kubernetes/Helm workflow
|
||||
|
|
|
|||
|
|
@ -0,0 +1,43 @@
|
|||
local M = {}
|
||||
|
||||
local function has_configuration(configurations, name, adapter)
|
||||
for _, configuration in ipairs(configurations or {}) do
|
||||
if configuration.name == name and configuration.type == adapter then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function M.setup(dap)
|
||||
dap = dap or require 'dap'
|
||||
|
||||
dap.adapters.codelldb = dap.adapters.codelldb or {
|
||||
type = 'executable',
|
||||
command = 'codelldb',
|
||||
}
|
||||
|
||||
local launch_name = 'Launch current file (codelldb)'
|
||||
local launch_configuration = {
|
||||
name = launch_name,
|
||||
type = 'codelldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
}
|
||||
|
||||
for _, language in ipairs { 'c', 'cpp' } do
|
||||
dap.configurations[language] = dap.configurations[language] or {}
|
||||
|
||||
if not has_configuration(dap.configurations[language], launch_name, 'codelldb') then
|
||||
table.insert(dap.configurations[language], vim.deepcopy(launch_configuration))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -145,5 +145,7 @@ return {
|
|||
detached = vim.fn.has 'win32' == 0,
|
||||
},
|
||||
}
|
||||
|
||||
require('custom.dap_cpp').setup(dap)
|
||||
end,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,15 @@ return {
|
|||
dependencies = { 'nvim-treesitter/nvim-treesitter' },
|
||||
config = function()
|
||||
require('nvim-treesitter-textobjects').setup {
|
||||
select = {
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
},
|
||||
},
|
||||
move = {
|
||||
set_jumps = true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue