LnL7 / vim-nix

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

Rewrite of the syntax file #1

Closed aszlig closed 8 years ago

aszlig commented 8 years ago

The goal here is to get syntax highlighting to be more correct, adhering more to the AST of the language itself rather than just blindly matching simple patterns or keywords.

However, most toplevel syntactic elements such as function calls (more or less whitespace-separated Nix expressions) currently are matched in a dumb "catch everything and hope it's more or less correct" way rather than following the upstream parser of Nix.

Right now the implementation works "well enough" for all of the Nix expression files I've tested, though I have to admit that my tests were by no means exhaustive but I did test fairly complex Nix expression files.

In the long run it would be desirable to have a complete set of syntax rules here, so we can also detect errors from just the syntax highlighting rules.

The rules for paths and identifiers are now the same as in libexpr/lexer.l from Nix itself, so for example, highlighting paths should be more strict and close to what the evaluator expects.

@LnL7: You might also want to take a look at https://github.com/MarcWeber/vim-addon-nix, which has a few more features than just syntax highlighting (for example checking code with nix-instantiate). So maybe you want to join forces.

LnL7 commented 8 years ago

Sure! I put the current version together in a few hours, since I was not happy with the plugin from the nix repo. I have not touched it since, but it definately could use some improvement.