Spyder, a Python IDE, doesn't seem to support syntax highlighting for the Kv language at this time. This is a memo when a new lexer (highlight rule) is added to Pygments used by Spyder as a syntax highlighter.
A lexer file is a Python script file that shows the highlighting rules for Pygments. Get the source code on GitHub from the link below.
kivy/highlight.py at master · kivy/kivy https://github.com/kivy/kivy/blob/master/kivy/extras/highlight.py
Rename highlight.py
to kv.py
and save it under the \ site-packages \ pygments \ lexers
folder.
Edit the kv.py
file because it cannot be used as it is downloaded. Add one line of the following sentence and save it by overwriting.
kv.py
__all__ = ['KivyLexer']
An example of the kv.py
file after addition is as follows.
kv.py
...
import sys
__all__ = ['KivyLexer']
class KivyLexer(RegexLexer):
...
Rebuild the lexer mapping to make Pygments
recognize kv.py
.
cmd.exe
> cd C:\Program Files\Anaconda3\Lib\site-packages\pygments\lexers
> python _mapping.py
...
pygments.lexers.javascript
pygments.lexers.julia
pygments.lexers.jvm
pygments.lexers.kv
pygments.lexers.lisp
pygments.lexers.make
pygments.lexers.markup
...
=== 400 lexers processed.
that's all.
When you start Spyder, the files with the extension .kv
will be syntax highlighted.
Recommended Posts