Skip to content

test: verify all keywords of grammar are available in completions#701

Merged
juleswritescode merged 5 commits intomainfrom
test/keyword-creation
Mar 6, 2026
Merged

test: verify all keywords of grammar are available in completions#701
juleswritescode merged 5 commits intomainfrom
test/keyword-creation

Conversation

@juleswritescode
Copy link
Copy Markdown
Collaborator

@juleswritescode juleswritescode commented Mar 1, 2026

Adds two tests that make sure:

  1. new keywords added to grammar.js are included in the keyword-providers
  2. all keywords in keyword-providers are included in grammar.js

I tried generating the tests from the pg_query.proto first, but some tokens such as "btree" and "gin" are no "official postgres keywords" — we do want to suggest them as keywords at the right spots, though.

Regarding keyword generation: I think generating the keywords from either protobuf or treesitter-grammar doesn't really make sense: We have the .starts_statement() and .require_prefix() builder pattern, and I figure there'll be more of those options soon; so we'd need some manual code anyways.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these keywords were unreachable 👍🏻

Copy link
Copy Markdown
Collaborator

@psteinroe psteinroe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the KW list from postgres includes a keyword type to differentiate btw reserved and non-reserved keywords. did u check if the list we want here could be generated from that?

@juleswritescode
Copy link
Copy Markdown
Collaborator Author

juleswritescode commented Mar 1, 2026

the KW list from postgres includes a keyword type to differentiate btw reserved and non-reserved keywords. did u check if the list we want here could be generated from that?

Yeah I did check it, but the issue is that we have some completable "keywords" that aren't even tokens in the Postgres protobuf.

For example, for create index my_cool_idx on auth.users using |, we'd want to suggest btree, hash, gist, spgist, gin, or brin. These aren't even listed in the protobuf file.

So our "keyword completion" is actually more a "valid token at this position" completion.

@juleswritescode juleswritescode enabled auto-merge (squash) March 6, 2026 08:55
@juleswritescode juleswritescode merged commit 24d927b into main Mar 6, 2026
9 checks passed
@juleswritescode juleswritescode deleted the test/keyword-creation branch March 6, 2026 09:11
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

Successfully merging this pull request may close these issues.

2 participants