It seems the pattern for language plugins is to define hooks on character insertion to automatically indent the next line, and those hooks are activated by a filetype hook. That is fine for many languages, but if you have something like html, php, erb, or even kak, where you have multiple languages in the same file, it means the auto-indentation is useless in the embedded contexts (such as a script tag in html).
I suppose it would be possible to write hooks for InsertChar that figure out if you are in an embedded section, and then determine which indent command defined by the plugin for the embedded language to use. Besides being messy, this introduces a tight coupling between the top level and embedded language, since, for example, the html plugin needs to know what indentation functions the javascript plugin uses, and what characters they are triggered on. Or you could duplicate the logic of javascript indentation in the html indenters.
I'm not sure what a good solution for this would be that is in-line with kakoune's philosophy though. Having some visibility into what highlight regions the inserted character is in might reduce some complexity and duplication in figuring out which language to use for indenting. (ex. if we are in a script region, use the javascript indenting). I'm not really sure how to handle inconsistent indent commands/hooks though.
It seems the pattern for language plugins is to define hooks on character insertion to automatically indent the next line, and those hooks are activated by a filetype hook. That is fine for many languages, but if you have something like html, php, erb, or even kak, where you have multiple languages in the same file, it means the auto-indentation is useless in the embedded contexts (such as a script tag in html).
I suppose it would be possible to write hooks for InsertChar that figure out if you are in an embedded section, and then determine which indent command defined by the plugin for the embedded language to use. Besides being messy, this introduces a tight coupling between the top level and embedded language, since, for example, the html plugin needs to know what indentation functions the javascript plugin uses, and what characters they are triggered on. Or you could duplicate the logic of javascript indentation in the html indenters.
I'm not sure what a good solution for this would be that is in-line with kakoune's philosophy though. Having some visibility into what highlight regions the inserted character is in might reduce some complexity and duplication in figuring out which language to use for indenting. (ex. if we are in a script region, use the javascript indenting). I'm not really sure how to handle inconsistent indent commands/hooks though.