Skip to content
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

syntax/nix: autogenerate namespaced builtins from nix __dump-language #59

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions builtins.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash jq nix

header="syn keyword nixNamespacedBuiltin contained"

nix __dump-language | jq -r '
def to_vim: keys | map(" \\ " + . + "\n") | .[];
[ (.builtins | to_vim)
, (.constants | del(.["true","false","null","builtins"]) | to_vim)
] | add
' | sed -n -i -e '/^'"$header"'/ {
p; n; r /dev/stdin
:l; n; /^$/!bl; b
}; p' syntax/nix.vim
118 changes: 104 additions & 14 deletions syntax/nix.vim
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,112 @@ syn keyword nixSimpleBuiltin
\ scopedImport throw toString


" Generated automatically: use `./builtins.sh` from the repo's root to update.
" Namespaced and non-namespaced Nix builtins as of version 2.0:
syn keyword nixNamespacedBuiltin contained
\ abort add addErrorContext all any attrNames attrValues baseNameOf
Ma27 marked this conversation as resolved.
Show resolved Hide resolved
\ catAttrs compareVersions concatLists concatStringsSep currentSystem
\ currentTime deepSeq derivation derivationStrict dirOf div elem elemAt
\ fetchGit fetchMercurial fetchTarball fetchurl filter \ filterSource
\ findFile foldl' fromJSON functionArgs genList \ genericClosure getAttr
\ getEnv hasAttr hasContext hashString head import intersectAttrs isAttrs
\ isBool isFloat isFunction isInt isList isNull isString langVersion
\ length lessThan listToAttrs map mapAttrs match mul nixPath nixVersion
\ parseDrvName partition path pathExists placeholder readDir readFile
\ removeAttrs replaceStrings scopedImport seq sort split splitVersion
\ storeDir storePath stringLength sub substring tail throw toFile toJSON
\ toPath toString toXML trace tryEval typeOf unsafeDiscardOutputDependency
\ unsafeDiscardStringContext unsafeGetAttrPos valueSize fromTOML bitAnd
\ bitOr bitXor floor ceil
\ abort
\ add
\ all
\ any
\ attrNames
\ attrValues
\ baseNameOf
\ bitAnd
\ bitOr
\ bitXor
\ break
\ catAttrs
\ ceil
\ compareVersions
\ concatLists
\ concatMap
\ concatStringsSep
\ deepSeq
\ dirOf
\ div
\ elem
\ elemAt
\ fetchClosure
\ fetchGit
\ fetchTarball
\ fetchurl
\ filter
\ filterSource
\ findFile
\ flakeRefToString
\ floor
\ foldl'
\ fromJSON
\ fromTOML
\ functionArgs
\ genList
\ genericClosure
\ getAttr
\ getContext
\ getEnv
\ getFlake
\ groupBy
\ hasAttr
\ hasContext
\ hashFile
\ hashString
\ head
\ import
\ intersectAttrs
\ isAttrs
\ isBool
\ isFloat
\ isFunction
\ isInt
\ isList
\ isNull
\ isPath
\ isString
\ length
\ lessThan
\ listToAttrs
\ map
\ mapAttrs
\ match
\ mul
\ outputOf
\ parseDrvName
\ parseFlakeRef
\ partition
\ path
\ pathExists
\ placeholder
\ readDir
\ readFile
\ readFileType
\ removeAttrs
\ replaceStrings
\ seq
\ sort
\ split
\ splitVersion
\ storePath
\ stringLength
\ sub
\ substring
\ tail
\ throw
\ toFile
\ toJSON
\ toPath
\ toString
\ toXML
\ trace
\ traceVerbose
\ tryEval
\ typeOf
\ zipAttrsWith
\ currentSystem
\ currentTime
\ langVersion
\ nixPath
\ nixVersion
\ storeDir

syn match nixBuiltin "builtins\.[a-zA-Z']\+"he=s+9 contains=nixComment,nixNamespacedBuiltin

Expand Down
Loading