cap-js-community / tree-sitter-cds

CAP CDS grammar for tree-sitter.
Apache License 2.0
16 stars 2 forks source link

How to update already existing queries? #25

Closed thecoldstone closed 6 months ago

thecoldstone commented 6 months ago

I have run into the issue that queries for highlight and locals were modified in previous commit.

:checkhealth was showing some issues related to wrong structure within files highlights and locals.

Screenshot 2024-02-07 at 11 47 10

Question: Are queries updated along with other components of nvim-treesitter-cds by running :TSUpdate cds?

Solution: Manually change queries according the latest updates in .local/share/nvim/lazy/nvim-treesitter/queries/cds

bugwelle commented 6 months ago

Are queries updated along with other components of nvim-treesitter-cds by running :TSUpdate cds?

No, they are not. Sadly, queries aren't updated. I can't find the reference I've read a while ago, but I think this is a known limitation.

For now, it should be possible to install the updated queries by running the setup script ./nvim/setup-nvim-treesitter.sh again. See

I intend to make tree-sitter-cds stable in the next few weeks (i.e. v 1.0). You can track https://github.com/cap-js-community/tree-sitter-cds/issues/17 for progress.

nvim-tree-sitter documentation is available at https://neovim.io/doc/user/treesitter.html#treesitter-query

I will add update instructions to our documentation.

Regards, Andre

bugwelle commented 6 months ago

Found their statement: https://github.com/nvim-treesitter/nvim-treesitter/discussions/5608#discussioncomment-7450342

thecoldstone commented 6 months ago

Are queries updated along with other components of nvim-treesitter-cds by running :TSUpdate cds?

No, they are not. Sadly, queries aren't updated. I can't find the reference I've read a while ago, but I think this is a known limitation.

For now, it should be possible to install the updated queries by running the setup script ./nvim/setup-nvim-treesitter.sh again. See

I intend to make tree-sitter-cds stable in the next few weeks (i.e. v 1.0). You can track #17 for progress.

nvim-tree-sitter documentation is available at https://neovim.io/doc/user/treesitter.html#treesitter-query

I will add update instructions to our documentation.

Regards, Andre

However, does this script copy queries to ./config/nvim/ instead of .local/share/nvim/lazy/nvim-treesitter/queries/cds, does not it? Is it correct to have them in nvim configurations?

bugwelle commented 6 months ago

The script uses nvim --headless -c 'echo stdpath("config")' -c 'q' to get NeoVim's config/runtime directory. Queries must be written there, see https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries

Queries are what nvim-treesitter uses to extract information from the syntax tree; they are located in the queries/{language}/* runtime directories (see :h rtp),

I didn't look to much into lazy (I didn't use it at first). Do they have custom queries directories that work as well? Would be great to know! You can set the environment variable NVIM_CONFIG_DIR="$HOME/.local/share/nvim/lazy/nvim-treesitter" if you want the script to copy the files there. 😄

bugwelle commented 6 months ago

A bit of documentation was added via #26. Open for further ideas and remarks (especially in regard to lazy). 😄

bugwelle commented 6 months ago

I'm closing this issue. With #27 I've added another sentence to our documentation. If there's anything else, please let me know.