summaryrefslogtreecommitdiffstats
path: root/lua/conf/plugins/dap-vtxt.lua
blob: 30b263271bfda479b1768e1e24e5e9c96487833d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
return { "theHamsta/nvim-dap-virtual-text",
  requires = {
    "nvim-treesitter/nvim-treesitter",
    "mfussenegger/nvim-dap"
  },
  function()
    require("nvim-dap-virtual-text").setup {
      virt_text_pos = vim.fn.has("nvim-0.10") == 1 and "inline" or "eol",

      --- A callback that determines how a variable is displayed or whether it should be omitted
      --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable
      --- @param buf number
      --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame
      --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)
      --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text
      --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed
      display_callback = function(variable, buf, stackframe, node, options)
        -- by default, strip out new line characters
        if options.virt_text_pos == "inline" then
          return " = "..variable.value:gsub("%s+", " ")
        else
          return variable.name.." = "..variable.value:gsub("%s+", " ")
        end
      end
    }
  end
}