2020-04-22 17:17:21 +02:00
|
|
|
[](https://gitter.im/nvim-treesitter/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
2020-04-18 17:32:14 +02:00
|
|
|
# nvim-treesitter
|
2020-04-22 17:17:21 +02:00
|
|
|
Treesitter configurations and abstraction layer for Neovim.
|
|
|
|
|
|
|
|
|
|
# Quickstart
|
|
|
|
|
|
|
|
|
|
## Requirements
|
2020-04-22 19:36:10 +02:00
|
|
|
- Neovim [nightly](https://github.com/neovim/neovim#install-from-source)
|
|
|
|
|
- `git` in your path.
|
|
|
|
|
- A C compiler in your path.
|
2020-04-22 17:17:21 +02:00
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
2020-04-23 12:51:00 -04:00
|
|
|
You can install `nvim-treesitter` with your favorite package manager, or using the default `pack` feature of Neovim!
|
2020-04-22 17:17:21 +02:00
|
|
|
|
|
|
|
|
### Using a package manager
|
|
|
|
|
|
|
|
|
|
Simply add these lines to your `init.vim` :
|
|
|
|
|
```vim
|
|
|
|
|
Plug 'nvim-treesitter/nvim-treesitter'
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### Using neovim `pack` feature
|
|
|
|
|
|
2020-04-22 19:36:10 +02:00
|
|
|
We highly recommend reading `:h packages` to learn more about this feature, but you can still follow these steps:
|
2020-04-22 17:17:21 +02:00
|
|
|
```sh
|
|
|
|
|
$ 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
|
|
|
|
|
|
2020-04-22 19:36:10 +02:00
|
|
|
Treesitter is using a different _parser_ for every language. It can be quite a pain to install, but fortunately `nvim-treesitter`
|
|
|
|
|
provides two command to tackle this issue:
|
2020-04-22 17:17:21 +02:00
|
|
|
- `TSInstall` to install a given parser.
|
|
|
|
|
- `TSInstallInfo` to know which parser is installed.
|
|
|
|
|
|
2020-04-22 19:46:57 +02:00
|
|
|
Let's say you need parsers for `lua`, `c`, and `python`, this is how you do with these commands:
|
2020-04-22 17:17:21 +02:00
|
|
|
```vim
|
|
|
|
|
: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
|
|
|
|
|
```
|
|
|
|
|
|
2020-04-22 19:47:09 +02:00
|
|
|
Cool, lets see which parsers are installed:
|
2020-04-22 17:17:21 +02:00
|
|
|
```vim
|
|
|
|
|
: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
|
|
|
|
|
```
|
|
|
|
|
|
2020-04-23 12:51:00 -04:00
|
|
|
And now you should be able to use every functionality `nvim-treesitter` provides!
|
2020-04-22 17:17:21 +02:00
|
|
|
|
|
|
|
|
## Features and Roadmap
|
|
|
|
|
|
2020-04-23 12:51:00 -04:00
|
|
|
The goal of `nvim-treesitter` is both to provide a simple and easy way to use the interface for Treesitter in Neovim,
|
|
|
|
|
but also to add some functionalities to it:
|
2020-04-22 17:17:21 +02:00
|
|
|
Some of these features are :
|
|
|
|
|
- [ ] Incremental selection
|
|
|
|
|
- [ ] Syntax based code folding
|
|
|
|
|
- [ ] Consistent syntax highlighting
|
|
|
|
|
|
2020-04-22 19:36:10 +02:00
|
|
|
You can find the roadmap [here](https://github.com/nvim-treesitter/nvim-treesitter/projects/1).
|
2020-04-23 12:51:00 -04:00
|
|
|
The roadmap and all features of this plugin are open to change, and any suggestion will be highly appreciated!
|
2020-04-22 17:17:21 +02:00
|
|
|
|
|
|
|
|
## Troubleshooting
|
2020-04-22 19:36:10 +02:00
|
|
|
Before doing anything run `:checkhealth nvim_treesitter`. This will help you find where the bug might come from.
|
2020-04-22 17:17:21 +02:00
|
|
|
|
|
|
|
|
### Feature `X` does not work for language `Y`...
|
2020-04-22 19:36:10 +02:00
|
|
|
First, check the `## Y parser healthcheck` section of `:checkhealth` if you have any warning.
|
|
|
|
|
If you do, it's highly possible that this is the cause of the problem.
|
2020-04-22 17:17:21 +02:00
|
|
|
If everything is okay, then it might be an actual error.
|
|
|
|
|
|
|
|
|
|
In both cases, feel free to open an issue here.
|