Language Injection
Closed this issue · 6 comments
Hi! I like your settings file.
Unfortunately, I often write kv-code inside python.
from kivy.lang import Builder
Builder.load_string("""
BoxLayout:
Widget:
""")
I found feature in PyCharm to make Language injections. (Settings > Editor > Language Injections) but I could not figure out how to use it.
Maybe you can add this setting to your settings file?
I wrote regex for this
Begin:
(Builder\.load_string\(|kv = )(\s*['"]{3}|[\s ^\n\r]*['"])
End:
(['"]{3}|['"])(\s*\)|)
Matches:
Builder.load_string("""
BoxLayout:
Widget:
""")
Builder.load_string(
"""
BoxLayout:
Widget:
"""
)
kv = """
BoxLayout:
Widget:
"""
@noembryo I didn't figure out how to use Language Injection Settings. That regex is just to help you
Well, almost totally bad news.. :o(
You can't use Language Injection with a language that is not supported from the IDE (like kivy).
One little thing that I did though, was to use YAML for the injection.
For this to work, we must put keywords for the start and end of the .kv code.
I use # kv_start
and # kv_end
Then, you have to create an injection for YAML with this
+ pyStringLiteralMatches("# kv_start(.+?)# kv_end")
... and you have some kind of injection that is not much, but better then nothing...
Closing this for now, and waiting for the official JetBrains support...