nvim-dap-ui

repository·master·Indexed 25 days ago

https://github.com/rcarriga/nvim-dap-ui

A user interface for the nvim-dap debugger plugin providing visual windows for inspecting variable scopes, stack frames, watch expressions, breakpoints, and a REPL/console. It includes features for automating UI visibility via nvim-dap listeners, floating window elements, and expression evaluation via eval().

Tokens
915
Snippets
6
Records
9
Agent score
36%

What's inside nvim-dap-ui

  1. Automate UI visibility with nvim-dap listeners

    master

    You can automate opening and closing the UI by attaching nvim-dap-ui functions to nvim-dap events. This ensures the UI appears when a debug session starts and disappears when it ends.

    local dap, dapui = require("dap"), require("dapui")
    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
  2. Install nvim-dap-ui

    master

    Install nvim-dap-ui along with its required dependencies nvim-dap and nvim-nio using your preferred package manager.

    It is highly recommended to use lazydev.nvim to enable type checking, documentation, and autocompletion for the nvim-dap-ui API.

    -- lazy.nvim
    { "rcarriga/nvim-dap-ui", dependencies = {"mfussenegger/nvim-dap", "nvim-neotest/nvim-nio"} }
    
    -- lazydev.nvim setup for type checking
    require("lazydev").setup({
      library = { "nvim-dap-ui" },
    })
  3. Initialize nvim-dap-ui

    master

    To use the UI, call the setup() method during your Neovim startup. You can optionally pass custom configuration settings to this function.

    For detailed configuration options and defaults, refer to :h dapui.setup().

    require("dapui").setup()
  4. Control UI visibility with open, close, and toggle

    master

    Use the following functions to manage the visibility of the UI elements. You can optionally pass either "sidebar" or "tray" as an argument to target only that specific component.

    require("dapui").open()
    require("dapui").close()
    require("dapui").toggle()
  5. Evaluate expressions with eval()

    master

    Use eval() to perform a one-time expression evaluation in a hover window.

    • If an expression is provided, it evaluates that string.
    • If no expression is provided, it evaluates the word under the cursor (or the highlighted text in visual mode).
    • Calling the function while the window is already open will jump the cursor to it.
  6. Open elements in floating windows

    master

    Use float_element to display specific elements in a floating window instead of the sidebar or tray. If no element ID is provided, you will be prompted to select one.

    Available settings:

    • width: number - Width of the window
    • height: number - Height of the window
    • enter: boolean - Whether to enter the floating window immediately
    • position: string - Position of the window ("center" or nil)
    require("dapui").float_element(<element ID>, <optional settings>)