Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for a neovim-style extends query hierarchy. #839

Open
ctdunc opened this issue Jan 17, 2025 · 0 comments
Open

Add support for a neovim-style extends query hierarchy. #839

ctdunc opened this issue Jan 17, 2025 · 0 comments

Comments

@ctdunc
Copy link

ctdunc commented Jan 17, 2025

Is your feature request related to a problem? Please describe.
I want to allow users to pass settings like "do/don't capitalize keywords" which would currently require me to maintain multiple query files where the content is largely the same.

Describe the solution you'd like
I would like to have some order in which multiple query files are loaded from different locations. e.g. the default ships at /usr/share/topiary/queries/lang.scm, but users can override it at .config/topiary/queries/lang.scm.

neovim added an ;extends modeline to their tree-sitter queries, which when present indicates that neovim should just append the text of the file to any previously loaded queries. See their very simple implementation

This works fine. In my SQL example, I tried out the query file (all the whitespace stuff omitted)

([
  (keyword_select) 
  (keyword_from)
  (keyword_where)
]) @upper_case
(keyword_select) @lower_case

which produces the following output:

select id
  ,column_a
  ,column_b
FROM foo
WHERE id = 0
;

from the input

sElEcT id, column_a, column_b FRoM foo WHeRE id = 0;

Describe alternatives you've considered
Shipping a grammar file for every possible permutation of settings a user could want for SQL. This is 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant