Custom Views

You can write your own views. If you are a plugin author, this allows you to embed your plugin into nvim-dap-view.

If you are a regular user and you are missing a view, consider making a feature request instead of writing your own implementation.

Writing a custom view is similar to writing a custom button . A view consists of an ID and 6 fields:

  1. A label, the string that will show up in the user's winbar
  2. A short_label, which is used when there's not enough space to display the whole winbar
  3. An action function to render the component
  4. A keymap, which will trigger the action
  5. A buffer function that will create a new buffer and return its bufnr
  6. A filetype, which is the filetype of the buffer

The logic after the action is triggered is not handled by nvim-dap-view.

Example

A bare bones view would consist of:

return {
    winbar = {
        custom_sections = {
            my_new_view = { -- the ID
                label = "My new view",
                short_label = "mnv",
                action = function()
                    vim.print("Hi from view")
                end,
                keymap = "M",
                buffer = function()
                    return vim.api.nvim_create_buf(true, false)
                end,
                ft = "my-custom-ft",
            },
        },
    },
}
lua

To add a custom view to your config, just add it to the sections table as if it was a regular view:

return {
    winbar = {
        sections = {
            "my_new_view",
            -- ...
        },
    },
}
lua

Register View

If you are a plugin author, you can use the register_view function to ensure your view is loaded. By doing that, users don't have to create the custom view "manually". An example can be found here .