-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nix: major cleanup #4140
nix: major cleanup #4140
Conversation
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +1.86 KB View Changes
|
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +1.82 KB View Changes
|
src/languages/nix.js
Outdated
match: /nix-repl> / | ||
}, | ||
{ | ||
className: 'meta', | ||
match: /:[a-z]+/, |
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.
Can we pin to the beginning of line here perhaps with ^
... not sure, just a suggestion.
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 have pinned nix-repl>
above with a ^
. :[a-z]+
is meant to highlight commands used in the REPL after the prompt. There isn't anything else that can come after a colon in the nix language for now, so I'm not sure how much better we could make this one.
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +1.8 KB View Changes
|
Build Size ReportChanges to minified artifacts in 2 files changedTotal change +1.97 KB View Changes
|
I have rewritten the test to test more language features, catching a few bugs in the process. Also added support for basic function parameters. There are some more advanced function parameters as well (you can find an example at the top of the test), but I've not been able to properly parse those without breaking parser backtracking. |
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +1.99 KB View Changes
|
Build Size ReportChanges to minified artifacts in 2 files changedTotal change +2.03 KB View Changes
|
Build Size ReportChanges to minified artifacts in 2 files changedTotal change +2.03 KB View Changes
|
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +2.04 KB View Changes
|
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +2.27 KB View Changes
|
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +2.27 KB View Changes
|
@joshgoebel I have gotten rid of all the lookbehinds by using |
src/languages/nix.js
Outdated
|
||
const URL = { | ||
scope: 'link', | ||
match: /https?:\/\/[A-Za-z0-9\-._~:/?#[\]@!$&'()*+,=]+/, |
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.
Does nix support ftp, ssh, or other protocols?
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.
Nix actually supports the entirety of rfc2396 (see last paragraph of https://nix.dev/manual/nix/2.24/language/syntax#string-literal), but I wasn't able to make direct use of the regex provided in the rfc because it kept picking up all sorts of false positives. The URLs are just shorthands for a string with the same content.
The feature is quite discouraged these days, and with no instances left that I'm aware of in nixpkgs (the largest and most important repository for the ecosystem). So I used a slightly suboptimal regex, hoping to catch some basic instances.
I could add a few more common protocols, but I'm not entirely sure where to stop.
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.
If it's deprecated/discouraged perhaps lets drop it altogether so people don't complain it's not working in their own special use cases... What are they doing now instead, quoted strings?
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 have removed the commits related to it. It will pick instances up like a literal path, but maybe it's better to actively not support it (at least for time being, until someone comes up with a better regex). Quoted strings is the recommended replacement, yes.
Nix 2.24.9
Type :? for help.
nix-repl> https://nixos.org == "https://nixos.org"
true
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.
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +2.27 KB View Changes
|
Build Size ReportChanges to minified artifacts in 3 files changedTotal change +2.18 KB View Changes
|
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +2.18 KB View Changes
|
- Add a bunch of new keywords - List all `builtins` explicitly - Sort alphabetically, to make it easier to spot missing builtins - Remove `add`, not a real builtin - Move `or` to `keywords`, this is not a `literal`
- The different string variants have different modes of escapes. Split `STRING.contains` into their different variants to reflect this. - Add escape logic for `'''` - Add escape logic for backslash escaped characters.
Also ensure comments are handled before any other expressions
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +2.18 KB View Changes
|
Build Size ReportChanges to minified artifacts in 5 files changedTotal change +2.17 KB View Changes
|
Changes
This PR contains an overall cleanup of the nix language. It fixes some bugs with string handling, adds a bunch of new keywords that are now part of the language, and adds a bunch of extra support for different language constructs.
add
builtinor
as builtin instead of literal'''
string escapes"
and''
stringsChecklist
CHANGES.md