Closed Ma27 closed 3 years ago
The changes can be tested via https://github.com/Ma27/rnix-lsp/tree/experimental.
Seems to be working for me.
cc @nerdypepper @aaronjanse for a review.
Amazing, thanks! I'll take a look over the weekend.
Thank you @Ma27!! I'll do some review & local testing over the next few days. I'm excited to have support for this syntax
This is not completely in sync with the syntax supported by Nix, for example ./${"a"}.b
gives
error: unexpected TOKEN_PATH at 9..10, wanted any of [TOKEN_IDENT]
error: unexpected end of file, wanted any of [TOKEN_IDENT]
NODE_ROOT 0..10 {
NODE_SELECT 0..10 {
NODE_PATH_WITH_INTERPOL 0..8 {
TOKEN_PATH("./") 0..2
NODE_STRING_INTERPOL 2..8 {
TOKEN_INTERPOL_START("${") 2..4
NODE_STRING 4..7 {
TOKEN_STRING_START("\"") 4..5
TOKEN_STRING_CONTENT("a") 5..6
TOKEN_STRING_END("\"") 6..7
}
TOKEN_INTERPOL_END("}") 7..8
}
}
TOKEN_DOT(".") 8..9
NODE_ERROR 9..10 {
TOKEN_PATH("b") 9..10
}
}
}
whereas this syntax is supported by Nix since 2.4 (https://github.com/NixOS/nix/pull/5066).
Yes, I realized that this is a problem ~a week ago, I started working on a fix, but my time is slightly constrained unfortunately.
Opened a ticket to keep track of it: https://github.com/nix-community/rnix-parser/issues/85 :)
:warning: Warning: not ready to be merged. This is my first deep-dive and I'm a little afraid of regressions, so I'd first like to use this with
rnix-lsp
locally to test it a bit :)Summary & Motivation
Since Nix 2.4 it's possible to perform string interpolations within paths:
Please note that the following expressions are not supported (by both Nix and this patch):
NIX_PATH
imports, i.e.<nixpkgs/${foo}>
foo${bar}/baz
.The newly introduced token
NODE_PATH_WITH_INTERPOL
is only used for these interpolated paths. Literal paths are stillTOKEN_PATH
insideNODE_LITERAL
for backwards compatibility.Backwards-incompatible changes
none
Further context
Closes #44
cc @nerdypepper