From 8b4da44c03b6c79832f47dd27ba9f542510d4eab Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 27 Jul 2023 21:04:13 +0800 Subject: [PATCH 1/6] fix vlang grammar fetch and build fail --- languages.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languages.toml b/languages.toml index 7f77429635cc..74ee6cf5e6ca 100644 --- a/languages.toml +++ b/languages.toml @@ -70,7 +70,7 @@ terraform-ls = { command = "terraform-ls", args = ["serve"] } texlab = { command = "texlab" } vala-language-server = { command = "vala-language-server" } vhdl_ls = { command = "vhdl_ls", args = [] } -vlang-language-server = { command = "v", args = ["ls"] } +vlang-language-server = {command = "v-analyzer", args = [""]} vscode-css-language-server = { command = "vscode-css-language-server", args = ["--stdio"], config = { "provideFormatter" = true }} vscode-html-language-server = { command = "vscode-html-language-server", args = ["--stdio"], config = { provideFormatter = true } } vscode-json-language-server = { command = "vscode-json-language-server", args = ["--stdio"], config = { provideFormatter = true } } @@ -1826,7 +1826,7 @@ indent = { tab-width = 4, unit = "\t" } [[grammar]] name = "v" -source = { git = "https://github.com/vlang/vls", subpath = "tree_sitter_v", rev = "66cf9d3086fb5ecc827cb32c64c5d812ab17d2c6" } +source = {git = "https://github.com/v-analyzer/v-analyzer", subpath = "tree_sitter_v", rev = "e14fdf6e661b10edccc744102e4ccf0b187aa8ad"} [[language]] name = "verilog" From 0440c24c75788f093f6691a77d605f83d0b8069c Mon Sep 17 00:00:00 2001 From: tony Date: Thu, 27 Jul 2023 22:49:59 +0800 Subject: [PATCH 2/6] update highlights.scm for v-analyzer --- runtime/queries/v/highlights.scm | 136 +++++++++++++++++++------------ 1 file changed, 85 insertions(+), 51 deletions(-) diff --git a/runtime/queries/v/highlights.scm b/runtime/queries/v/highlights.scm index e014b77d9e78..34fc473a2ee4 100644 --- a/runtime/queries/v/highlights.scm +++ b/runtime/queries/v/highlights.scm @@ -1,83 +1,112 @@ +(comment) @comment + +(module_clause + (identifier) @namespace) + +(import_path + (import_name) @namespace) + +(import_alias + (import_name) @namespace) + +(enum_fetch + (reference_expression) @constant) + +(enum_field_definition + (identifier) @constant) + +(global_var_definition + (identifier) @constant) + +(compile_time_if_expression + condition: (reference_expression) @constant) + +(compile_time_if_expression + condition: (binary_expression + left: (reference_expression) @constant + right: (reference_expression) @constant)) + +(compile_time_if_expression + condition: (binary_expression + left: (reference_expression) @constant + right: (unary_expression (reference_expression) @constant))) + +(label_reference) @label + (parameter_declaration - name: (identifier) @variable.parameter) + name: (identifier) @variable.parameter) +(receiver + name: (identifier) @variable.parameter) (function_declaration - name: (identifier) @function) + name: (identifier) @function) (function_declaration - receiver: (parameter_list) - name: (identifier) @function.method) + receiver: (receiver) + name: (identifier) @function.method) +(interface_method_definition + name: (identifier) @function.method) (call_expression - function: (identifier) @function) -(call_expression - function: (selector_expression - field: (identifier) @function.method)) + name: (selector_expression + field: (reference_expression) @function.method)) -(field_identifier) @variable.other.member -(selector_expression - operand: (identifier) @variable - field: (identifier) @variable.other.member) +(call_expression + name: (reference_expression) @function) -(int_literal) @constant.numeric.integer +(struct_declaration + name: (identifier) @type) -(attribute_declaration) @attribute -(comment) @comment -[ - (c_string_literal) - (raw_string_literal) - (interpreted_string_literal) - (string_interpolation) - (rune_literal) -] @string +(enum_declaration + name: (identifier) @type) -(escape_sequence) @constant.character.escape +(interface_declaration + name: (identifier) @type) -[ - (pointer_type) - (array_type) -] @type +(type_declaration + name: (identifier) @type) -(const_spec name: (identifier) @constant) -(global_var_type_initializer name: (identifier) @constant) -(global_var_spec name: (identifier) @constant) -((identifier) @constant (#match? @constant "^[A-Z][A-Z\\d_]*$")) +(struct_field_declaration + name: (identifier) @variable.other.member) +(field_name) @variable.other.member -[ - (generic_type) - (type_identifier) -] @constructor +(selector_expression + field: (reference_expression) @variable.other.member) -(builtin_type) @type.builtin +(int_literal) @constant.numeric.integer +(escape_sequence) @constant.character.escape [ - (true) - (false) -] @constant.builtin.boolean + (c_string_literal) + (raw_string_literal) + (interpreted_string_literal) + (string_interpolation) + (rune_literal) +] @string +(string_interpolation + (braced_interpolation_opening) @punctuation.bracket + (interpolated_expression) @none + (braced_interpolation_closing) @punctuation.bracket) -[ - (module_identifier) - (import_path) -] @namespace +(attribute) @attribute [ - (pseudo_comptime_identifier) - (label_name) -] @label + (type_reference_expression) + ] @type [ - (identifier) -] @variable - + (true) + (false) +] @constant.builtin.boolean [ "pub" "assert" - "go" "asm" "defer" "unsafe" "sql" + (nil) (none) ] @keyword @@ -105,12 +134,17 @@ "lock" "rlock" "spawn" + "break" + "continue" + "go" ] @keyword.control [ "if" + "$if" "select" "else" + "$else" "match" ] @keyword.control.conditional @@ -155,7 +189,7 @@ "]" ] @punctuation.bracket -(array) @punctuation.bracket +(array_creation) @punctuation.bracket [ "++" From 9ea79460cb929fc54ff454048331e7714afdcccb Mon Sep 17 00:00:00 2001 From: lydiandy Date: Sat, 29 Jul 2023 01:04:26 +0800 Subject: [PATCH 3/6] Update languages.toml Co-authored-by: Michael Davis --- languages.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages.toml b/languages.toml index 74ee6cf5e6ca..1d4fe6f6be78 100644 --- a/languages.toml +++ b/languages.toml @@ -70,7 +70,7 @@ terraform-ls = { command = "terraform-ls", args = ["serve"] } texlab = { command = "texlab" } vala-language-server = { command = "vala-language-server" } vhdl_ls = { command = "vhdl_ls", args = [] } -vlang-language-server = {command = "v-analyzer", args = [""]} +vlang-language-server = { command = "v-analyzer" } vscode-css-language-server = { command = "vscode-css-language-server", args = ["--stdio"], config = { "provideFormatter" = true }} vscode-html-language-server = { command = "vscode-html-language-server", args = ["--stdio"], config = { provideFormatter = true } } vscode-json-language-server = { command = "vscode-json-language-server", args = ["--stdio"], config = { provideFormatter = true } } From 220cf7bbcc38d94189441f82c3a874f6bd32b777 Mon Sep 17 00:00:00 2001 From: lydiandy Date: Sat, 29 Jul 2023 01:04:44 +0800 Subject: [PATCH 4/6] Update runtime/queries/v/highlights.scm Co-authored-by: Michael Davis --- runtime/queries/v/highlights.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/queries/v/highlights.scm b/runtime/queries/v/highlights.scm index 34fc473a2ee4..fbaf70882d96 100644 --- a/runtime/queries/v/highlights.scm +++ b/runtime/queries/v/highlights.scm @@ -85,7 +85,7 @@ (string_interpolation (braced_interpolation_opening) @punctuation.bracket - (interpolated_expression) @none + (interpolated_expression) @embedded (braced_interpolation_closing) @punctuation.bracket) (attribute) @attribute From 6dba4da6f317fd1ea07ee732315f7d7b2fba02e6 Mon Sep 17 00:00:00 2001 From: tony Date: Sat, 29 Jul 2023 20:18:29 +0800 Subject: [PATCH 5/6] update scm for new lsp --- runtime/queries/v/indents.scm | 5 ++--- runtime/queries/v/textobjects.scm | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/runtime/queries/v/indents.scm b/runtime/queries/v/indents.scm index 5573d4897c2e..21dae30f5517 100644 --- a/runtime/queries/v/indents.scm +++ b/runtime/queries/v/indents.scm @@ -3,11 +3,10 @@ (function_declaration) (if_expression) (match_expression) - (expression_case) - (default_case) (for_statement) (unsafe_expression) - (short_var_declaration) + (var_declaration) + (const_declaration) ] @indent [ diff --git a/runtime/queries/v/textobjects.scm b/runtime/queries/v/textobjects.scm index 40eb101fe5fb..5015af17ef59 100644 --- a/runtime/queries/v/textobjects.scm +++ b/runtime/queries/v/textobjects.scm @@ -6,7 +6,7 @@ body: (block)? @test.inside) @test.around (#match? @_name "^test")) -(fn_literal +(function_literal body: (block)? @function.inside) @function.around (parameter_list @@ -17,9 +17,9 @@ ((_) @parameter.inside) @parameter.around)) (struct_declaration - (struct_field_declaration_list) @class.inside) @class.around + (struct_field_declaration) @class.inside) @class.around -(struct_field_declaration_list +(struct_field_declaration ((_) @parameter.inside) @parameter.around) (comment) @comment.inside From d202c9fbb956eaf0cc62751fc0ddde1365be7bbf Mon Sep 17 00:00:00 2001 From: tony Date: Sun, 30 Jul 2023 00:23:20 +0800 Subject: [PATCH 6/6] gen doc lang-support.md --- 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 8941f735f20b..244e5a3b74f3 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -156,7 +156,7 @@ | typescript | ✓ | ✓ | ✓ | `typescript-language-server` | | ungrammar | ✓ | | | | | uxntal | ✓ | | | | -| v | ✓ | ✓ | ✓ | `v` | +| v | ✓ | ✓ | ✓ | `v-analyzer` | | vala | ✓ | | | `vala-language-server` | | verilog | ✓ | ✓ | | `svlangserver` | | vhdl | ✓ | | | `vhdl_ls` |