Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the Nix lexer which I based on the recenly merged Dart lexer. Some of the language details can be found in
https://nix.dev/manual/nix/2.24/language/syntax
and related documents.
Some notes about the implementation:
key = value;
) I used the same lookahead technique as used in the JSON lexer which tries to find=
after the identifier./
somewhere inside the literal. It didn't seem to be a problem for sources I used for testing but searching for/
in every identifier might cause performance issues - if it is a problem, path literal highlighting could be performed only for<paths_in_braces>
.There's one issue I'm aware of - folding of sources like
where the end of the block
}
is on the same line like the start of multiline string''
. This style is used e.g. inhttps://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/docker/default.nix
and I added an example of this at the end of the unit test. What happens is that fold level is unchanged on the
} ''
line because it is decreased and increased at the same time so the result is that folding starts at the initial{
and ends at the final''
which is strange. It would be OK if it were just a combination of the same blocks likebut it's strange when it's block+string. Do any other lexers have to solve this issue and what is the recommended approach here? One way would be to completely disable folding of multiline strings or just accept this behavior if there's no better option.
Fixes #116.