Skip to content

Commit 375ca1a

Browse files
author
fidgetingbits
committed
Add argument for lambdas
1 parent b8b5af5 commit 375ca1a

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change arg blue dot
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: blue, character: .}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: argumentOrParameter}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |-
16+
{ lib, buildPackages, fetchurl, stdenv, ... }:
17+
18+
stdenv.mkDerivation rec {
19+
name = "example-nix-package";
20+
version = "1.0";
21+
}
22+
selections:
23+
- anchor: {line: 0, character: 17}
24+
active: {line: 0, character: 17}
25+
marks:
26+
blue..:
27+
start: {line: 0, character: 40}
28+
end: {line: 0, character: 43}
29+
finalState:
30+
documentContents: |-
31+
{ lib, buildPackages, fetchurl, stdenv, }:
32+
33+
stdenv.mkDerivation rec {
34+
name = "example-nix-package";
35+
version = "1.0";
36+
}
37+
selections:
38+
- anchor: {line: 0, character: 40}
39+
active: {line: 0, character: 40}

queries/nix.scm

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
[
44
(binding)
55
] @statement
6+
;; This matches assert statements as stand-alone statements. This
7+
;; is because it's common to have a series of assert statements in a file, which
8+
;; would otherwise all match as a single statement. See the playground/nix/asserts.nix
9+
;; file for an example.
610
(assert_expression
711
"assert" @statement.start
8-
condition: (_) @statement.condition
12+
condition: (_)
913
";" @statement.end
1014
body: (_)
1115
)
1216
(binding_set) @map.iteration @list.iteration @ifStatement.iteration
13-
(source_code) @statement.iteration @map.iteration
17+
(source_code) @statement.iteration @map.iteration @comment.iteration
1418

1519
;;!! let
1620
;;!! a = 1;
@@ -60,6 +64,10 @@
6064
(rec_attrset_expression)
6165
] @map @statement.iteration @value.iteration @name.iteration
6266

67+
;;!! foo = { x = 1; y = 2; };
68+
;;! ^
69+
(attrpath) @collectionKey
70+
6371
;; Strings
6472

6573
;;!! # foo
@@ -91,8 +99,9 @@
9199
;;! ^^^^^^^^ Func1 due to currying
92100
;;! ^^^^^^^^^^^ Func2 due to currying
93101
(function_expression
102+
universal: (identifier) @argumentOrParameter
94103
body: (_)
95-
) @anonymousFunction
104+
) @anonymousFunction @argumentOrParameter.iteration
96105

97106
;; We define the named function as the full assignment of the lambda
98107
;; This means funk name becomes the variable holding the lambda
@@ -110,6 +119,9 @@
110119
(apply_expression) @functionCall
111120
(formals) @argumentOrParameter.iteration
112121
(formal) @argumentOrParameter
122+
(formals
123+
(ellipses) @argumentOrParameter
124+
)
113125

114126
;; value
115127

0 commit comments

Comments
 (0)