intellij-idealive-templates

how to create Intellij live templates in a custom language "context"?


I am building a custom language plugin for a custom language. I would like to add some live templates for this language, but the new language is not showing up on the list of available contexts in the "Change Context Type For Selected Templates" menu.

The plugin already has a plugin.xml with your usual language-related extensions: <annotator>, <fileType>, <lang.parserDefinition>, <lang.syntaxHighlighterFactory>, etc. Am I missing a relevant extension?

Bookkeeping: This question was already asked 4 years ago. But the given answer doesn't resolve my problem and I don't have enough reputation to comment or ask for clarification.


Solution

  • It looks like the plugin needs to implement a com.intellij.codeInsight.template.TemplateContextType, and then register the implementation as a <liveTemplateContext>.

    This documentation provides useful details: https://plugins.jetbrains.com/docs/intellij/template-support.html#implement-templatecontexttype