{"id":13412581,"url":"https://github.com/theHamsta/nvim-dap-virtual-text","last_synced_at":"2025-03-14T18:31:50.100Z","repository":{"id":40266533,"uuid":"289949308","full_name":"theHamsta/nvim-dap-virtual-text","owner":"theHamsta","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-04T17:08:30.000Z","size":108,"stargazers_count":864,"open_issues_count":8,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-22T11:21:56.933Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/theHamsta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-24T14:22:00.000Z","updated_at":"2024-10-17T22:15:42.000Z","dependencies_parsed_at":"2024-04-12T06:02:19.738Z","dependency_job_id":"b2073989-5a52-4ae7-ae6f-81a8f658e63f","html_url":"https://github.com/theHamsta/nvim-dap-virtual-text","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamsta%2Fnvim-dap-virtual-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamsta%2Fnvim-dap-virtual-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamsta%2Fnvim-dap-virtual-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theHamsta%2Fnvim-dap-virtual-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theHamsta","download_url":"https://codeload.github.com/theHamsta/nvim-dap-virtual-text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221495306,"owners_count":16832456,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:26.409Z","updated_at":"2024-10-26T04:30:50.681Z","avatar_url":"https://github.com/theHamsta.png","language":"Lua","funding_links":[],"categories":["Debugging","Lua"],"sub_categories":["Cursorline","CSV Files"],"readme":"# nvim-dap-virtual-text\n\nThis plugin adds virtual text support to [nvim-dap](https://github.com/mfussenegger/nvim-dap).\n[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) is used to find variable definitions.\n\n```vim\nPlug 'mfussenegger/nvim-dap'\nPlug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}\nPlug 'theHamsta/nvim-dap-virtual-text'\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e With Neovim 0.9 and above, `nvim-treesitter` is not hard a dependency.\n\u003e This plugin only needs the parsers for the languages you want to use it with\n\u003e and `locals.scm` queries defining references and definitions of variables\n\u003e (typically provided by nvim-treesitter).\n\nThe hlgroup for the virtual text is `NvimDapVirtualText` (linked to `Comment`).\nExceptions that caused the debugger to stop are displayed as `NvimDapVirtualTextError`\n(linked to `DiagnosticVirtualTextError`). Changed and new variables will be highlighted with\n`NvimDapVirtualTextChanged` (default linked to `DiagnosticVirtualTextWarn`).\n\nThe behavior of this plugin can be activated and controlled via a `setup` call\n\n```lua\nrequire(\"nvim-dap-virtual-text\").setup()\n```\n\nWrap this call with `lua \u003c\u003cEOF` when you are using viml for your config:\n\n```vim\nlua \u003c\u003cEOF\nrequire(\"nvim-dap-virtual-text\").setup()\nEOF\n```\n\nor with additional options:\n```lua\nrequire(\"nvim-dap-virtual-text\").setup {\n    enabled = true,                        -- enable this plugin (the default)\n    enabled_commands = true,               -- create commands DapVirtualTextEnable, DapVirtualTextDisable, DapVirtualTextToggle, (DapVirtualTextForceRefresh for refreshing when debug adapter did not notify its termination)\n    highlight_changed_variables = true,    -- highlight changed values with NvimDapVirtualTextChanged, else always NvimDapVirtualText\n    highlight_new_as_changed = false,      -- highlight new variables in the same way as changed variables (if highlight_changed_variables)\n    show_stop_reason = true,               -- show stop reason when stopped for exceptions\n    commented = false,                     -- prefix virtual text with comment string\n    only_first_definition = true,          -- only show virtual text at first definition (if there are multiple)\n    all_references = false,                -- show virtual text on all all references of the variable (not only definitions)\n    clear_on_continue = false,             -- clear virtual text on \"continue\" (might cause flickering when stepping)\n    --- A callback that determines how a variable is displayed or whether it should be omitted\n    --- @param variable Variable https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable\n    --- @param buf number\n    --- @param stackframe dap.StackFrame https://microsoft.github.io/debug-adapter-protocol/specification#Types_StackFrame\n    --- @param node userdata tree-sitter node identified as variable definition of reference (see `:h tsnode`)\n    --- @param options nvim_dap_virtual_text_options Current options for nvim-dap-virtual-text\n    --- @return string|nil A text how the virtual text should be displayed or nil, if this variable shouldn't be displayed\n    display_callback = function(variable, buf, stackframe, node, options)\n    -- by default, strip out new line characters\n      if options.virt_text_pos == 'inline' then\n        return ' = ' .. variable.value:gsub(\"%s+\", \" \")\n      else\n        return variable.name .. ' = ' .. variable.value:gsub(\"%s+\", \" \")\n      end\n    end,\n    -- 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\n    virt_text_pos = vim.fn.has 'nvim-0.10' == 1 and 'inline' or 'eol',\n\n    -- experimental features:\n    all_frames = false,                    -- show virtual text for all stack frames not only current. Only works for debugpy on my machine.\n    virt_lines = false,                    -- show virtual lines instead of virtual text (will flicker!)\n    virt_text_win_col = nil                -- position the virtual text at a fixed window column (starting from the first text column) ,\n                                           -- e.g. 80 to position at column 80, see `:h nvim_buf_set_extmark()`\n}\n```\n\nWith support for inline virtual text (nvim 0.10), `virt_text_pos = 'inline'`\n\n![image](https://user-images.githubusercontent.com/7189118/236633778-5e18c02c-4415-46a4-b903-6ee06764ef2a.png)\n\n\nWith `highlight_changed_variables = false, all_frames = false`\n\n![current_frame](https://user-images.githubusercontent.com/7189118/81495691-5d937400-92b2-11ea-8995-17daeda593cc.gif)\n\nWith `highlight_changed_variables = false, all_frames = true`\n\n![all_scopes](https://user-images.githubusercontent.com/7189118/81495701-6b48f980-92b2-11ea-8df4-dd476dc825bc.gif)\n\nIt works for all languages with `locals.scm` in nvim-treesitter (`@definition.var` is required for variable definitions).\nThis should include C/C++, Python, Rust, Go, Java...\n\n![image](https://user-images.githubusercontent.com/7189118/82733259-f4304e00-9d12-11ea-90da-addebada2e18.png)\n\n![image](https://user-images.githubusercontent.com/7189118/91160889-485c1d00-e6ca-11ea-9c70-e329c50ed1e1.png)\n\nThe virtual text can additionally use a comment-like syntax to further improve distinguishability between actual code and debugger info by setting the following option:\n```lua\nrequire(\"nvim-dap-virtual-text\").setup {\n  commented = true,\n}\n```\n\nThis will use the `commentstring` option to choose the appropriate comment-syntax for the current filetype\n\n![image](https://user-images.githubusercontent.com/6146545/134688673-49c86368-ed51-4f16-82b4-fce05bcd9767.PNG)\n\nWith `virt_text_win_col = 80, highlight_changed_variables = true` (x has just changed its value)\n\n![image](https://user-images.githubusercontent.com/7189118/139598856-d45e02ef-62f6-4f7e-a619-ed9b48d53cc1.png)\n\n\n## Show Stop Reason on Exception\n\n![image](https://user-images.githubusercontent.com/7189118/115946315-b3136180-a4c0-11eb-8d8b-980b11464448.png)\n![image](https://user-images.githubusercontent.com/7189118/115946346-db9b5b80-a4c0-11eb-8582-6075d818d869.png)\n\nException virtual text can be deactivated via\n\n```lua\nrequire(\"nvim-dap-virtual-text\").setup {\n  show_stop_reason = false,\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheHamsta%2Fnvim-dap-virtual-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FtheHamsta%2Fnvim-dap-virtual-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtheHamsta%2Fnvim-dap-virtual-text/lists"}