Skip to content

Commit

Permalink
Add Nickel language
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Apr 20, 2022
1 parent 893963d commit a0b348e
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
| make || | | |
| markdown || | | |
| mint | | | | `mint` |
| nickel || || `nls` |
| nix || || `rnix-lsp` |
| ocaml || || `ocamllsp` |
| ocaml-interface || | | `ocamllsp` |
Expand Down
15 changes: 15 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,21 @@ indent = { tab-width = 4, unit = " " }
name = "python"
source = { git = "https://github.com/tree-sitter/tree-sitter-python", rev = "d6210ceab11e8d812d4ab59c07c81458ec6e5184" }

[[language]]
name = "nickel"
scope = "source.nickel"
injection-regex = "nickel"
file-types = ["ncl"]
shebangs = []
roots = []
comment-token = "#"
language-server = { command = "nls" }
indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "nickel"
source = { git = "https://github.com/nickel-lang/tree-sitter-nickel", rev = "85348774ccf7624fac72703b2264d18b6f572be6" }

[[language]]
name = "nix"
scope = "source.nix"
Expand Down
68 changes: 68 additions & 0 deletions runtime/queries/nickel/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
(types) @type
(type_builtin) @type.builtin
"Array" @type.builtin

(enum_tag) @constructor

"null" @constant.builtin
(bool) @constant.builtin.boolean
(str_esc_char) @constant.character.escape
(num_literal) @constant.numeric

(str_chunks) @string

; NOTE: Nickel has no block comments
(comment) @comment.line
(annot_atom doc:
(static_string
; Nickel doesn't use comments for documentation, ideally this would be
; `@documentation` or something similar
(chunk_literal_single) @comment.block.documentation
)
)

(record_operand (atom (ident) @variable))
(let_expr
"let" @keyword
pat: (pattern
(ident) @variable
)
"in" @keyword
)
(fun_expr
"fun" @keyword.function
pats:
(pattern
id: (ident) @variable.parameter
)+
)
(record_field) @variable.other.member

[
"."
] @punctuation.delimiter
[
"{" "}"
"(" ")"
"[|" "|]"
"[" "]"
] @punctuation.bracket
(multstr_start) @punctuation.bracket
(multstr_end) @punctuation.bracket
(interpolation_start) @punctuation.bracket
(interpolation_end) @punctuation.bracket

["forall" "default" "doc"] @keyword
["if" "then" "else" "switch"] @keyword.control.conditional
"import" @keyword.control.import

(infix_expr
op: (_) @operator
)

(applicative
t1: (applicative
(record_operand) @function
)
)
(builtin) @function.builtin
17 changes: 17 additions & 0 deletions runtime/queries/nickel/indents.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
(fun_expr)
(let_expr)
(switch_expr)
(ite_expr)

(uni_record)
(str_chunks_multi)
"["
"[|"
] @indent

[
"}"
"]"
"|]"
] @outdent

0 comments on commit a0b348e

Please sign in to comment.