Closed
Description
Problem
Same as #14977.
If using treesitter as fold provider, foldcolumn can be out of sync after the buffer is changed.
Steps to reproduce
-
Create the
minimal.lua
init file:local tmp = vim.env.TMPDIR or vim.env.TEMPDIR or vim.env.TMP or vim.env.TEMP or '/tmp' local data = tmp .. '/' .. (vim.env.NVIM_APPNAME or 'nvim') local packages_root = data .. '/site' local cloned_root = packages_root .. '/pack/packages/start' local cloned_path = cloned_root .. '/nvim-treesitter' local url = 'https://github.com/nvim-treesitter/nvim-treesitter.git' vim.fn.mkdir(cloned_root, 'p') vim.opt.pp:prepend(packages_root) vim.opt.rtp:prepend(packages_root) if not vim.loop.fs_stat(cloned_path) then vim.fn.system({ 'git', 'clone', url, cloned_path }) end require('nvim-treesitter.configs').setup({ ensure_installed = 'json', highlight = { enable = true }, }) vim.o.foldcolumn = '1' vim.o.foldmethod = 'expr' vim.o.foldexpr = 'nvim_treesitter#foldexpr()' vim.o.foldlevelstart = 99
-
Create the following json file
test.json
for testing:{ "glossary": { "title": "example glossary", "GlossDiv": { "title": "S", "GlossList": { "GlossEntry": { "ID": "SGML", "SortAs": "SGML", "GlossTerm": "Standard Generalized Markup Language", "Acronym": "SGML", "Abbrev": "ISO 8879:1986", "GlossDef": { "para": "A meta-markup language, used to create markup languages such as DocBook.", "GlossSeeAlso": [ "GML", "XML" ] }, "GlossSee": "markup" } } } } }
-
nvim --clean -u minimal.lua test.json
-
zjzj
to jump to the first line of the second fold -
O
to insert a line above -
Observe that the foldcolumn is out of sync
Screenshots:
Expected behavior
Foldcolumn should always be in sync.
Foldcolumn should be re-calculated after treesitter updates folds.
Neovim version (nvim -v)
NVIM v0.10.0-dev-1427+gac353e87aec
Vim (not Nvim) behaves the same?
no, vim does not have treesitter
Operating system/version
Linux 6.1.60-1-lts
Terminal name/version
alacritty 0.12.3 (5efb0690) + tmux 3.3a
$TERM environment variable
tmux-256color
Installation
AUR