Skip to content
This repository was archived by the owner on Jan 17, 2024. It is now read-only.
This repository was archived by the owner on Jan 17, 2024. It is now read-only.

Treesitter not updating or refreshing automatically as text changes #64

@wookayin

Description

@wookayin

Describe the bug

Treesitter syntax tree does not update or refresh automatically as I update the buffer. Please see the video below.

Screenshot

To Reproduce

This is how I did when generating the video above:

$ nvim -u minimal.vim a.py

minimal.vim:

packadd nvim-treesitter
packadd nvim-treesitter-playground
packadd nvim-gps

source ~/.config/nvim/lua/config/treesitter.lua
set statusline=%{%v:lua.require'nvim-gps'.get_location()%}

where treesitter.lua contains a minimal setup config, nothing special there.

Expected behavior

Treesitter syntax tree (shown from TSPlayground or nvim-gps) should update automatically. It seems that playground does update automatically when I insert new blank lines, but the syntax tree gets out of sync. nvim-gps does not recognize the new context (nested functions) that was typed after opening the buffer.

Output of :checkhealth nvim-treesitter

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.4 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v17.3.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: Apple clang version 13.0.0 (clang-1300.0.29.30)
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - pioasm         ✓ . . . ✓ 
  - vala           ✓ . . . . 
  - hocon          ✓ . . . ✓ 
  - cmake          ✓ . ✓ . . 
  (..omitted..)
  - python         ✓ ✓ ✓ ✓ ✓ 
  (...)

Output of nvim --version

Version information:

  • NVIM v0.7.0-dev+1032-g01e58fb14 (built today)
  • tree-sitter -V: tree-sitter 0.20.4 (installed through homebrew)
  • MacOS 12.0 (arm64)
  • I've run :TSUpdate and all parsers are up-to-date

Additional context

I thought this was a bug of nvim-gps, but it seems that it's the problem of my treesitter itself (ref: SmiteshP/nvim-gps#69) because playground is also not working.

I searched existing issues but haven't found anything relevant (e.g., nvim-treesitter/nvim-treesitter#78, nvim-treesitter/nvim-treesitter#235 are about highlights.)

This happens for all filetypes, not only python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions