wookayin/dotfiles

Treesitter integration

wookayin opened this issue · 4 comments

Continued from #27

Basic support (syntax, folding)

  • https://github.com/nvim-treesitter/nvim-treesitter
  • ✅ Debugging: https://github.com/nvim-treesitter/playground
  • Note: Treesitter's syntax highlight overrides existing python syntax, which is annoying It should also replace semshi (since most use cases are covered). It also breaks some other plugins that rely on highlight groups (e.g. vim-autoimport) because synID cannot retrieve dynamic highlights. When TS is enabled, old vim regex highlights should be avoided (they usually don't work together nicely).

Some cool plugins powered by treesitter

See https://github.com/nvim-treesitter/nvim-treesitter/wiki/Extra-modules-and-plugins for a comprehensive list

To make (some) treesitter modules work properly with up-to-date parse tree as text change, either playground-highlight module needs to be enabled or some workaround like ec2f252 is needed, when one doesn't want to use playground's highlight/syntax feature yet.

Improved python folding -- the whole function/class is now foldable, rather than its body only (which should also be fixed in the upstream soon).

Some issues with treesitter highlights (for lua): embedded vimscripts vim.cmd [[ ... ]] are highlighted as @string:

image

-> Workaround discussed in https://www.reddit.com/r/neovim/comments/1059xht/comment/j3dw7ty/

image

See 5a4b971

  • Most of core filetypes (lua, cpp, vim, rust, tex, etc.) now use treesitter highlights (see be7102e). See individual filetype plugins.
  • Automatic parser installation and error recovery utils are added.
  • Some treesitter utilities: 91b77f0.

Closing as done. Configurations for advanced plugins will be added in the next steps.