LnL7 / vim-nix

Vim configuration files for Nix http://nixos.org/nix
MIT License
287 stars 26 forks source link

Syntax highlight for unpackPhase/installPhase/... #54

Closed Freed-Wu closed 11 months ago

Freed-Wu commented 12 months ago

How about highlight unpackPhase/installPhase/... as sh syntax? Like markdown/typst highlight code fence:

markdown

Refer https://github.com/vim-pandoc/vim-pandoc-syntax

bew commented 12 months ago

That looks like a restricted version of #28

Ma27 commented 11 months ago

IMHO it's not a good idea to assume bash for unpackPhase etc. Also, this highlighting would be pretty incomplete considering that you can define custom phases, have quite a lot of phases and also pre/post hooks and the syntax highlighting would be completely wrong and confusing if you have - for whatever reason - an installPhase that's not a bash string. To deliver somehow usable results, we'd probably have to scan for stdenv.mkDerivation which would make this even more error-prone (right now we simply pattern-match for some highlighting even in case of syntax errors) and we'd need some more sophisticated parsing then.

tl;dr what @bew says, the correct solution would be something like #28 (although getting this ready is a different story).

Btw just tried #28 out though and it works relatively well, so you just apply the patch to your local vim-nix (that's possible via super.vimUtils.vim-nix.overrideAttrs in an overlay for instance).