Add syntax highlighting for TOML

This commit is contained in:
Max Brunsfeld 2022-04-21 16:39:49 -07:00
parent 0c587ae73c
commit 3a878c8d6c
8 changed files with 76 additions and 0 deletions

10
Cargo.lock generated
View File

@ -5228,6 +5228,15 @@ dependencies = [
"tree-sitter",
]
[[package]]
name = "tree-sitter-toml"
version = "0.5.1"
source = "git+https://github.com/tree-sitter/tree-sitter-toml?rev=342d9be207c2dba869b9967124c679b5e6fd0ebe#342d9be207c2dba869b9967124c679b5e6fd0ebe"
dependencies = [
"cc",
"tree-sitter",
]
[[package]]
name = "tree-sitter-typescript"
version = "0.20.1"
@ -5856,6 +5865,7 @@ dependencies = [
"tree-sitter-json 0.20.0",
"tree-sitter-markdown",
"tree-sitter-rust",
"tree-sitter-toml",
"tree-sitter-typescript",
"unindent",
"url",

View File

@ -89,6 +89,7 @@ tree-sitter-c = "0.20.1"
tree-sitter-json = { git = "https://github.com/tree-sitter/tree-sitter-json", rev = "137e1ce6a02698fc246cdb9c6b886ed1de9a1ed8" }
tree-sitter-rust = "0.20.1"
tree-sitter-markdown = { git = "https://github.com/MDeiml/tree-sitter-markdown", rev = "330ecab87a3e3a7211ac69bbadc19eabecdb1cca" }
tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }
tree-sitter-typescript = "0.20.1"
url = "2.2"

View File

@ -37,6 +37,11 @@ pub fn build_language_registry(login_shell_env_loaded: Task<()>) -> LanguageRegi
tree_sitter_rust::language(),
Some(Arc::new(rust::RustLspAdapter)),
),
(
"toml",
tree_sitter_toml::language(),
None, //
),
(
"tsx",
tree_sitter_typescript::language_tsx(),

View File

@ -0,0 +1,3 @@
("[" @open "]" @close)
("{" @open "}" @close)
("\"" @open "\"" @close)

View File

@ -0,0 +1,9 @@
name = "TOML"
path_suffixes = ["toml"]
line_comment = "# "
autoclose_before = ",]}"
brackets = [
{ start = "{", end = "}", close = true, newline = true },
{ start = "[", end = "]", close = true, newline = true },
{ start = "\"", end = "\"", close = true, newline = false },
]

View File

@ -0,0 +1,33 @@
; Properties
;-----------
(bare_key) @property
(quoted_key) @property
; Literals
;---------
(boolean) @constant
(comment) @comment
(string) @string
(integer) @number
(float) @number
(offset_date_time) @string.special
(local_date_time) @string.special
(local_date) @string.special
(local_time) @string.special
; Punctuation
;------------
"." @punctuation.delimiter
"," @punctuation.delimiter
"=" @operator
"[" @punctuation.bracket
"]" @punctuation.bracket
"[[" @punctuation.bracket
"]]" @punctuation.bracket
"{" @punctuation.bracket
"}" @punctuation.bracket

View File

@ -0,0 +1,15 @@
(table
.
"["
.
(_) @name) @item
(table_array_element
.
"[["
.
(_) @name) @item
(pair
.
(_) @name) @item