Nvim Treesitter configurations and abstraction layer
Find a file
2020-04-22 19:21:02 +02:00
autoload/health feat: add checkhealth 2020-04-21 13:38:16 +02:00
lua feat/refacto: add configs.lua, setup install 2020-04-21 23:40:23 +02:00
parser add parser installer 2020-04-19 15:13:38 +02:00
plugin feat/refacto: add configs.lua, setup install 2020-04-21 23:40:23 +02:00
queries/lua feat: first version of locals 2020-04-19 17:28:52 +02:00
.editorconfig style: add editorconfig 2020-04-18 17:39:03 +02:00
README.md docs(README): update and add quickstart 2020-04-22 19:21:02 +02:00

Gitter

nvim-treesitter

Treesitter configurations and abstraction layer for Neovim.

Quickstart

Requirements

  • Neovim nightly (more)
  • git in you path.
  • A C compiler in you path.

Installation

You can install nvim-treesitter with you favorite package manager, or even using the default pack feature of neovim !

Using a package manager

Simply add these lines to your init.vim :

Plug 'nvim-treesitter/nvim-treesitter'

Using neovim pack feature

As this is a bit more advanced, we highly recommend reading :h packages, but you can also follow these steps:

$ mkdir -p ~/.local/share/nvim/site/pack/nvim-treesitter/start
$ cd ~/.local/share/nvim/site/pack/nvim-treesitter/start
$ git clone https://github.com/nvim-treesitter/nvim-treesitter.git

Adding parsers

Treesitter is based on a parser for each language. Installing them can be quite a pain, but fortunately nvim-treesitter provides two command to tackle this for you :

  • TSInstall to install a given parser.
  • TSInstallInfo to know which parser is installed.

Let's say you want to have a parser for lua, c, and python, here is how to use the commands :

:TSInstall c
Downloading...
Compiling...
Treesitter parser for c has been installed

:TSInstall lua
Downloading...
Compiling...
Treesitter parser for lua has been installed

:TSInstall python
Downloading...
Compiling...
Treesitter parser for python has been installed

Cool, let's check which parser is installed now:

:TSInstallInfo
csharp     [✗] not installed
html       [✗] not installed
typescript [✗] not installed
c          [✓] installed
swift      [✗] not installed
java       [✗] not installed
python     [] installed
cpp        [✗] not installed
lua        [✓] installed
ruby       [✗] not installed
ocaml      [✗] not installed
go         [✗] not installed
rust       [✗] not installed
json       [✗] not installed
javascript [✗] not installed
css        [✗] not installed
julia      [✗] not installed
php        [✗] not installed
bash       [✗] not installed
tsx        [✗] not installed

And now you should be able to use every functionnality nvim-treesitter provides !

Features and Roadmap

The goal of nvim-treesitter is both to provide a simple and easy to use interface to treesitter in neovim, and to add some functionnalities to use it out of the box. Some of these features are :

  • Incremental selection
  • Syntax based code folding
  • Consistent syntax highlighting

You can find the roadmap here. This roadmap and all features of this plugin are everything but definitively determined, and any suggestion will be highly apreciated !

Troubleshooting

Before doing anything run :checkhealth nvim_treesitter. This will give a better overview of which part of the plugin is the source of the bug.

Feature X does not work for language Y...

First, check in the ## Y parser healthcheck section of :checkhealth if you have any warning. If you do, it is highly possible that this is the cause of the problem. If everything is okay, then it might be an actual error.

In both cases, feel free to open an issue here.