andersevenrud / nvim_context_vt

Virtual text context for neovim treesitter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Duplicate virtual text

andersevenrud opened this issue · comments

I'm not really sure if this is something that very recently started happening, but I'm getting duplicate virtual texts when I go deeper into a tree.

Setup

NVIM v0.7.0-dev+811-gb0993bdc4
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by anders

nvim-treesitter checkhealth:

  - OK: `tree-sitter` found  0.20.1 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v17.2.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (GCC) 11.1.0
  - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.

Installed nvim-treesitter HEAD:

fa2a6b68aaa6df0187b5bbebe6cbadc120d4a65a

Minimum reproducible configuration

require("packer").startup(function(use)
        use "wbthomason/packer.nvim"
        use {
                "nvim-treesitter/nvim-treesitter",
                config = function()
                        require'nvim-treesitter.configs'.setup {
                                ensure_installed = "maintained",
                                highlight = {
                                        enable = true,
                                },
                        }
                end
        }
        use {
                "haringsrob/nvim_context_vt",
                requires = { "nvim-treesitter/nvim-treesitter" }
        }
end)

Visualization

Watch as I step through every line of the configuration above in an isolated environment from my regular setup:

Ignore the difference in configuration from above example as I moved some text around for testing purposes

nvim_context_vt-bug-2022-01-03_18.26.51.mp4

Additional information

This is the output when I'm on line 2 using :lua require 'nvim_context_vt'.showDebug():

current type
function_definition
parent type
arguments

Another one in typescript/javascript, though technically not the same, there should only be one 🤔

This seems to be the culprit:

https://github.com/haringsrob/nvim_context_vt/blob/49fd42bb410e35c6e5ab1c7671c1ac2cd4763418/lua/nvim_context_vt.lua#L136-L138

My guess is that there probably needs to be some guard here so only one extmark is set per line.

Thank you for reporting and fixing this issue!