-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support paths with dynamic interpolation from Nix 2.4+ #52
Conversation
Since Nix 2.4 it's possible to perform string interpolations within paths: nix-repl> let a = "rnix"; in /home/ma27/Projects/${a}-parser /home/ma27/Projects/rnix-parser Please note that the following expressions are not supported (by both Nix and this patch): * `NIX_PATH` imports, i.e. `<nixpkgs/${foo}>` * Interpolations before the first slash, i.e. `foo${bar}/baz`. The newly introduced token `NODE_PATH_WITH_INTERPOL` is only used for these interpolated paths. Literal paths are still `TOKEN_PATH` inside `NODE_LITERAL` for backwards compatibility. Closes #44
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 |
NODE_IDENT 0..1 { | ||
TOKEN_IDENT("a") 0..1 | ||
} | ||
NODE_ERROR 1..7 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if the error were more isolated (rather than consuming the rest of the expression in code like a${b}/c + /tmp
), but I think we can figure that out once we merge some of the very helpful error handling code that @oberblastmeister has been working on
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll need to think of this later today, but actually we should split 0.10 in 0.10 and 0.11. The reason for this is that I'd like to have a rnix-parser which doesn't provide invalid syntax-errors for new language-features that are part of the current stable Nix (2.4) which will be stable Nix in the upcoming 21.11.
That said, yes, I'd love to have @oberblastmeister's changes at some point, definitely, but I think we should cut 0.10 a bit earlier than planned IMHO :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all LGTM. I want to later re-visit error handling in this code, but in the meantime I think that parsing correct Nix syntax is a higher priority.
I'm in favor of merging this PR. I think we should consider releasing 0.10 quickly with just this PR, moving the already-merged breaking-change commits like 56131e0 to 0.11 (then maybe assigning 0.12 to things currently assigned to 0.11).
This is not completely in sync with the syntax supported by Nix, for example
whereas this syntax is supported by Nix since 2.4 (NixOS/nix#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: #85 :) |
Fixed in #86 |
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 forthese interpolated paths. Literal paths are still
TOKEN_PATH
insideNODE_LITERAL
for backwards compatibility.Backwards-incompatible changes
none
Further context
Closes #44
cc @nerdypepper