Install the tree-sitter CLI tool globally:
npm -g install tree-sitter-cliClone the specific tree-sitter parser repository for your target language:
git clone https://github.com/tree-sitter/tree-sitter-rust.gitReplace tree-sitter-rust with the appropriate parser for your language (e.g., tree-sitter-python, tree-sitter-javascript).
Navigate to the parser directory and build it:
cd tree-sitter-rust
tree-sitter generate
makeCheck that the shared library file was created:
ls -la libtree-sitter-rust.dylib # On macOS
ls -la libtree-sitter-rust.so # On Linux
ls -la libtree-sitter-rust.dll # On WindowsCheck your Neovim runtime paths to determine where to place the parser:
nvim --headless -c 'echo &runtimepath' -c 'q!' 2>&1 | tr ',' '\n'Create the parser directory and copy the library file:
mkdir -p $HOME/.local/share/nvim/site/parser
cp libtree-sitter-rust.dylib $HOME/.local/share/nvim/site/parser/rust.soexport NVIM_APPNAME="nvim-test" # for example
mkdir -p $HOME/.local/share/$NVIM_APPNAME/site/parser
cp libtree-sitter-rust.dylib $HOME/.local/share/$NVIM_APPNAME/site/parser/rust.soNote: The file extension may need to be changed to match your system's expected format:
- On macOS: copy as
rust.soorrust.dylib - On Linux: copy as
rust.so - On Windows: copy as
rust.dll
Restart Neovim and open a file of the target language to verify that tree-sitter syntax highlighting is working. You can also run :checkhealth treesitter if you have the treesitter plugin configured, or use Neovim's built-in treesitter functionality to verify the parser is loaded.