Skip to content

Conversation

@rolandwalker
Copy link
Contributor

@rolandwalker rolandwalker commented Jan 19, 2026

Description

Since the pygments library is already required, why not use its list of reserved words for completions?

This fixes #767 and should keep us up-to-date. It's really great to have the JSON_* functions.

Obsoletes #925, and addresses the two points in #925 (comment) .

Compared to the previous code, this PR

  • removes LEN and TOP, which are not MySQL reserved words
  • preserves extra completion candidates containing space, such as ORDER BY

Downsides and bugs:

  • pygments.lexers._mysql_builtins does contain a leading underscore, so we should be aware that the library reserves the right to break this usage. The library version has been more tightly defined to remediate issues here.
  • Similarly, certain tests might become more brittle with regard to library updates.
  • Certain reserved words are duplicated with special commands, so if the first word of a command-line is any of the following, duplicated completions will show, as both upper- and lower-case: exit, help, source, status, system, use. This is fixable, but should we prefer the upper- or lower-case flavor?
  • There are many more completion candidates now, which may inspire us to do further work soon on prioritizing which completions are seen at the top.

Checklist

  • I've added this contribution to the changelog.md.
  • I've added my name to the AUTHORS file (or it's already there).
  • I ran uv run ruff check && uv run ruff format && uv run mypy --install-types . to lint and format the code.

@scottnemes
Copy link
Contributor

scottnemes commented Jan 20, 2026

This is fixable, but should we prefer the upper- or lower-case flavor

I always prefer lowercase, but as long as it's consistent; i.e. all options, regardless of source, are uppercase or lowercase ideally.

@scottnemes scottnemes self-requested a review January 20, 2026 02:30
scottnemes
scottnemes previously approved these changes Jan 20, 2026
for x in favorite_keywords
+ list(MYSQL_DATATYPES)
+ list(MYSQL_KEYWORDS)
+ ['ALTER TABLE', 'CHANGE MASTER TO', 'CHARACTER SET', 'FOREIGN KEY']
Copy link
Contributor

Choose a reason for hiding this comment

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

While looking at your follow-up PR, I noticed these get duped, I.e.:

image image

Is that desired?

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind I realized it makes sense in the context of you technically don't know if they want just the keyword master, or the command change master to in this example. Was overthinking it since there is no valid "change master" command, but that is another layer of context.

@scottnemes scottnemes self-requested a review January 20, 2026 02:36
@scottnemes scottnemes dismissed their stale review January 20, 2026 02:36

Added comment

Since the pygments library is already required, why not use its list of
reserved words for completions?

This fixes #767 and should keep us up-to-date. It's really great to have
the JSON_* functions.

Obsoletes #925.

Compared to the previous code, this PR

 * removes LEN and TOP, which are not MySQL reserved words
 * preserves extra completion candidates containing space, such as
   "ORDER BY"

Downsides and bugs:

* pygments.lexers._mysql_builtins does contain a leading underscore, so
  we should be aware that the library reserves the right to break this
  usage. The library version has been more tightly defined to remediate
  issues here.
* Similarly, certain tests might become more brittle with regard to
  library updates.
* Certain reserved words are duplicated with special commands, so if
  the first word of a command-line is any of the following, duplicated
  completions will show, as both upper- and lower-case: exit, help,
  source, status, system, use. This is fixable, but should we prefer
  the upper- or lower-case flavor?
* There are _many_ more completion candidates now, which may inspire us
  to do further work soon on prioritizing which completions are seen at
  the top.
@rolandwalker rolandwalker force-pushed the RW/complete-keywords-functions-2 branch from 7fee5fd to 7103137 Compare January 20, 2026 10:19
@rolandwalker
Copy link
Contributor Author

This is fixable, but should we prefer the upper- or lower-case flavor

I always prefer lowercase, but as long as it's consistent; i.e. all options, regardless of source, are uppercase or lowercase ideally.

I'll make lowercase duplicates preferred in a followup PR.

@rolandwalker rolandwalker merged commit 5b42a4e into main Jan 20, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/complete-keywords-functions-2 branch January 20, 2026 10:23
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.

3 participants