on master help sign in
feat(lang): add nushell language support (#2225)

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commit5c2570582bdacf7acebf1bf4cab90699b98ecc67 authorJustin Ma <hustcer@outlook.com> dateFri 22 Apr 2022, 22:37 (5 years ago) parent3c250b7
6 files changed+88
book/src/generated/lang-support.md+1 languages.toml+13 runtime/queries/nu/folds.scm+4 runtime/queries/nu/highlights.scm+55 runtime/queries/nu/injections.scm+2 runtime/queries/nu/locals.scm+13
book/src/generated/lang-support.md+1
@@ -50,6 +50,7 @@
5050| mint | | | | `mint` |
5151| nickel | ✓ | | ✓ | `nls` |
5252| nix | ✓ | | ✓ | `rnix-lsp` |
53+| nu | ✓ | | | |
5354| ocaml | ✓ | | ✓ | `ocamllsp` |
5455| ocaml-interface | ✓ | | | `ocamllsp` |
5556| org | ✓ | | | |
languages.toml+13
@@ -1210,3 +1210,16 @@ indent = { tab-width = 4, unit = " " }
12101210[[grammar]]
12111211name = "gdscript"
12121212source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" }
1213+
1214+[[language]]
1215+name = "nu"
1216+scope = "source.nu"
1217+injection-regex = "nu"
1218+file-types = ["nu"]
1219+roots = []
1220+comment-token = "#"
1221+indent = { tab-width = 2, unit = " " }
1222+
1223+[[grammar]]
1224+name = "nu"
1225+source = { git = "https://github.com/LhKipp/tree-sitter-nu", rev = "db4e990b78824c8abef3618e0f93b7fe1e8f4c0d" }
runtime/queries/nu/folds.scmnew file+4
@@ -0,0 +1,4 @@
1+[
2+ (function_definition)
3+ (block)
4+] @fold
runtime/queries/nu/highlights.scmnew file+55
@@ -0,0 +1,55 @@
1+(string) @string
2+(type) @type
3+(value_path) @variable
4+(comment) @comment
5+
6+(number_literal) @constant.numeric
7+(range from: (number_literal) @constant.numeric)
8+(range to: (number_literal) @constant.numeric)
9+
10+(command cmd_name: (identifier) @function)
11+(function_definition func_name: (identifier) @function)
12+
13+[
14+ (variable_declaration name: (identifier))
15+ (parameter (identifier))
16+ (flag (flag_name))
17+ (flag (flag_shorthand_name))
18+ (record_entry entry_name: (identifier))
19+ (block_args block_param: (identifier))
20+] @variable.other.member
21+; (parameter (identifier) @variable.parameter) ; -- alternative highlighting group?
22+
23+(cmd_invocation) @embedded
24+
25+
26+((identifier) @constant
27+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
28+
29+[
30+ "if"
31+ "else"
32+ "let"
33+ "def"
34+ "export"
35+] @keyword
36+
37+[
38+ ; "/" Not making / an operator may lead to better highlighting?
39+ "$"
40+ "|"
41+ "+"
42+ "-"
43+ "*"
44+ "="
45+ "!="
46+ "&&"
47+ "||"
48+ "=="
49+ ">"
50+] @operator
51+
52+["."
53+ ","
54+ ";"
55+] @punctuation.delimiter
runtime/queries/nu/injections.scmnew file+2
@@ -0,0 +1,2 @@
1+((comment) @injection.content
2+ (#set! injection.language "comment"))
runtime/queries/nu/locals.scmnew file+13
@@ -0,0 +1,13 @@
1+; Scopes
2+(function_definition) @scope
3+
4+; Definitions
5+(variable_declaration
6+ name: (identifier) @definition.var)
7+
8+(function_definition
9+ func_name: (identifier) @definition.function)
10+
11+; References
12+(value_path) @reference
13+(word) @reference