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

Add Vlang tree-sitter in the languages.toml #2526

Merged
merged 3 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -89,6 +89,7 @@
| tsx | ✓ | | | `typescript-language-server` |
| twig | ✓ | | | |
| typescript | ✓ | | ✓ | `typescript-language-server` |
| v | ✓ | | | |
| 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 = [] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One note (not sure what we can do about this though):

There's already the command vls for vue

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I don't think there's much we can do about it on our end. I guess you can't develop in v and vue at the same time 😄

I think in other editors plugins might solve this if they install the language server binary local to the plugin. I'm not too worried about this though.

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
147 changes: 147 additions & 0 deletions runtime/queries/v/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
(ERROR) @error
(comment) @comment

(identifier) @variable
(module_identifier) @variable
(import_path) @variable

(parameter_declaration
name: (identifier) @parameter)
(function_declaration
name: (identifier) @function)
(function_declaration
receiver: (parameter_list)
name: (identifier) @method)

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

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

(field_identifier) @property
(selector_expression
field: (identifier) @property)

(int_literal) @number
(interpreted_string_literal) @string
(rune_literal) @string
(escape_sequence) @string.escape

[
"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