Open
Description
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"
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
}
nvim --clean -u minimal.lua test.sh
- Press
G
- Press
dd
- Notice there is no virtual text on the treesitter context
- Press
gg
- Notice the virtual text on line 2
- Press
G
- Notice the virtual text on the treesitter context
- Press
u
- Notice the virtual text is still on the treesitter context
- Press
gg
- Notice there is no virtual text on line 2