Configs2026年7月28日·1 分钟阅读

nvim-dap — Debug Adapter Protocol Client for Neovim

DAP client implementation enabling debugging directly in Neovim with breakpoints, stepping, variable inspection

Agent 就绪

这个资产会安全暂存

这个资产会先安全暂存。复制的指令会要求 Agent 读取暂存文件,并在激活脚本、MCP 配置或全局配置前先确认。

Stage only · 29/100策略:需暂存
Agent 入口
任意 MCP/CLI Agent
类型
CLI Tool
安装
Single
信任
信任等级:Established
入口
nvim-dap
安全暂存命令
npx -y tokrepo@latest install 6ccf4dd6-8a1c-11f1-9bc6-00163e2b0d79 --target codex

先暂存文件;激活前需要读取暂存 README 和安装计划。

Introduction

nvim-dap is a Debug Adapter Protocol (DAP) client implementation for Neovim, written by mfussenegger. With over 7,200 stars on GitHub, it brings IDE-level debugging capabilities to Neovim by communicating with language-specific debug adapters through the standardized DAP interface originally created by Microsoft for VS Code.

What nvim-dap Does

nvim-dap connects Neovim to external debug adapters that control program debugging. You can set breakpoints, step through code, inspect variables, evaluate expressions, and navigate the call stack. It handles the DAP JSON-RPC protocol, translating debugger state into Neovim UI elements.

Architecture Overview

The plugin implements the DAP client specification in pure Lua. It communicates with debug adapter processes via JSON-RPC over stdio or TCP. The core manages session lifecycle: initialization, configuration, breakpoint state, and thread/stack frame tracking. UI rendering is minimal in core — nvim-dap-ui provides richer visual interfaces.

Self-Hosting & Configuration

nvim-dap runs locally with no external services. Each language requires a debug adapter binary (e.g., debugpy for Python, codelldb for C/C++/Rust, node-debug2 for JavaScript). Configuration involves two tables in your init.lua: dap.adapters defines how to launch each adapter, and dap.configurations defines launch/attach profiles per filetype. Keybindings are set manually — common mappings include continue, step over, step into, step out, and toggle breakpoint.

Key Features

  • Full DAP protocol support including launch and attach modes
  • Breakpoints: line, conditional, hit count, and log points
  • Step through code: continue, step over, step into, step out
  • Variable inspection via scopes and hover evaluation
  • Call stack navigation across multiple threads
  • REPL for evaluating expressions in the current debug context
  • Extensible through Lua callbacks at every lifecycle event

Comparison with Similar Tools

Compared to Vimspector (Vimscript-based), nvim-dap is Lua-native, lighter, and more composable with other Neovim plugins. VS Code uses the same DAP protocol but bundles its own UI; nvim-dap separates client from UI. Compared to language-specific debugger plugins, nvim-dap provides a unified interface across all DAP-supported languages.

FAQ

Which languages are supported? Any language with a DAP-compliant debug adapter works. Popular ones include Python (debugpy), C/C++/Rust (codelldb, cppdbg), JavaScript/TypeScript (node-debug2, js-debug), Go (delve), and Java (java-debug).

Do I need nvim-dap-ui? No. nvim-dap works standalone with its built-in REPL and sign-based breakpoints. nvim-dap-ui adds floating windows for variables, watches, stacks, and breakpoints.

Can I debug tests? Yes, with the right launch configuration. Plugins like neotest integrate with nvim-dap to debug individual tests directly.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产