Skip to content

Commit

Permalink
Add Vlang tree-sitter in the languages.toml (helix-editor#2526)
Browse files Browse the repository at this point in the history
Co-authored-by: pancake <[email protected]>
Co-authored-by: Michael Davis <[email protected]>
  • Loading branch information
3 people authored and mtoohey31 committed Jun 15, 2022
1 parent cfafd6a commit f6ac878
Show file tree
Hide file tree
Showing 3 changed files with 166 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 @@ -89,6 +89,7 @@
| tsx || | | `typescript-language-server` |
| twig || | | |
| typescript || || `typescript-language-server` |
| v || | | `vls` |
| vala || | | `vala-language-server` |
| verilog ||| | `svlangserver` |
| vue || | | `vls` |
Expand Down
15 changes: 15 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1381,6 +1381,21 @@ indent = { tab-width = 2, unit = " " }
name = "scheme"
source = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "27fb77db05f890c2823b4bd751c6420378df146b" }

[[language]]
name = "v"
scope = "source.v"
file-types = ["v", "vv"]
shebangs = ["v run"]
roots = ["v.mod"]
language-server = { command = "vls", args = [] }
auto-format = true
comment-token = "//"
indent = { tab-width = 4, unit = "\t" }

[[grammar]]
name = "v"
source = { git = "https://github.com/vlang/vls", subpath = "tree_sitter_v", rev = "3e8124ea4ab80aa08ec77f03df53f577902a0cdd" }

[[language]]
name = "verilog"
scope = "source.verilog"
Expand Down
150 changes: 150 additions & 0 deletions runtime/queries/v/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
(parameter_declaration
name: (identifier) @variable.parameter)
(function_declaration
name: (identifier) @function)
(function_declaration
receiver: (parameter_list)
name: (identifier) @function.method)

(call_expression
function: (identifier) @function)
(call_expression
function: (selector_expression
field: (identifier) @function.method))

(field_identifier) @variable.other.member
(selector_expression
field: (identifier) @variable.other.member)

(int_literal) @constant.numeric.integer
(interpreted_string_literal) @string
(rune_literal) @string
(escape_sequence) @constant.character.escape

[
(type_identifier)
(builtin_type)
(pointer_type)
(array_type)
] @type

[
(identifier)
(module_identifier)
(import_path)
] @variable

[
"as"
"asm"
"assert"
;"atomic"
;"break"
"const"
;"continue"
"defer"
"else"
"enum"
"fn"
"for"
"$for"
"go"
"goto"
"if"
"$if"
"import"
"in"
"!in"
"interface"
"is"
"!is"
"lock"
"match"
"module"
"mut"
"or"
"pub"
"return"
"rlock"
"select"
;"shared"
;"static"
"struct"
"type"
;"union"
"unsafe"
] @keyword

[
(true)
(false)
] @boolean

[
"."
","
":"
";"
] @punctuation.delimiter

[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket

(array) @punctuation.bracket

[
"++"
"--"

"+"
"-"
"*"
"/"
"%"

"~"
"&"
"|"
"^"

"!"
"&&"
"||"
"!="

"<<"
">>"

"<"
">"
"<="
">="

"+="
"-="
"*="
"/="
"&="
"|="
"^="
"<<="
">>="

"="
":="
"=="

"?"
"<-"
"$"
".."
"..."
] @operator

(comment) @comment

0 comments on commit f6ac878

Please sign in to comment.