nix-mode icon indicating copy to clipboard operation
nix-mode copied to clipboard

Support fenced code blocks via multiple modes

Open sellout opened this issue 3 years ago • 3 comments

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.

sellout avatar Dec 05 '22 17:12 sellout

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.

gekoke avatar Dec 16 '22 00:12 gekoke

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.

akirak avatar Dec 16 '22 04:12 akirak

I have experimented with this in https://github.com/NixOS/nix-mode/blob/master/nix-mode-mmm.el, but haven't used it recently.

matthewbauer avatar Dec 16 '22 16:12 matthewbauer