mfussenegger / nvim-dap-ui

A UI for nvim-dap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nvim-dap-ui

This is still early stage software. Bugs are expected and there may be breaking changes!

Introduction

A UI for nvim-dap which provides a good out of the box configuration.

Preview

Installation

Install with your favourite package manager alongside nvim-dap

dein:

call dein#add("mfussenegger/nvim-dap")
call dein#add("rcarriga/nvim-dap-ui")

vim-plug

Plug "mfussenegger/nvim-dap"
Plug "rcarriga/nvim-dap-ui"

packer.nvim

use { "rcarriga/nvim-dap-ui", requires = {"mfussenegger/nvim-dap"} }

Configuration

nvim-dap-ui is built on the idea of "elements". These elements are windows which provide different features.

The UI is split between a sidebar which sits on the side of the screen, and a tray which sits on the top or bottom of the screen. Both of these can contain any of the available elements.

Elements can also be displayed temporarily in a floating window.

You can supply an object to the require("dapui").setup() function to configure the elements.

Default settings:

require("dapui").setup({
  icons = {
    expanded = "",
    collapsed = "",
    circular = ""
  },
  mappings = {
    expand = "<CR>",
    open = "o",
    remove = "d"
  },
  sidebar = {
    elements = {
      -- You can change the order of elements in the sidebar
      "scopes",
      "scopes",
      "watches"
    },
    width = 40,
    position = "left" -- Can be "left" or "right"
  },
  tray = {
    elements = {
      "repl"
    },
    height = 10,
    position = "bottom" -- Can be "bottom" or "top"
  }
})

Variable Scopes

image

Element ID: scopes

Displays the available scopes and variables within them.

Mappings:

  • expand: Toggle showing any children of variable.

Threads and Stack Frames

image

Element ID: stacks

Displays the running threads and their stack frames.

Mappings:

  • open: Jump to a place within the stack frame.

Watch Expressions

image

Element ID: watches

Allows creation of expressions to watch the value of in the context of the stack frame they are defined in.

Mappings:

  • open: Jump to the stack frame the expression was defined in.
  • expand: Toggle the value and frame position of the expression.
  • remove: Remove the watched expression.

REPL

Element ID: repl

The REPL provided by nvim-dap.

Usage

To get started simply call the setup method on startup, optionally providing custom settings.

require("dapui").setup()

nvim-dap-ui will add hooks to nvim-dap to open the sidebar and tray whenever you start a debugging session, and close when the session is finished.

Floating Elements

For elements that are not opened in the tray or sidebar, you can open them in a floating window.

image

require("dapui").float_element(<element ID>)

If you do not provide an element ID, you will be queried to select one.

Call the same function again while the window is open and the cursor will jump to the floating window. The REPL will automatically jump to the floating window on open.

Evaluate Expression

For a one time expression evaluation, you can call a hover window to show a value

image

require("dapui").eval(<expression>)

If an expression is not provided it will use the word under the cursor, or if in visual mode, the currently highlighted text. You can define a visual mapping like so

vnoremap <M-k> <Cmd>lua require("dapui").eval()<CR>

Call the same function again while the window is open to jump to the eval window.

About

A UI for nvim-dap


Languages

Language:Lua 99.8%Language:Shell 0.2%