Support fenced code blocks via multiple modes
In https://github.com/LnL7/vim-nix/pull/28, there is support for highlighting code within nix lines, using inline comments before the opening '', like
{
foo = /* sh */ ''
mkdir -p $out/share
'';
}
I would love to have this. The two should be compatible, as @LnL7 mentions in https://github.com/LnL7/vim-nix/pull/28#issuecomment-647683536, so we should coördinate.
I was just thinking about this - and hey, most recent issue!
It would also be cool if appropriate highlighting could be inferred for text blocks following certain functions like pkgs.writeShellScriptBin and pkgs.writePython3Bin, without requiring a comment.
Isn't this a job of tree-sitter? https://github.com/cstrahan/tree-sitter-nix/pull/31
There are mmm-mode, polymode, etc. which let you configure mixed modes, but their behaviors are sometimes a bit awkward. I have worked on TypeScript (with React JSX in it) in Emacs, and tree-sitter is the best option for highlighting mixed modes.
For editing, there is separedit support.
I have experimented with this in https://github.com/NixOS/nix-mode/blob/master/nix-mode-mmm.el, but haven't used it recently.