My Neovim DAP Setup for C Debugging (2)

Neovim DAP with LLDB

Background

Inconveniences with the current setup

I was using Neovim DAP with GDB for C debugging. Here’re some inconveniences during the debug process:

  • needed fflush(0) for displaying standard output in the REPL (the small buffer below)
  • Gemini’s suggested solutions for obtaining standard input sounded too complicated, like:
    • attaching GDB to an external TTY, or

    • from a certain file

      dap.configurations.c = {
        {
          name = "Launch with File Input Redirection",
          type = "gdb", -- or codelldb
          request = "launch",
          program = function()
            return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
          end,
          cwd = "${workspaceFolder}",
          args = { "<", "input.txt" }, -- Passes input.txt as standard input
        },
      }
      

Popularity of an alternative compiler

AI Learning Club’s C course’s introduction says that Clang often offers a quicker compilation and more informative error messages. As a result, I was feeling motivated to connect Neovim DAP to LLDB instead.

[Read More]
Neovim  DAP  LLDB  C  clang 

My Neovim DAP Setup for C Debugging

Setting up the Debug Adapter Protocol (DAP) in Neovim transforms C and C++ workflows by integrating full-featured debugging—breakpoints, call stacks, REPL execution, and variable evaluation—directly into your modal editing experience.

Rather than maintaining static code snippets in this post, you can inspect my active setup directly on GitHub:

👉 VincentTam/nvim-config: lua/plugins/dap.lua


Core Architecture

The setup relies on three primary components managed through lazy.nvim:


Ergonomic Navigation: Shift + Arrow Shortcuts

While traditional DAP keymaps often use multi-key leader sequences (e.g., <Leader>dn), navigating execution during a active step-by-step session is much faster with single-key modifications.

[Read More]
NeoVim  DAP  GDB  C