Add syntax highlighting for the Kv language to Spyder in the Python IDE

Overview

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.

environment

Download lexer file

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 and save files

Rename highlight.py to kv.py and save it under the \ site-packages \ pygments \ lexers folder.

Edit lexer file

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):
...

Rebuilding lexer mapping

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.

reference

Recommended Posts

Add syntax highlighting for the Kv language to Spyder in the Python IDE
Add D (any other language) to SublimeLinter for highlighting
Use Spyder in Python IDE
In the python command python points to python3.8
Convert files written in python etc. to pdf with syntax highlighting
[Introduction to Python] How to use the in operator in a for statement?
Dockerfile with the necessary libraries for natural language processing in python
In Jupyter, add IPerl to the kernel.
MongoDB for the first time in Python
Switch the module to be loaded for each execution environment in Python
Add words to MeCab's user dictionary on Ubuntu for use in Python
How to use the C library in Python
CERTIFICATE_VERIFY_FAILED in Python 3.6, the official installer for macOS
The fastest way for beginners to master Python
Just add the python array to the json data
Add quotation marks ">" for replying emails in Python3
To dynamically replace the next method in python
Draw graphs in Julia ... Leave the graphs to Python
Tips for hitting the ATND API in Python
The trick to write flatten concisely in python
Try to calculate RPN in Python (for beginners)
To add a module to python put in Julialang
How to get the files in the [Python] folder
I searched for the skills needed to become a web engineer in Python
Use the LibreOffice app in Python (3) Add library
I want to display the progress in Python!
What to do if you get `No kernel for language python found` in Hydrogen
I just want to find the 95% confidence interval for the difference in population ratios in Python
[For beginners] Web scraping with Python "Access the URL in the page to get the contents"
Things to keep in mind when building automation tools for the manufacturing floor in Python
Output the specified table of Oracle database in Python to Excel for each file
Tool to make mask image for ETC in Python
How to retrieve the nth largest value in Python
I tried to graph the packages installed in Python
[For beginners] How to use say command in python!
How to get the variable name itself in python
Try to make a Python module in C language
How to get the number of digits in Python
How to know the current directory in Python in Blender
Syntax that Perl users tend to forget in Python
How to run python in virtual space (for MacOS)
Convert the image in .zip to PDF with Python
How to use Python Kivy ① ~ Basics of Kv Language ~
How to add page numbers to PDF files (in Python)
I want to write in Python! (3) Utilize the mock
How to use the model learned in Lobe in Python
[Python] How to output the list values in order
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
I want to use the R dataset in python
Python OpenCV tried to display the image in text.
Introduction to Python language
How to find the cumulative sum / sum for each group using DataFrame in Spark [Python version]
[python] How to check if the Key exists in the dictionary
Test code to check for broken links in the page
Output "Draw ferns programmatically" to the drawing process in Python
How to debug the Python standard library in Visual Studio
Check the operation of Python for .NET in each environment
[python] How to use the library Matplotlib for drawing graphs
How to use the __call__ method in a Python class
Change the standard output destination to a file in Python
A note for embedding the scripting language in a bash script