dbcli / mycli

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.
http://mycli.net
Other
11.39k stars 657 forks source link

Please add syntax highlighting for temporal support keywords #817

Open lonetwin opened 4 years ago

lonetwin commented 4 years ago

MariaDB has support for temporal tables which includes some new keywords from the SQL:2011 standard. It would be great if mycli could syntax highlight as well as complete these keywords.

I wanted to submit a patchset that introduced these new keywords to mycli but was not sure where exactly this ought to be added. Should I add them to both mycli/sqlcompleter.py::SQLCompleter and mycli/lexer.py ?

gfrlv commented 4 years ago

Hi, it depends on how thorough you want the support for these keywords to be. Adding keywords to the list in SQLCompleter suffices for them to be shown in the completion menu. Keywords in lexer.py extend the pygments lexer that is used for syntax highlighting. I think it's better to add them in a PR directly to pygments rather than maintain a longer list of standard keywords in MyCliLexer.

If you want more intelligent completion than just a long list of keywords, you'll have to hack packages/completion_engine.py

gfrlv commented 4 years ago

By the way, the support of newer keywords in mycli is generally somewhat patchy (e.g. here is an old unmerged PR that addressed the issue). Of course, we could just add every possible keyword to one big list, but then it would be confusing for users of older mysql versions. Probably a nicer solution would be to have specific subclasses of SQLCompleter for different databases, and to switch between them based on SELECT VERSION() when connecting.

That said, in the meantime PRs adding specific keywords are still welcome.