aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/nu
diff options
context:
space:
mode:
authorJustin Ma2022-04-22 14:37:51 +0000
committerGitHub2022-04-22 14:37:51 +0000
commit5c2570582bdacf7acebf1bf4cab90699b98ecc67 (patch)
tree8bc047910e863f435e33a5b50a6b4095c3de252a /runtime/queries/nu
parent3c250b7528175e67717a3c6d11be7409023d5a16 (diff)
feat(lang): add nushell language support (#2225)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'runtime/queries/nu')
-rw-r--r--runtime/queries/nu/folds.scm4
-rw-r--r--runtime/queries/nu/highlights.scm55
-rw-r--r--runtime/queries/nu/injections.scm2
-rw-r--r--runtime/queries/nu/locals.scm13
4 files changed, 74 insertions, 0 deletions
diff --git a/runtime/queries/nu/folds.scm b/runtime/queries/nu/folds.scm
new file mode 100644
index 00000000..f6b5acb1
--- /dev/null
+++ b/runtime/queries/nu/folds.scm
@@ -0,0 +1,4 @@
+[
+ (function_definition)
+ (block)
+] @fold
diff --git a/runtime/queries/nu/highlights.scm b/runtime/queries/nu/highlights.scm
new file mode 100644
index 00000000..b643a63a
--- /dev/null
+++ b/runtime/queries/nu/highlights.scm
@@ -0,0 +1,55 @@
+(string) @string
+(type) @type
+(value_path) @variable
+(comment) @comment
+
+(number_literal) @constant.numeric
+(range from: (number_literal) @constant.numeric)
+(range to: (number_literal) @constant.numeric)
+
+(command cmd_name: (identifier) @function)
+(function_definition func_name: (identifier) @function)
+
+[
+ (variable_declaration name: (identifier))
+ (parameter (identifier))
+ (flag (flag_name))
+ (flag (flag_shorthand_name))
+ (record_entry entry_name: (identifier))
+ (block_args block_param: (identifier))
+] @variable.other.member
+; (parameter (identifier) @variable.parameter) ; -- alternative highlighting group?
+
+(cmd_invocation) @embedded
+
+
+((identifier) @constant
+ (#match? @constant "^[A-Z][A-Z\\d_]*$"))
+
+[
+ "if"
+ "else"
+ "let"
+ "def"
+ "export"
+] @keyword
+
+[
+ ; "/" Not making / an operator may lead to better highlighting?
+ "$"
+ "|"
+ "+"
+ "-"
+ "*"
+ "="
+ "!="
+ "&&"
+ "||"
+ "=="
+ ">"
+] @operator
+
+["."
+ ","
+ ";"
+] @punctuation.delimiter
diff --git a/runtime/queries/nu/injections.scm b/runtime/queries/nu/injections.scm
new file mode 100644
index 00000000..321c90ad
--- /dev/null
+++ b/runtime/queries/nu/injections.scm
@@ -0,0 +1,2 @@
+((comment) @injection.content
+ (#set! injection.language "comment"))
diff --git a/runtime/queries/nu/locals.scm b/runtime/queries/nu/locals.scm
new file mode 100644
index 00000000..2a341f80
--- /dev/null
+++ b/runtime/queries/nu/locals.scm
@@ -0,0 +1,13 @@
+; Scopes
+(function_definition) @scope
+
+; Definitions
+(variable_declaration
+ name: (identifier) @definition.var)
+
+(function_definition
+ func_name: (identifier) @definition.function)
+
+; References
+(value_path) @reference
+(word) @reference