Tree-sitter based syntax highlighting for Vim
Project description
_ ______ ______ _____ __
| | / / __ \/ ____/ / ___/__ ______ / /_____ __ __
| | / / /_/ / __/ \__ \/ / / / __ \/ __/ __ `/ |/_/ Syntax highlighing
| |/ / ____/ /___ ___/ / /_/ / / / / /_/ /_/ /> < using Tree-sitter
|___/_/ /_____/____/____/\__, /_/ /_/\__/\__,_/_/|_|
/____/
Welcome to the Tree-sitter support for Vim.
- status:
This is version 0.2.0
This is alpha software, but I use it all the time and it has been behaving reliably for me.
Built in support for Python and C code. The documentation added in version 0.2 provided guidelines on how to add other languages. Submissions for additional languages support gratefully received.
News
Version 0.2 significant changes:
Some initial documentation at https://vpe-syntax.readthedocs.io/en/latest/. This is in its very early stages, but does include a tutorial on adding languages.
Any feedback is welcome at https://github.com/paul-ollis/vpe_syntax, either as issues or discussions.
A (hopefully) well defined set of highlight groups (modelled on NeoVim’s set). This should support suitably rich colour schemes.
The right hand side Vim session above is using VPE-Syntax with the colour scheme in examples/colour_scheme.vim.
A functional colour scheme editor is available. Start it with the command:
Synsit tweak
https://github.com/user-attachments/assets/52d80562-0ce1-43e4-857e-f7be479cec6c
This version uses version 0.2 of VPE-Sitter, which has New code to work around the way older versions of Vim (before 9.1.1782) buffer changes when using the listener_add function.
Several days of running with this change suggest that it is stable, providing solid syntax highlighting.
Requirements
You will need Vim 9.0 or greater and obviously it will have to have been built with Python 3 support, at least version 3.11.
Limitations
No support for selective spell checking.
Vim’s regular expression based syntax highlighting provides a mechanism to mark only some parts of a buffer (e.g. comments) to be spell checked. VPE_Syntax uses text properties to provide highlighting. Text properties do not currently provide support for this. I hope to supply a pull request to get this added to Vim.
If possible, release 0.3 will contain a work around.
No support for embedded languages. This is planned work.
Installation
I have only used this on Linux and Windows.
Linux
As advised for VPE, it is recommended that you use a virtual environment, hosted within your Vim configuration tree. You may find it useful to read the VPE Linux installation instructions for some background. The following assumes that your Vim configuration directory is $HOME/.vim.
If you do not already have a virtual environment then create one:
# Make sure you are in your $HOME directory python -m venv .vim/lib/pythonActivate the virtual environment and install vpe_syntax.
# Activate the virtual environment. source .vim/lib/python/bin/activate # Install VPE. python -m pip install vpe_syntaxIf you did not already have VPE installed then you will need to perform additional one-off installation of support Vim plugin code. Follow the VPE first installations, steps 2 to 4.
Windows
A user install is recommended.
Install using the command.
# Install VPE. python -m pip install --user vpe_syntaxIf you did not already have VPE installed then you will need to perform additional one-off installation of support Vim plugin code. Follow the VPE first installations, steps 2 to 4.
Install Tree-sitter parsers
The above steps should install all the direct dependencies of VPE_Syntax, but you will need to separately install parsers for the languages you wish to highlight. Assuming you want to use both supported languages then before you exit the virtual environment do:
python3 -m pip install tree-sitter-python==0.23.6 tree-sitter-c==0.21.4
The Tree-sitter API seems to be somewhat fast moving, so I recommend using the exact versions given above.
You can then deactivate the virtual environment.
deactivate
Using Vpe_Syntax
One everything is correctly installed, you should find that your Vim has gained a Synsit command. The important form of this is:
Synsit on
Which will enable Tree-sitter based highlighting in the current buffer, provided it contains C or Python code. If everything is working you will likely see some differences in the way your code is coloured, but by an large things will be quite similar.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vpe_syntax-0.2.0.tar.gz.
File metadata
- Download URL: vpe_syntax-0.2.0.tar.gz
- Upload date:
- Size: 43.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73f02ccec09122cd5f31a6c070874f8ec9bd27e60886887f3393ee6d28f9ae66
|
|
| MD5 |
63db26ee32d4bd709498c6d7a3b2d7ff
|
|
| BLAKE2b-256 |
d8cab9aaed87a36a18f240d8ba25db14040458f1b9f8df813f3bcbb7e9f99fe8
|
File details
Details for the file vpe_syntax-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vpe_syntax-0.2.0-py3-none-any.whl
- Upload date:
- Size: 42.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6ac86f7873991e35cb73d277780e8c1029fa45851822eeac7acc6cf389aa502c
|
|
| MD5 |
a8febc80cd71fcba93eaf57fde3a9137
|
|
| BLAKE2b-256 |
d112f14fe6c938a321cdf7d4b1393f1ab7d13a538afb3468cca26cae86e01787
|