diff options
| author | zhangwwpeng <133727312+zhangwwpeng@users.noreply.github.com> | 2024-06-24 00:36:01 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-23 18:36:01 +0200 |
| commit | b5b64ac9fb544421250f6c581c0e43c886f3f7fa (patch) | |
| tree | 159029d6fd172658ec6bf37d346c865f2351247c | |
| parent | fix(latex): correct lockfile hash (diff) | |
| download | nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar.gz nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar.bz2 nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar.lz nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar.xz nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.tar.zst nvim-treesitter-b5b64ac9fb544421250f6c581c0e43c886f3f7fa.zip | |
feat: add systemverilog support (#6775)
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | lockfile.json | 3 | ||||
| -rw-r--r-- | lua/nvim-treesitter/parsers.lua | 9 | ||||
| -rw-r--r-- | queries/systemverilog/folds.scm | 23 | ||||
| -rw-r--r-- | queries/systemverilog/highlights.scm | 595 | ||||
| -rw-r--r-- | queries/systemverilog/injections.scm | 5 |
6 files changed, 635 insertions, 1 deletions
@@ -407,6 +407,7 @@ We are looking for maintainers to add more parsers and to write query files for - [x] [swift](https://github.com/alex-pinkus/tree-sitter-swift) (maintained by @alex-pinkus) - [x] [sxhkdrc](https://github.com/RaafatTurki/tree-sitter-sxhkdrc) (maintained by @RaafatTurki) - [x] [systemtap](https://github.com/ok-ryoko/tree-sitter-systemtap) (maintained by @ok-ryoko) +- [x] [systemverilog](https://github.com/gmlarumbe/tree-sitter-systemverilog) (maintained by @zhangwwpeng) - [x] [t32](https://gitlab.com/xasc/tree-sitter-t32.git) (maintained by @xasc) - [x] [tablegen](https://github.com/amaanq/tree-sitter-tablegen) (maintained by @amaanq) - [x] [tact](https://github.com/tact-lang/tree-sitter-tact) (maintained by @novusnota) diff --git a/lockfile.json b/lockfile.json index 6914eba51..a3ea9cba1 100644 --- a/lockfile.json +++ b/lockfile.json @@ -701,6 +701,9 @@ "systemtap": { "revision": "1af543a96d060b1f808982037bfc54cc02218edd" }, + "systemverilog": { + "revision": "7dc4904578a29315c64f0f6500920baff41cc3af" + }, "t32": { "revision": "6182836f4128725f1e74ce986840d7317021a015" }, diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua index da2b2f6fa..16a425168 100644 --- a/lua/nvim-treesitter/parsers.lua +++ b/lua/nvim-treesitter/parsers.lua @@ -34,7 +34,6 @@ for ft, lang in pairs { html_tags = "html", ["typescript.tsx"] = "tsx", ["html.handlebars"] = "glimmer", - systemverilog = "verilog", pandoc = "markdown", rmd = "markdown", quarto = "markdown", @@ -2040,6 +2039,14 @@ list.systemtap = { maintainers = { "@ok-ryoko" }, } +list.systemverilog = { + install_info = { + url = "https://github.com/zhangwwpeng/tree-sitter-systemverilog", + files = { "src/parser.c" }, + }, + maintainers = { "@zhangwwpeng" }, +} + list.t32 = { install_info = { url = "https://gitlab.com/xasc/tree-sitter-t32.git", diff --git a/queries/systemverilog/folds.scm b/queries/systemverilog/folds.scm new file mode 100644 index 000000000..ea52476a4 --- /dev/null +++ b/queries/systemverilog/folds.scm @@ -0,0 +1,23 @@ +[ + (seq_block) + (function_body_declaration) + (task_body_declaration) + (generate_block) + (always_construct) + (property_declaration) + (checker_declaration) + (class_declaration) + (config_declaration) + (covergroup_declaration) + (clocking_declaration) + (interface_declaration) + (module_declaration) + (package_declaration) + (module_instantiation) + (program_declaration) + (specify_block) + (generate_region) + (package_import_declaration) + (text_macro_definition) + (include_compiler_directive)+ +] @fold diff --git a/queries/systemverilog/highlights.scm b/queries/systemverilog/highlights.scm new file mode 100644 index 000000000..c8cff453f --- /dev/null +++ b/queries/systemverilog/highlights.scm @@ -0,0 +1,595 @@ +; Keywords +[ + "begin" + "end" + "generate" + "endgenerate" + (module_keyword) + "endmodule" + "program" + "endprogram" + "package" + "endpackage" + "checker" + "endchecker" + "config" + "endconfig" + "pure" + "virtual" + "extends" + "implements" + "super" + (class_item_qualifier) + "parameter" + "localparam" + "defparam" + "assign" + "modport" + "fork" + "join" + "join_none" + "join_any" + "default" + "break" + "tagged" + "extern" + "alias" + "posedge" + "negedge" + "bind" + "expect" + "type" + "void" + "coverpoint" + "cross" + "nettype" + "export" + "force" + "release" + "timeunit" + "timeprecision" + "sequence" + "endsequence" + "property" + "endproperty" + "clocking" + "endclocking" + "covergroup" + "endgroup" + "specify" + "endspecify" + "primitive" + "endprimitive" + "wait" + "wait_order" + "const" + "constraint" + "unique" + "do" + "genvar" + "inside" + "rand" + "continue" + "randc" + "event" + "global" + "ref" + "initial" + (unique_priority) + (bins_keyword) + (always_keyword) +] @keyword + +[ + "class" + "endclass" + "interface" + "endinterface" + "enum" + "struct" + "union" + "typedef" +] @keyword.type + +[ + "function" + "endfunction" + "task" + "endtask" +] @keyword.function + +"return" @keyword.return + +[ + "for" + "foreach" + "repeat" + "forever" + "while" +] @keyword.repeat + +; for +(loop_generate_construct + (generate_block + [ + "begin" + "end" + ] @keyword.conditional)) + +; foreach +(loop_statement + (statement + (statement_item + (seq_block + [ + "begin" + "end" + ] @keyword.conditional)))) + +; repeat forever while +(loop_statement + (statement_or_null + (statement + (statement_item + (seq_block + [ + "begin" + "end" + ] @keyword.conditional))))) + +[ + "if" + "else" + "iff" + (case_keyword) + "endcase" +] @keyword.conditional + +[ + "=" + "-" + "+" + "/" + "*" + "^" + "&" + "|" + "&&" + "||" + "<=" + "==" + "!=" + "===" + "!==" + "-:" + "<" + ">" + ">=" + "%" + ">>" + "<<" + "|=" + "|=>" + "|->" + ">>>" + "<<<" + "->>" + "->" + "=>" + "*>" + ".*" + (unary_operator) + (inc_or_dec_operator) + (queue_dimension) +] @operator + +"#" @constructor + +[ + ";" + "::" + "," + "." + ":" +] @punctuation.delimiter + +(conditional_expression + [ + "?" + ":" + ] @keyword.conditional.ternary) + +[ + "[" + "]" + "(" + ")" + "{" + "}" + "'{" +] @punctuation.bracket + +[ + "or" + "and" +] @keyword.operator + +[ + "input" + "output" + "inout" + "signed" + "unsigned" + "assert" + "cover" + "assume" + "disable" + "automatic" + "static" + (dpi_function_import_property) + (dpi_task_import_property) +] @keyword.modifier + +[ + "include" + "import" + "directive_include" +] @keyword.import + +(comment) @comment @spell + +[ + "@" + (cycle_delay_range) + (delay_control) + (cycle_delay) + (attribute_instance) +] @attribute + +(attribute_instance + (attr_spec + (simple_identifier) @property)) + +[ + (integral_number) + (unbased_unsized_literal) + (fixed_point_number) + (unsigned_number) +] @number + +[ + (net_type) + (data_type) + (time_unit) +] @type.builtin + +; variable +(list_of_variable_decl_assignments + (variable_decl_assignment + name: (simple_identifier) @variable)) + +(hierarchical_identifier + (simple_identifier) @variable) + +(tf_port_item + (simple_identifier) @variable) + +port_name: (simple_identifier) @variable + +(port + (simple_identifier) @variable) + +(list_of_port_identifiers + (simple_identifier) @variable) + +(net_lvalue + (simple_identifier) @variable) + +(sequence_port_item + (simple_identifier) @variable) + +(property_port_item + (simple_identifier) @variable) + +(net_decl_assignment + (simple_identifier) @variable) + +(ERROR + (simple_identifier) @variable) + +; variable.member +(hierarchical_identifier + (simple_identifier) + (simple_identifier) @variable.member) + +(select + (simple_identifier) @variable.member) + +(named_port_connection + port_name: (simple_identifier) @variable.member) + +(ordered_port_connection + (expression + (primary + (hierarchical_identifier + (simple_identifier) @variable.member)))) + +(coverage_option + (simple_identifier) @variable.member) + +; variable.builtin +(method_call_body + arguments: (list_of_arguments + (expression) @variable.builtin + (#any-of? @variable.builtin "this"))) + +(implicit_class_handle) @variable.builtin + +; variable.parameter +(named_parameter_assignment + (simple_identifier) @variable.parameter) + +(parameter_declaration + (list_of_param_assignments + (param_assignment + (simple_identifier) @variable.parameter))) + +(local_parameter_declaration + (list_of_param_assignments + (param_assignment + (simple_identifier) @variable.parameter))) + +; function builtin +[ + (simulation_control_task) + (system_tf_identifier) + (severity_system_task) + (randomize_call) + (array_or_queue_method_name) + "new" +] @function.builtin + +; declaration +(task_body_declaration + . + name: (simple_identifier) @function + (simple_identifier)? @label) + +(function_body_declaration + . + name: (simple_identifier) @function + (simple_identifier)? @label) + +(function_body_declaration + . + (data_type_or_void) + name: (simple_identifier) @function + (simple_identifier)? @label) + +(clocking_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(sequence_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(property_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(class_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(interface_class_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(covergroup_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(package_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(checker_declaration + . + name: (simple_identifier) @constructor + (simple_identifier)? @label) + +(interface_declaration + . + [ + (simple_identifier) @constructor + (interface_nonansi_header + (simple_identifier) @constructor) + (interface_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +(module_declaration + . + [ + (simple_identifier) @constructor + (module_nonansi_header + (simple_identifier) @constructor) + (module_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +(program_declaration + . + [ + (simple_identifier) @constructor + (program_nonansi_header + (simple_identifier) @constructor) + (program_ansi_header + (simple_identifier) @constructor) + ] + (simple_identifier)? @label) + +; function.call +(method_call_body + name: (simple_identifier) @function.call) + +(tf_call + (hierarchical_identifier + (simple_identifier) @function.call)) + +; instance +(module_instantiation + instance_type: (simple_identifier) @constructor) + +(name_of_instance + instance_name: (simple_identifier) @module) + +(sequence_instance + (hierarchical_identifier + (simple_identifier) @module)) + +(udp_instantiation + (simple_identifier) @constructor) + +(ansi_port_declaration + (interface_port_header + interface_name: (simple_identifier) @variable + modport_name: (simple_identifier) @variable.member) + port_name: (simple_identifier) @variable) + +; bind +(bind_directive + (bind_target_scope + (simple_identifier) @constructor)) + +(bind_target_instance + (hierarchical_identifier + (simple_identifier) @module)) + +; assertion +(concurrent_assertion_item + (simple_identifier) @label) + +; converge +(cover_point + name: (simple_identifier) @label) + +(cover_cross + name: (simple_identifier) @module) + +(list_of_cross_items + (simple_identifier) @constructor) + +;package +(package_import_item + (simple_identifier) @constructor) + +; label +(seq_block + (simple_identifier) @label) + +(statement + block_name: (simple_identifier) @label) + +; dpi +(dpi_spec_string) @string + +c_name: (c_identifier) @function + +(dpi_import_export + name: (simple_identifier) @function) + +; type def +(class_type + (simple_identifier) @constructor) + +(class_type + (simple_identifier) + (simple_identifier) @type) + +(data_type + (class_scope + (class_type + (simple_identifier) @constructor))) + +(task_prototype + name: (simple_identifier) @function) + +(function_prototype + name: (simple_identifier) @function) + +(type_assignment + name: (simple_identifier) @type.definition) + +(interface_class_type + (simple_identifier) @type.definition) + +(package_scope + (simple_identifier) @constructor) + +(data_declaration + (type_declaration + type_name: (simple_identifier) @type.definition)) + +(net_declaration + (simple_identifier) @type) + +(constraint_declaration + (simple_identifier) @constructor) + +(method_call + (primary + (hierarchical_identifier + (simple_identifier) @constructor))) + +(string_literal + (quoted_string) @string) + +; include +(include_statement + (file_path_spec) @string.special.path) + +; directive +[ + "directive_define" + "directive_default_nettype" + "directive_resetall" + "directive_timescale" + "directive_undef" + "directive_undefineall" + "directive_ifdef" + "directive_elsif" + "directive_endif" + "directive_else" +] @keyword.directive.define + +(include_compiler_directive + (quoted_string) @string.special.path) + +(include_compiler_directive + (system_lib_string) @string) + +(default_nettype_compiler_directive + (default_nettype_value) @type.builtin) + +(text_macro_definition + (text_macro_name + (simple_identifier) @keyword.directive)) + +(text_macro_usage) @keyword.directive + +(ifdef_condition + (simple_identifier) @keyword.directive) + +(undefine_compiler_directive + (simple_identifier) @keyword.directive) diff --git a/queries/systemverilog/injections.scm b/queries/systemverilog/injections.scm new file mode 100644 index 000000000..b6d2d4721 --- /dev/null +++ b/queries/systemverilog/injections.scm @@ -0,0 +1,5 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +((macro_text) @injection.content + (#set! injection.language "systemverilog")) |
