From 0eacb2f0325126638927ba207620035c8742c633 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 26 May 2022 15:53:09 +0200 Subject: [PATCH 1/3] Add Vlang tree-sitter in the languages.toml * $ cargo xtask docgen * Name it v instead of vlang and add highlights.scm * Setup tabstop and vls --- book/src/generated/lang-support.md | 1 + languages.toml | 15 +++ runtime/queries/v/highlights.scm | 147 +++++++++++++++++++++++++++++ 3 files changed, 163 insertions(+) create mode 100644 runtime/queries/v/highlights.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index e47ccbc4d2b5..49f5a2b6d59b 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -89,6 +89,7 @@ | tsx | ✓ | | | `typescript-language-server` | | twig | ✓ | | | | | typescript | ✓ | | ✓ | `typescript-language-server` | +| v | ✓ | | | | | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vue | ✓ | | | `vls` | diff --git a/languages.toml b/languages.toml index e2bf26bf41c8..35c4b4704ca3 100644 --- a/languages.toml +++ b/languages.toml @@ -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" diff --git a/runtime/queries/v/highlights.scm b/runtime/queries/v/highlights.scm new file mode 100644 index 000000000000..dbd016251611 --- /dev/null +++ b/runtime/queries/v/highlights.scm @@ -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 From 0e83865bc18e6b64d52f31bfc60d8f75d12816bb Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 27 May 2022 14:37:02 +0200 Subject: [PATCH 2/3] docgen --- book/src/generated/lang-support.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 49f5a2b6d59b..c4e602452dc9 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -89,7 +89,7 @@ | tsx | ✓ | | | `typescript-language-server` | | twig | ✓ | | | | | typescript | ✓ | | ✓ | `typescript-language-server` | -| v | ✓ | | | | +| v | ✓ | | | `vls` | | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vue | ✓ | | | `vls` | From e5d9914b7ecc72151f987e13163307616d9505a1 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Sat, 28 May 2022 11:26:38 -0500 Subject: [PATCH 3/3] adjust highlight query scopes to match helix's --- runtime/queries/v/highlights.scm | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/runtime/queries/v/highlights.scm b/runtime/queries/v/highlights.scm index dbd016251611..c71245dcad60 100644 --- a/runtime/queries/v/highlights.scm +++ b/runtime/queries/v/highlights.scm @@ -1,37 +1,38 @@ -(ERROR) @error -(comment) @comment - -(identifier) @variable -(module_identifier) @variable -(import_path) @variable - (parameter_declaration - name: (identifier) @parameter) + name: (identifier) @variable.parameter) (function_declaration name: (identifier) @function) (function_declaration receiver: (parameter_list) - name: (identifier) @method) + name: (identifier) @function.method) (call_expression function: (identifier) @function) (call_expression function: (selector_expression - field: (identifier) @method)) + field: (identifier) @function.method)) -(type_identifier) @type -(builtin_type) @type -(pointer_type) @type -(array_type) @type - -(field_identifier) @property +(field_identifier) @variable.other.member (selector_expression - field: (identifier) @property) + field: (identifier) @variable.other.member) -(int_literal) @number +(int_literal) @constant.numeric.integer (interpreted_string_literal) @string (rune_literal) @string -(escape_sequence) @string.escape +(escape_sequence) @constant.character.escape + +[ + (type_identifier) + (builtin_type) + (pointer_type) + (array_type) +] @type + +[ + (identifier) + (module_identifier) + (import_path) +] @variable [ "as" @@ -145,3 +146,5 @@ ".." "..." ] @operator + +(comment) @comment \ No newline at end of file