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

feat(lang): add nushell language support #2225

Merged
merged 6 commits into from
Apr 22, 2022
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
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
| mint | | | | `mint` |
| nickel | ✓ | | ✓ | `nls` |
| nix | ✓ | | ✓ | `rnix-lsp` |
| nu | ✓ | | | |
| ocaml | ✓ | | ✓ | `ocamllsp` |
| ocaml-interface | ✓ | | | `ocamllsp` |
| org | ✓ | | | |
Expand Down
13 changes: 13 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1210,3 +1210,16 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "gdscript"
source = { git = "https://github.com/PrestonKnopp/tree-sitter-gdscript", rev = "2a6abdaa47fcb91397e09a97c7433fd995ea46c6" }

[[language]]
name = "nu"
scope = "source.nu"
injection-regex = "nu"
file-types = ["nu"]
roots = []
comment-token = "#"
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "nu"
source = { git = "https://github.com/LhKipp/tree-sitter-nu", rev = "db4e990b78824c8abef3618e0f93b7fe1e8f4c0d" }
4 changes: 4 additions & 0 deletions runtime/queries/nu/folds.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[
(function_definition)
(block)
] @fold
55 changes: 55 additions & 0 deletions runtime/queries/nu/highlights.scm
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions runtime/queries/nu/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))
13 changes: 13 additions & 0 deletions runtime/queries/nu/locals.scm
Original file line number Diff line number Diff line change
@@ -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