Giter Club home page Giter Club logo

nvim-dap-virtual-text's Introduction

nvim-dap-virtual-text

This plugin adds virtual text support to nvim-dap. nvim-treesitter is used to find variable definitions.

Plug 'mfussenegger/nvim-dap'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'theHamsta/nvim-dap-virtual-text'

The hlgroup for the virtual text is NvimDapVirtualText (linked to Comment). Exceptions that caused the debugger to stop are displayed as NvimDapVirtualTextError (linked to DiagnosticVirtualTextError). Changed and new variables will be highlighted with NvimDapVirtualTextChanged (default linked to DiagnosticVirtualTextWarn).

The behavior of this plugin can be activated and controlled via a setup call

require("nvim-dap-virtual-text").setup()

Wrap this call with lua <<EOF when you are using viml for your config:

lua <<EOF
require("nvim-dap-virtual-text").setup()
EOF

or with additional options:

require("nvim-dap-virtual-text").setup {
    enabled = true,                        -- enable this plugin (the default)
    enabled_commands = true,               -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
    highlight_changed_variables = true,    -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
    highlight_new_as_changed = false,      -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
    show_stop_reason = true,               -- show stop reason when stopped for exceptions
    commented = false,                     -- prefix virtual text with comment string
    only_first_definition = true,          -- only show virtual text at first definition (if there are multiple)
    all_references = false,                -- show virtual text on all all references of the variable (not only definitions)
    clear_on_continue = false,             -- clear virtual text on "continue" (might cause flickering when stepping)
    --- 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)
      if options.virt_text_pos == 'inline' then
        return ' = ' .. variable.value
      else
        return variable.name .. ' = ' .. variable.value
      end
    end,
    -- position of virtual text, see `:h nvim_buf_set_extmark()`, default tries to inline the virtual text. Use 'eol' to set to end of line
    virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol',

    -- experimental features:
    all_frames = false,                    -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
    virt_lines = false,                    -- show virtual lines instead of virtual text (will flicker!)
    virt_text_win_col = nil                -- position the virtual text at a fixed window column (starting from the first text column) ,
                                           -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`
}

With support for inline virtual text (nvim 0.10), virt_text_pos = 'inline'

image

With highlight_changed_variables = false, all_frames = false

current_frame

With highlight_changed_variables = false, all_frames = true

all_scopes

It works for all languages with locals.scm in nvim-treesitter (@definition.var is required for variable definitions). This should include C/C++, Python, Rust, Go, Java...

image

image

The virtual text can additionally use a comment-like syntax to further improve distinguishability between actual code and debugger info by setting the following option:

require("nvim-dap-virtual-text").setup {
  commented = true,
}

This will use the commentstring option to choose the appropriate comment-syntax for the current filetype

image

With virt_text_win_col = 80, highlight_changed_variables = true (x has just changed its value)

image

Show Stop Reason on Exception

image image

Exception virtual text can be deactivated via

require("nvim-dap-virtual-text").setup {
  show_stop_reason = false,
}

nvim-dap-virtual-text's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nvim-dap-virtual-text's Issues

Virtual text appears only for previous lines

The virtual text is shown for a variable only on the previous lines during debugging. (1)
On the attached screenshot, new_value 's value is not shown for the current line (3), only the definition preceding it. (2)
Is this something expected? ๐Ÿค” The value c is printed for every line in your README demo.

The snippet is inside a for loop in which the first new_value (1) is updated in the previous iteration than (2).

image

Deprecation warning for `get_node_text`

When using the plugin, I get the following warning: nvim-treesitter.ts_utils.get_node_text is deprecated: use vim.treesitter.query.get_node_text.

If I understand correctly, the fix is just to use the function mentioned in the warning and to remove the [1] index at the end. I implemented the fix here: vandalt@de40488. I can send a PR if you want.

Thank you!

Error: Attempt to concatenate nil error_prefix

When using this configuration:

  require("nvim-dap-virtual-text").setup({
    enabled = true,
    highlight_changed_variables = true,
    highlight_new_as_changed = true,
    show_stop_reason = true,
  })

I get this error when my program stops on an error:

screenshot_20211101_013203

I am using the gdb debugger and the exception/error I get when I run this in the terminal is just a segfault:

Segmentation fault (core dumped)

Allow filter by name too

Hi @theHamsta

I looked how filter_references_pattern works and see that it filters the value of evaluated variable.

I'd like to hide this - in most cases it's not needed for me.

What do you think about adding filters for names too?

Error 17:29:47 msg_show.lua_error Error executing vim.schedule lua callback: ...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:200: bad argument #1 to 'pairs' (table expected, got nil)

I got the following error if I run dap.step_over() too fast before you're probably preparing something. It will be good to use pcall, thanks.

 ๎ช‡  Error  17:29:47 msg_show.lua_error Error executing vim.schedule lua callback: ...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:200: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
	[C]: in function 'pairs'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:200: in function 'c'
	...wang/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:964: in function <...wang/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:957>

Invalid 'virt_text_pos'

I'm getting this error every time I step forward when debugging:

image

Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:213: Invalid 'virt_text_pos'
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:213: in function 'set_virtual_text'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
	...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:953: in function <...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:947>

Workaround

I can get rid of this problem entirely by removing the display_callback:

{
    "theHamsta/nvim-dap-virtual-text",
    config = function()
        require("nvim-dap-virtual-text").setup({
            display_callback = function(variable, buf, stackframe, node, options) end,
        })
    end,
},

Or I can make sure to use the 10f858c commit of nvim-dap-virtual-text.

My setup

I'm using LazyVim which loads nvim-dap-virtual-text itself (see here) as I've enabled LazyVim's "DAP Core" (which installs nvim-dap and friends).

On top of that I've got these DAP settings and these neotest settings. My entire neovim config is available in my dotfiles repo here.

Print debugging

I added a print statement before the "offending" line at virtual_text.lua:213:

print(options.virt_text_pos, buf, hl_namespace, node_range[inline and 3 or 1], node_range[inline and 4 or 2])
08:03:23 msg_show inline 1 147 10 10
 ๎ช‡  Error  08:03:23 msg_show.lua_error Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: Invalid 'virt_text_pos'
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: in function 'set_virtual_text'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
	...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:953: in function <...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:947>
08:03:23 msg_show inline 1 147 10 10
 ๎ช‡  Error  08:03:23 msg_show.lua_error Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: Invalid 'virt_text_pos'
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: in function 'set_virtual_text'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
	...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:953: in function <...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:947>
08:03:23 msg_show inline 1 147 10 10
 ๎ช‡  Error  08:03:23 msg_show.lua_error Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: Invalid 'virt_text_pos'
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: in function 'set_virtual_text'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
	...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:953: in function <...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:947>
08:03:23 msg_show inline 1 147 10 10
 ๎ช‡  Error  08:03:23 msg_show.lua_error Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: Invalid 'virt_text_pos'
stack traceback:
	[C]: in function 'nvim_buf_set_extmark'
	...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:217: in function 'set_virtual_text'
	...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
	...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:953: in function <...k/.local/share/LazyVim/lazy/nvim-dap/lua/dap/session.lua:947>

Solution

Can you see what's going on here - and/or what can be done to fix this?

Linked discussion

LazyVim/LazyVim#821

Race condition for custom response handler?

I observed that the virtual text does not show up reliably since this plugin was factored out of the PR. We rely that our response handler is executed after the handler of nvim-dap. But this doesn't seem to be the always case (except for slow Python debugger debugpy), especially

Placing the following after this line https://github.com/mfussenegger/nvim-dap/blob/20e4bb21dbe4c35965b37687fdaf384a09e9330f/lua/dap.lua#L401

seems to solve the issue (this would guarantee that we are always called after nvim-dap setting the variables.

          for _, c in pairs(M.custom_response_handlers.variables) do
            c(self, nil)
          end

Does not show the correct current value

Actual
Shows a wrong value for the arr: list[tuple[int,int]] variable.
Expected
Show the right value [(1, 2), (0, 3), (2, 4)]

You can see on the attached screenshot [nvim-dap-virtual-text](https://github.com/theHamsta/nvim-dap-virtual-text) shows [3, 2, 4] while at the bottom dap repr shows [(1, 2), (0, 3), (2, 4)]
image

Code that I used.

from operator import itemgetter


class Solution:
    def twoSum(self, nums: list[int], target: int) -> list[int]:
        if len(nums) < 2:
            return nums

        arr = list(sorted(enumerate(nums), key=itemgetter(1)))
        i = 0
        j = len(nums) - 1

        while i < j:
            arri = arr[i]
            arrj = arr[j]
            sum_ = arri[1] + arrj[1]
            if sum_ == target:
                return [arri[0], arrj[0]]
            elif sum_ > target:
                j -= 1
            else:
                i += 1
        return []

arr = [2, 7, 11, 15]
target = 9

Solution().twoSum(arr, target) == [0, 1]

cannot convert lua table error when virt_lines=true

Below is my config for this plugin:

require("nvim-dap-virtual-text").setup({ 
    virt_lines=true, 
    virt_lines_above=false
})

It throws below error when debugging, and the plugin does not display any virtual text.

Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:232: Cannot convert given lua table
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:232: in function 'set_virtual_text'
        ...tart/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:969: in function <...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:963>
Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:232: Cannot convert given lua table
stack traceback:
        [C]: in function 'nvim_buf_set_extmark'
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:232: in function 'set_virtual_text'
        ...tart/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:969: in function <...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:963>

Looking through the code, it seems lua is unable to convert the content table (which contains the virtual lines), for nvim_buf_set_extmark().

Swift support?

Is there any easy way to make it work with Swift? Thank you in advance :)

[Feature Request] option to shorten types

I love this plugin, very simple yet elegant and effective. Thank you for making it.
The cherry on top would be an option to shorten types, I use the debugger often with C++ and the types can become quickly very long.
nvim-dap-ui is a perfect example of what I would like to have:

image

I don't know how much work that requires but it would help readability a lot, I would probably just get rid of the type all together if I could and inspect the object only when I need it.

Thank you,
Andrea

No text with vscode-php-adapter

Hi,

currently this plugin does not work with
https://github.com/xdebug/vscode-php-debug.

As far I checked the reason is in a slight difference on how variables are detected/named between treesitter and xdebug. For example xdebug uses $request while treesitter uses request.

So far i could fix the problem with a language specific workaround in lua/nvim-dap-virtual-text/virtual_text.lua:

  for _, s in ipairs(scopes) do
    if s.variables then
      for _, v in pairs(s.variables) do
        if lang == 'php' then
            variables[v.name:gsub("^%$", "")] = v
        else
            variables[v.name] = v
        end
      end
    end
  end

This only works for the function arguments, but does not show anything for inner function variables.

Treesitter error when running in kotlin

I am getting the below error when trying to run the plugin with kotlin. Note that the error doesn't appear to be with tree-sitter as it works fine when i remove the nvim-dap-virtual-text plugin.

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: no parser for 'kotlin' language, see :help treesitter-parsers
stack traceback:
[C]: in function 'error'
/usr/share/nvim/runtime/lua/vim/treesitter/language.lua:103: in function 'add'
/usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:113: in function 'new'
/usr/share/nvim/runtime/lua/vim/treesitter.lua:64: in function '_create_parser'
/usr/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:93: in function 'set_virtual_text'
...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
....local/share/nvim-lazy/lazy/nvim-dap/lua/dap/session.lua:968: in function <....local/share/nvim-lazy/lazy/nvim-dap/lua/dap/session.lua:962>

nvim-cap-virtual-text.lua

return {
  {
    "theHamsta/nvim-dap-virtual-text",
    config = function()
       require("nvim-dap-virtual-text").setup()
    end 
  },
}

treesitter

  {
    "nvim-treesitter/nvim-treesitter",
    opts = {
      ensure_installed = {
        "bash",
        "html",
        "javascript",
        "json",  -- add symbols-outline
        "kotlin",
  },

Getting option (nil value error) and odd virtual text color change

So I keep getting errors message when using this plugin and I am not sure if it comes from my configuration or some other error.
here is the error I see:

Error executing vim.schedule lua callback: ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:279: attempt to index local 'options' (a nil value)
stack traceback:
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:279: in function '_on_continue'
        ...lazy/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:148: in function 'c'
        ...adou/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:974: in function <...adou/.local/share/nvim/lazy/nvim-dap/lua/dap/session.lua:970>

You can see it happening in this scenario:
https://www.loom.com/share/8b9e590e21f94c958115e93a667525ea

Unit test -> run neotest with dap -> goes to breakpoint -> step over -> error -> continue -> error -> continue -> error -> continue (and it ends bunch of more errors).
Also notice how the virtual text changes colors when I step over versus when it goes into the breaking point. I believe this is expected behavior regarding my configuration as I have highlight_changed_variables = true.

Finally, not sure if this is related but depending what I do in the REPL the virtual text will go away...
see here:
https://www.loom.com/share/9073525124694eaa95b1644c3fbb855d
go to break point -> go to repl -> type print(xx) -> works -> type xx -> virtual text goes away -> continue -> still away -> step over -> virtual text is back!
This is my lazy vim conf for reference:

return {
  {
    'nvim-neotest/neotest-python',
    dependencies = {
      { 'nvim-neotest/neotest' },
    },
  },
  {
    'nvim-neotest/neotest',
    config = function()
      require("neotest").setup {
        log_level = vim.log.levels.DEBUG,
        quickfix = {
          open = false,
        },
        status = {
          virtual_text = true,
          signs = true,
        },
        adapters = {
          require "neotest-python" {
            -- Extra arguments for nvim-dap configuration
            -- See https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for values
            dap = {
              justMyCode = false,
              console = "integratedTerminal",
            },
            -- args = { "--log-level", "DEBUG", "--quiet" },
            -- runner = "pytest",
            -- runner = "unittest",
          },
        },
      }
    end,
    dependencies = {
      { 'nvim-neotest/neotest-python' },
    },
  },
  { 'mfussenegger/nvim-dap' },
  { 'mfussenegger/nvim-dap-python',
    config = function()
      local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
      pcall(function()
        require("dap-python").setup(mason_path .. "packages/debugpy/venv/bin/python")
      end)
    end,
    dependencies = {
      { 'mfussenegger/nvim-dap' },
    }
  },
  { 'rcarriga/nvim-dap-ui',
    config = function()
      require("dapui").setup()
    end,
    dependencies = {
      { 'mfussenegger/nvim-dap' },
    }
  },
  { 'LiadOz/nvim-dap-repl-highlights',
    config = function()
      require('nvim-dap-repl-highlights').setup()
    end,
    dependencies = {
      { 'mfussenegger/nvim-dap' },
    }
  },
  {
    'theHamsta/nvim-dap-virtual-text',
    config = function()
      require("nvim-dap-virtual-text").setup {
        enabled = true, -- enable this plugin (the default)
        enabled_commands = true, -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)
        highlight_changed_variables = true, -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText
        highlight_new_as_changed = false, -- highlight new variables in the same way as changed variables (if highlight_changed_variables)
        show_stop_reason = true, -- show stop reason when stopped for exceptions
        commented = true, -- prefix virtual text with comment string
        only_first_definition = false, -- only show virtual text at first definition (if there are multiple)
        all_references = true, -- show virtual text on all all references of the variable (not only definitions)
        -- experimental features:
        -- virt_text_pos = 'eol', -- position of virtual text, see `:h nvim_buf_set_extmark()`
        all_frames = true, -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.
        virt_lines = false, -- show virtual lines instead of virtual text (will flicker!)
        -- virt_text_win_col = nil -- position the virtual text at a fixed window column (starting from the first text column) ,
        -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`
      }
    end
  },
  dependencies = {
    { 'mfussenegger/nvim-dap' },
  }
}

This was executed with debugpy.
Side note.. I wish it would have better display for tensorflow tensor ^^ but I know this one is not on you ^^.

Virtual text isn't cleared 'on demand'

Hey!

Thanks for the nice plugin :)

I'm having trouble hiding the virtual text. There is some discussion about this issue in another thread:

          Even `:DapVirualTextDisable` doesn't clear the virt text for me: no new text is produced, but the old text does not hide.

Originally posted by @crhf in #14 (comment)

From what I understand, reading the original discussion, is that the logic to hide the virtual text is coupled with nvim-dap's event system. Nonetheless, it would be nice if commands like :DapVirtualTextDisable and :DapVirtualTextToggle could actually hide the text.

Virtual text in scala showing at incorrect position for function arguments

Hi,

I am trying to integrate this plugin with scala and I noticed that the virtual text for function arguments is displayed incorrectly if earlier in the file there is another function that contains argument with the same name.

image

Here are definitions for nvim-treesitter locals:

[(block)
(template_body)
(lambda_expression)
(function_declaration)] @scope

(function_declaration
  name: (identifier) @definition.function)

(val_definition
  pattern: (identifier) @definition.var)

(parameters (parameter name: (identifier) @definition.parameter ))

Any idea what could be the reason?
Btw scope detection works correctly for local variables defined within the function.
In the attached example var2 is detected correctly.

Lazy loading the plugin -- this costs ~25ms on startup

Not a huge deal obviously as that's not too much time, but from measuring with nvim --startuptime nvim-dap-virtual-text adds 22-30-ish ms on startup but doesn't do anything until nvim-dap is in use (which is a relatively uncommon thing anyways). Lazily loading this plugin would be a nice improvement.

CursorLine doesn't override virtual text background

image

I'd expect `CursorLine` background under the virtual text.

I've tried changing NvimDapVirtualText guibg=NONE etc but it didn't work. :( Comment doesn't have this issue (the background respects CursorLine) and NvimDapVirtualText still links to it.

Ideas how to customize the output (per language)

Example from PHP: any object of class that implements JsonSerializable could be rendered as the result of json_encode on it.

I have no idea that looks possibly good.

I thought about a callback that would be provided by the user to convert the variable to the desired form. It could use dap.session():evaluate() but I have doubt how practical is it.

Does not show actual values for recursive calls

It seems [nvim-dap-virtual-text](https://github.com/theHamsta/nvim-dap-virtual-text) shows only the values of the first method call and does not update on recursive call.

image

class Solution:
    def isValidBST(self, root: Optional[TreeNode]) -> bool:
        # validation
        if not root:
            return True

        left = True
        if root.left:
            if root.left.val < root.val:
                left = True and self.isValidBST(root.left)
            else:
                left = False

        right = True
        if root.right:
            if root.right.val > root.val:
                right = True and self.isValidBST(root.right)
            else:
                left = False

        return left and right


root = to_binary_tree([5, 4, 6, None, None, 3, 7])

# test cases
result = Solution().isValidBST(root)
assert not result

ignore signal SIGWINCH

This is mostly an annoyance, but currently, I'd say the plugin doesn't handle very well a SIGWINCH[1]. If a SIGWINCH happens, the plugin will display it in every single debugging step. Apologies if this is the intended behavior, as I imagine it might be useful in some cases. However, it clutters the view when debugging using an external terminal, as it's not unusual to resize splits/windows for whatever reason.

[Bug] Does not work with C++

Hi.
It does not work with c++.
My config:
Neovim 0.5.1
Kubuntu 21.10

Plug 'mfussenegger/nvim-dap'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'theHamsta/nvim-dap-virtual-text'

vim.g.dap_virtual_text = true
vim.g.dap_virtual_text = true
vim.g.dap_virtual_text = 'all frames'

let g:dap_virtual_text_commented = v:true

My treesitter:
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
disable = {"javascript","json"},
},
indent = {
enable = true,
disable = {},
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gti",
node_incremental = "gtf",
scope_incremental = "gts",
node_decremental = "gtd",
},
},
refactor = {
highlight_definitions = { enable = true },
highlight_current_scope = { enable = false },
smart_rename = {
enable = true,
keymaps = {
smart_rename = "gtr",
},
},
navigation = {
enable = true,
keymaps = {
goto_definition = "gtD",
list_definitions = "gtl",
list_definitions_toc = "gtt",
goto_next_usage = "<a-*>",
goto_previous_usage = "<a-#>",
},
},
},
ensure_installed = {
"cpp",
"llvm",
"cmake",
"glsl",
"lua",
"bash",
"comment",
"vim"

},
}
local parser_config = require "nvim-treesitter.parsers".get_parser_configs()
local ts_utils = require 'nvim-treesitter.ts_utils'

vim.treesitter.query.get_query() is deprecated, use vim.treesitter.query.get() instead

When using the plugin there is a new deprecation warning:

vim.treesitter.query.get_query() is deprecated, use vim.treesitter.query.get() instead. :help deprecated                                                                                       
stack traceback:
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:200: in function 'get_query'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:104: in function 'get_query'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:196: in function 'prepare_query'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:378: in function 'iter_group_results'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:390: in function 'collect_group_results'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:48: in function 'update_cached_matches'
        ...im/plugged/nvim-treesitter/lua/nvim-treesitter/query.lua:56: in function 'get_locals'
        ...m/plugged/nvim-treesitter/lua/nvim-treesitter/locals.lua:52: in function 'get_scopes'
        ...-virtual-text/lua/nvim-dap-virtual-text/virtual_text.lua:95: in function 'set_virtual_text'
        ...tart/nvim-dap-virtual-text/lua/nvim-dap-virtual-text.lua:112: in function 'c'
        ...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:968: in function <...nvim/site/pack/packer/start/nvim-dap/lua/dap/session.lua:962>

It seems like a call to treesitter's get_scopes does an internal call to get_query which is deprecated.

is this warning even relevant for this plugin if it doesn't use get_query directly?

`only_last_definition` option

Generally, the last definition for a variable is closer the exception than the first definition. This would be convenient to have the virtual text displayed on the nearest definition.
I suggest the implementation of a only_last_definition option, which would be the mirror of only_last_definition.
What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.