nvim-config/lua/plugins/config/debug/adapters.lua
dlond f81cab2da3 refactor: Complete modular migration from kickstart.nvim
Major architectural overhaul to transform the flat kickstart.nvim structure
  into a maintainable, modular configuration while preserving upstream sync capability.

  ## Structure Changes
  - Migrated from flat `lua/custom/` to organized `lua/core/` and `lua/plugins/`
  - Separated plugin specs from configs: `lua/plugins/spec/` and `lua/plugins/config/`
  - Complex configs (LSP, Debug) now use directory structure with sub-modules:
    - `lsp/init.lua`, `lsp/servers.lua`, `lsp/keymaps.lua`
    - `debug/init.lua`, `debug/adapters.lua`, `debug/keymaps.lua`

  ## Core Improvements
  - Created dedicated core modules: options, keymaps, autocmds, bootstrap, health
  - Added comprehensive health check (`lua/core/health.lua`) for diagnostics
  - Simplified init.lua to just orchestrate module loading
  - Better separation of concerns throughout

  ## Plugin Updates
  - Fixed Blink.cmp configuration (removed invalid fuzzy options)
  - Integrated Copilot with Blink.cmp for unified completion experience
  - Added autopairs and indent-line from kickstart examples
  - Optimized for Nix development environments (removed venv assumptions)

  ## Documentation
  - Updated README with modular structure and kickstart sync instructions
  - Created comprehensive KEYBIND_ANALYSIS.md with all mappings
  - Added modular.txt help documentation
  - Created TODO_TEST.md checklist for testing

  ## Benefits
  - Easier to maintain and extend
  - Clean separation allows upstream kickstart merges without conflicts
  - Scalable architecture for adding new languages/tools
  - Better code organization and discoverability

  All kickstart functionality preserved while gaining modularity and maintainability.
2025-09-02 13:23:53 +12:00

158 lines
No EOL
3.8 KiB
Lua

-- Debug Adapters Configuration
local M = {}
-- Helper function to find Python executable
-- In Nix environments, use whatever Python is in PATH
local function get_python_path()
-- Use the Python from current environment (Nix or system)
if vim.fn.executable('python3') == 1 then
return vim.fn.exepath('python3')
elseif vim.fn.executable('python') == 1 then
return vim.fn.exepath('python')
else
-- Fallback to system Python
return '/usr/bin/python3'
end
end
function M.setup()
local dap = require('dap')
-- Setup all language-specific adapters
M.setup_python(dap)
M.setup_cpp(dap)
-- Add more adapters as needed
-- M.setup_rust(dap)
-- M.setup_go(dap)
-- M.setup_javascript(dap)
end
-- Python debugger configuration
function M.setup_python(dap)
dap.adapters.python = {
type = 'executable',
command = vim.fn.exepath('python3') ~= '' and vim.fn.exepath('python3') or 'python',
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = 'Launch file',
program = '${file}',
pythonPath = get_python_path,
},
{
type = 'python',
request = 'launch',
name = 'Launch file with arguments',
program = '${file}',
args = function()
local args_string = vim.fn.input('Arguments: ')
return vim.split(args_string, ' ')
end,
pythonPath = get_python_path,
},
{
type = 'python',
request = 'attach',
name = 'Attach to running process',
processId = require('dap.utils').pick_process,
pythonPath = get_python_path,
},
}
end
-- C/C++/Rust debugger configuration (using codelldb)
function M.setup_cpp(dap)
-- CodeLLDB adapter
dap.adapters.codelldb = {
type = 'server',
port = '${port}',
executable = {
command = 'codelldb',
args = { '--port', '${port}' },
},
}
-- Alternative: Use lldb-vscode if codelldb is not available
dap.adapters.lldb = {
type = 'executable',
command = '/usr/bin/lldb-vscode', -- Adjust path as needed
name = 'lldb',
}
-- C++ configuration
dap.configurations.cpp = {
{
name = 'Launch',
type = 'codelldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = {},
runInTerminal = false,
},
{
name = 'Launch with arguments',
type = 'codelldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
args = function()
local args_string = vim.fn.input('Arguments: ')
return vim.split(args_string, ' ')
end,
runInTerminal = false,
},
{
name = 'Attach to process',
type = 'codelldb',
request = 'attach',
pid = require('dap.utils').pick_process,
args = {},
},
}
-- Share C++ configuration with C and Rust
dap.configurations.c = dap.configurations.cpp
dap.configurations.rust = dap.configurations.cpp
end
-- Example: Go debugger configuration (commented out)
-- function M.setup_go(dap)
-- dap.adapters.delve = {
-- type = 'server',
-- port = '${port}',
-- executable = {
-- command = 'dlv',
-- args = { 'dap', '-l', '127.0.0.1:${port}' },
-- },
-- }
--
-- dap.configurations.go = {
-- {
-- type = 'delve',
-- name = 'Debug',
-- request = 'launch',
-- program = '${file}',
-- },
-- {
-- type = 'delve',
-- name = 'Debug test',
-- request = 'launch',
-- mode = 'test',
-- program = '${file}',
-- },
-- }
-- end
return M