Syntax highlighting, syntax checking and prompting
Highlighting
The themes should be automatically generated from grammar for the target platforms Visual Studio Code and Jupyter.
Threads with no answers / solutions:
- https://stackoverflow.com/questions/77394923/syntax-highlighting-in-a-jupyter-kernel-for-a-custom-language
- https://stackoverflow.com/questions/59888325/how-to-add-custom-syntax-highlighting-in-ipython-for-jupyter-lab
- https://stackoverflow.com/questions/41650535/custom-syntax-highlighting-in-jupyter-notebook
Things we can try out:
- According to this one has to set the
language
attribute inVMKernel
. - Try to use
ipython.display.Code
after defining a textS/textM pygments lexer using this guide. - See how this has been implemented in the Octave kernel.
- Ideally, the code development should be in the textx-gen-coloring package in order to use common infrastructure (only textmate/vscode support, used in textx-gen-vscode, here we need pygments support). The supporting code is generic and not directly related to this package.
- Finally, we should complete the
language_info
inVMKernel
which is propagated to the notebook file. An example can be found here. - Generate textmate color scheme using the textx-gen-coloring package and convert it to a pygments style. See also this.
Syntax check
An instance of the textx-generated parser can be used to check the input instantly. If the input has a syntax error it will be displayed and the interpretation may be optionally suppressed. As a blue print we can have a look at the check
command of the textx CLI:
$ textx check builtins.vm --grammar ../src/virtmat/language/grammar/virtmat.tx
builtins.vm: OK.
Prompting
This is the behavior to show in a dropdown menu what choices are currently correct.
Finally, all three features can be combined in one single function, at least for performance reasons, because many functions might be common and thus called redundantly.
Edited by Ivan Kondov