Skip to content

Bug: Diagnostic virtual text is not updated in the treesitter context #509

Open
@benelan

Description

@benelan

Description

Diagnostic virtual text does not get updated in the treesitter context until you go out of the scope and then back in. It can be confusing when there is diagnostic virtual text displayed in the context and it doesn't go away after fixing the issue.

I pinned commit 8198ad4 for now, which doesn't display virtual text in the treesitter context at all.

Neovim version

v0.10.2

Expected behavior

Diagnostic virtual text gets updated in the treesitter context when it changes.

Actual behavior

Diagnostic virtual text does not get updated in the treesitter context until you go out of the scope and then back in.

Minimal config

local plugins = {
  ts = "https://github.com/nvim-treesitter/nvim-treesitter",
  ts_context = "https://github.com/nvim-treesitter/nvim-treesitter-context",
  lspconfig = "https://github.com/neovim/nvim-lspconfig",
  mason = "https://github.com/williamboman/mason.nvim",
  mason_lspconfig = "https://github.com/williamboman/mason-lspconfig.nvim",
}

for name, url in pairs(plugins) do
  local install_path = "/tmp/nvim/site/" .. name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "--depth=1", url, install_path })
  end
  vim.o.runtimepath = install_path .. "," .. vim.o.runtimepath
end

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE
vim.diagnostic.config({ virtual_text = true })

require("mason").setup()
require("mason-lspconfig").setup({
  ensure_installed = { "bashls" },
  handlers = {
    ["bashls"] = function()
      require("lspconfig")["bashls"].setup({
        capabilities = vim.lsp.protocol.make_client_capabilities(),
      })
    end,
  },
})

Steps to reproduce

Save the following as test.sh next to minimal.lua:

#!/usr/bin/env bash
test() {
    echo "test"
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
    #
}
  1. nvim --clean -u minimal.lua test.sh
  2. Press G
  3. Press dd
  4. Notice there is no virtual text on the treesitter context
  5. Press gg
  6. Notice the virtual text on line 2
  7. Press G
  8. Notice the virtual text on the treesitter context
  9. Press u
  10. Notice the virtual text is still on the treesitter context
  11. Press gg
  12. Notice there is no virtual text on line 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions