Skip to content

Latest commit

 

History

History
78 lines (57 loc) · 3.33 KB

neovim-support.md

File metadata and controls

78 lines (57 loc) · 3.33 KB

Neovim Support

We support Neovim using nvim-treesitter.

Setup

To use tree-sitter-cds with Neovim, please install nvim-treesitter and ensure your Neovim version is a recent one (>=0.9.1).
Afterward, configure tree-sitter-cds according to the nvim-treesitter guide and add tree-sitter-cds's queries to Neovim for syntax highlighting.

  1. Install Neovim Ensure that you have Neovim v0.9.1 or later. If not, you may need to build it yourself, see Build Neovim.
  2. Install nvim-tree-sitter
  3. Install custom parsers
  4. Add queries

We have a convenience script to copy all queries (*.scm files) to Neovim's queries directory: ./nvim/setup-nvim-treesitter.sh. If you update tree-sitter-cds, you will also have to update the queries again using this script.

Setup Guide with lazy.nvim

In case you are not familiar with Neovim, here is a basic setup guide for Neovim with the lazy.nvim plugin manager.

We use this Dockerfile to test tree-sitter-cds' setup.

First, Install Neovim. Ensure that you have Neovim v0.9.1 or later. If not, you may need to build it yourself, see Build Neovim.

After that, install lazy.nvim by following their installation guide. If you don't know where Neovim's config directory is, run nvim --headless -c ':echo stdpath("config")' -c ':qa'.

Finally, install nvim-treesitter. They have instructions for lazy.nvim. Don't forget to install a custom parser for CDS and add queries.

We have a convenience script to copy all queries (*.scm files) to Neovim's queries directory: ./nvim/setup-nvim-treesitter.sh. This script also adds a cds.vim files for ftdetect.

If you want a copy&paste solution, use:

# Assuming you're inside the tree-sitter-cds folder.
./nvim/setup-nvim-treesitter.sh
NVIM_CONFIG_DIR="$(nvim --headless -c ':echo stdpath("config")' -c ':qa' 2>&1)"
cp nvim/init.lua "${NVIM_CONFIG_DIR:?}/"

nvim --headless -c "Lazy" -c "qa"
nvim --headless -c ':TSInstallSync cds' -c ':qa'

Also run :checkhealth lazy and :checkhealth nvim-treesitter to ensure that everything is installed and configured correctly.

Update

When you update tree-sitter-cds via :TSUpdate cds, you will also have to install/update the queries again. See setup above. nvim-treesitter does not copy queries from this repository, hence why it needs to be done manually.

Run :checkhealth to ensure that everything works as intended.

Note that the grammar (and queries) may change drastically until v1 is reached.