mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-13 08:50:11 -04:00
highlights(nix): improve highlights
This commit is contained in:
parent
a851cef248
commit
df67a47a7e
1 changed files with 120 additions and 28 deletions
|
|
@ -1,22 +1,26 @@
|
||||||
; basic keywords
|
; basic keywords
|
||||||
[
|
[
|
||||||
("assert")
|
"assert"
|
||||||
("with")
|
"in"
|
||||||
("let")
|
"inherit"
|
||||||
("in")
|
"let"
|
||||||
("rec")
|
"rec"
|
||||||
("inherit")
|
"with"
|
||||||
] @keyword
|
] @keyword
|
||||||
|
|
||||||
|
; these are technically functions but they act more like keywords (abort and throw are control flow, derivation is a core language construct)
|
||||||
|
((identifier) @keyword
|
||||||
|
(#any-of? @keyword "abort" "derivation" "throw"))
|
||||||
|
|
||||||
; if/then/else
|
; if/then/else
|
||||||
[
|
[
|
||||||
("if")
|
"if"
|
||||||
("then")
|
"then"
|
||||||
("else")
|
"else"
|
||||||
] @conditional
|
] @conditional
|
||||||
|
|
||||||
; field access default (`a.b or c`)
|
; field access default (`a.b or c`)
|
||||||
("or") @keyword.operator
|
"or" @keyword.operator
|
||||||
|
|
||||||
; comments
|
; comments
|
||||||
(comment) @comment
|
(comment) @comment
|
||||||
|
|
@ -48,10 +52,9 @@
|
||||||
] @punctuation.bracket
|
] @punctuation.bracket
|
||||||
|
|
||||||
; `?` in `{ x ? y }:`, used to set defaults for named function arguments
|
; `?` in `{ x ? y }:`, used to set defaults for named function arguments
|
||||||
; I'm not really sure what group this should go in, but it should probably have highlighting, so I'm putting it in @punctuation.special
|
|
||||||
(formal
|
(formal
|
||||||
name: (identifier) @parameter
|
name: (identifier) @parameter
|
||||||
"?"? @punctuation.special)
|
"?"? @operator)
|
||||||
|
|
||||||
; `...` in `{ ... }`, used to ignore unknown named function arguments (see above)
|
; `...` in `{ ... }`, used to ignore unknown named function arguments (see above)
|
||||||
(ellipses) @punctuation.special
|
(ellipses) @punctuation.special
|
||||||
|
|
@ -62,33 +65,122 @@
|
||||||
universal: (identifier) @parameter
|
universal: (identifier) @parameter
|
||||||
":" @punctuation.special)
|
":" @punctuation.special)
|
||||||
|
|
||||||
|
; function calls
|
||||||
|
(apply_expression
|
||||||
|
function: (variable_expression
|
||||||
|
name: (identifier) @function.call))
|
||||||
|
|
||||||
; basic identifiers
|
; basic identifiers
|
||||||
(variable_expression) @variable
|
(variable_expression) @variable
|
||||||
|
|
||||||
; builtin functions
|
; builtin functions
|
||||||
((identifier) @_i (#match? @_i "^(builtins|baseNameOf|dirOf|fetchTarball|map|removeAttrs|toString)$")) @variable.builtin
|
; modified from `nix __dump-builtins | jq keys`
|
||||||
|
((identifier) @function.builtin (#any-of? @function.builtin
|
||||||
|
"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"
|
||||||
|
"floor"
|
||||||
|
"foldl'"
|
||||||
|
"fromJSON"
|
||||||
|
"functionArgs"
|
||||||
|
"genList"
|
||||||
|
"genericClosure"
|
||||||
|
"getAttr"
|
||||||
|
"getEnv"
|
||||||
|
"getFlake"
|
||||||
|
"groupBy"
|
||||||
|
"hasAttr"
|
||||||
|
"hashFile"
|
||||||
|
"hashString"
|
||||||
|
"head"
|
||||||
|
"intersectAttrs"
|
||||||
|
"isAttrs"
|
||||||
|
"isBool"
|
||||||
|
"isFloat"
|
||||||
|
"isFunction"
|
||||||
|
"isInt"
|
||||||
|
"isList"
|
||||||
|
"isNull"
|
||||||
|
"isPath"
|
||||||
|
"isString"
|
||||||
|
"length"
|
||||||
|
"lessThan"
|
||||||
|
"listToAttrs"
|
||||||
|
"map"
|
||||||
|
"mapAttrs"
|
||||||
|
"match"
|
||||||
|
"mul"
|
||||||
|
"parseDrvName"
|
||||||
|
"partition"
|
||||||
|
"path"
|
||||||
|
"pathExists"
|
||||||
|
"placeholder"
|
||||||
|
"readDir"
|
||||||
|
"readFile"
|
||||||
|
"removeAttrs"
|
||||||
|
"replaceStrings"
|
||||||
|
"seq"
|
||||||
|
"sort"
|
||||||
|
"split"
|
||||||
|
"splitVersion"
|
||||||
|
"storePath"
|
||||||
|
"stringLength"
|
||||||
|
"sub"
|
||||||
|
"substring"
|
||||||
|
"tail"
|
||||||
|
"toFile"
|
||||||
|
"toJSON"
|
||||||
|
"toPath"
|
||||||
|
"toString"
|
||||||
|
"toXML"
|
||||||
|
"trace"
|
||||||
|
"traceVerbose"
|
||||||
|
"tryEval"
|
||||||
|
"typeOf"
|
||||||
|
"zipAttrsWith"
|
||||||
|
))
|
||||||
|
|
||||||
; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin)
|
((identifier) @include (#eq? @include "import"))
|
||||||
(select_expression
|
|
||||||
expression: ((variable_expression) @_i (#eq? @_i "builtins"))
|
|
||||||
attrpath: (attrpath attr: (identifier) @variable.builtin)) @variable.builtin
|
|
||||||
|
|
||||||
; import
|
|
||||||
((identifier) @_i (#eq? @_i "import")) @include
|
|
||||||
|
|
||||||
; null
|
|
||||||
((identifier) @_i (#eq? @_i "import")) @constant.builtin
|
|
||||||
|
|
||||||
; these are technically functions but they act more like keywords (abort and throw are control flow, derivation is a core language construct)
|
|
||||||
((identifier) @_i (#match? @_i "^(abort|derivation|throw)$")) @keyword
|
|
||||||
|
|
||||||
; booleans
|
; booleans
|
||||||
((identifier) @_i (#match? @_i "^(true|false)$")) @boolean
|
((identifier) @boolean (#any-of? @boolean "true" "false"))
|
||||||
|
|
||||||
|
; constants
|
||||||
|
((identifier) @constant.builtin (#any-of? @constant.builtin "builtins" "null"))
|
||||||
|
|
||||||
; string interpolation (this was very annoying to get working properly)
|
; string interpolation (this was very annoying to get working properly)
|
||||||
(interpolation "${" @punctuation.special (_) "}" @punctuation.special) @none
|
(interpolation "${" @punctuation.special (_) "}" @punctuation.special) @none
|
||||||
|
|
||||||
; fields (the `.` in `a.b = c;` isn't included)
|
; display entire builtins path as builtin (ex. `builtins.filter` is highlighted as one long builtin)
|
||||||
|
(select_expression
|
||||||
|
expression: ((variable_expression) @_i (#eq? @_i "builtins"))
|
||||||
|
attrpath: (attrpath attr: (identifier) @function.builtin))
|
||||||
|
|
||||||
|
(select_expression attrpath: (attrpath attr: (identifier) @field))
|
||||||
(attrset_expression (binding_set (binding . (attrpath (identifier) @field))))
|
(attrset_expression (binding_set (binding . (attrpath (identifier) @field))))
|
||||||
(rec_attrset_expression (binding_set (binding . (attrpath (identifier) @field))))
|
(rec_attrset_expression (binding_set (binding . (attrpath (identifier) @field))))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue