syntax/nix: autogenerate namespaced builtins from nix __dump-language
#59
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.
We had quite a bunch of changes in the past that added builtins to get them highlighted properly[1].
Nowadays it's possible to get this from Nix itself by running
nix __dump-language
. This was done on a recent Nix and includes all experimental features by default[2] which seems fine to me since this is not an LSP, but only an approximation.This patch adds a few new builtins, e.g.
break
andflakeRefToString
and a script to regenerate the list.This doesn't include non-scoped builtins (e.g.
map
,baseNameOf
etc.), but those are added far less frequent, so this seems OK to me.Also, there are a few hidden builtins, most notably
unsafe*
andscopedImport
. I think this was done on purpose by upstream and I'm wondering if we should adhere to that approach. If we still want to keep those, I think we should add those to a custom highlighting group that's maintained manually.[1] #44, #42, #36, #32, 711aaf7
[2] https://github.com/NixOS/nix/blob/2.20.1/src/nix/main.cc#L372
cc @LnL7 @aszlig for opinions