首页 > 解决方案 > Highlight SQL queries inside of YAML file in Goland

问题描述

Goland has a beautiful highlighting mechanism for SQL queries in Go code.

It looks like this:

enter image description here

You can use auto complete option to specify columns and table names. But if you'll move all you queries to configuration file (yaml file in my case), Goland stops highlighting your SQL queries.

enter image description here

Is there an option to enable SQL query highlighting for any specified file type?

标签: jetbrains-idegoland

解决方案


Accordingly to this IDEA-51664 ticket you should be able to create a custom Language Injection rule in YAML files .. but I personally do not see how it can be done.


At the same time, you can manually inject any language into a value string inside the YAML file. It will be a temporal injection though (will last for one session or so). For this:

  1. Place caret inside such string
  2. Invoke "Quick Fix / Show Context Actions" menu (Alt + Enter on Windows/Linux in most keymaps)
  3. Choose Inject language or reference action

    enter image description here

  4. Select desired language from a list (use SQL to inject current SQL Dialect for that scope (file/folder) or just Generic SQL if you do not need specific DB checks etc).

    enter image description here

  5. Final result:

    enter image description here


推荐阅读