nvim-treesitter/runtime/queries/systemverilog/highlights.scm

606 lines
9.5 KiB
Scheme
Raw Normal View History

2020-08-28 18:11:10 +02:00
; Keywords
[
2024-01-09 11:50:31 +02:00
"begin"
"end"
"generate"
"endgenerate"
(module_keyword)
2020-08-28 18:11:10 +02:00
"endmodule"
"program"
"endprogram"
2020-11-18 21:38:58 +01:00
"package"
"endpackage"
"checker"
"endchecker"
"config"
"endconfig"
"pure"
"virtual"
"extends"
"implements"
"super"
(class_item_qualifier)
"parameter"
"localparam"
"defparam"
"assign"
"modport"
2020-11-18 21:38:58 +01:00
"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"
"string"
2022-10-28 17:08:00 +03:00
(unique_priority)
(bins_keyword)
(always_keyword)
2020-08-28 18:11:10 +02:00
] @keyword
2024-04-23 12:23:15 -07:00
[
"class"
"endclass"
"interface"
"endinterface"
"enum"
"struct"
"union"
2024-06-17 18:19:08 -07:00
"typedef"
2024-04-23 12:23:15 -07:00
] @keyword.type
[
"function"
"endfunction"
"task"
"endtask"
] @keyword.function
"return" @keyword.return
2020-08-28 18:11:10 +02:00
[
"for"
"foreach"
"repeat"
"forever"
"while"
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.repeat
2020-08-28 18:11:10 +02:00
; 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)))))
2020-08-28 18:11:10 +02:00
[
"if"
"else"
"iff"
(case_keyword)
"endcase"
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.conditional
2020-08-28 18:11:10 +02:00
[
"="
"-"
"+"
"/"
"*"
"^"
"&"
"|"
"&&"
"||"
"<="
"=="
"!="
"==="
"!=="
"-:"
"<"
">"
">="
"%"
">>"
"<<"
"|="
"|=>"
"|->"
">>>"
"<<<"
"->>"
"->"
"=>"
"*>"
".*"
2022-10-28 17:08:00 +03:00
(unary_operator)
(inc_or_dec_operator)
(queue_dimension)
2020-08-28 18:11:10 +02:00
] @operator
"#" @constructor
[
";"
"::"
","
"."
":"
] @punctuation.delimiter
(conditional_expression
[
"?"
":"
] @keyword.conditional.ternary)
[
"["
"]"
"("
")"
"{"
"}"
"'{"
] @punctuation.bracket
2024-06-17 18:19:08 -07:00
2022-10-28 17:08:00 +03:00
[
"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
2020-08-28 18:11:10 +02:00
[
"include"
"import"
"`include"
] @keyword.import
2020-08-28 18:11:10 +02:00
[
(one_line_comment)
(block_comment)
] @comment @spell
2024-01-06 15:05:50 +09:00
[
"@"
(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
2020-08-28 18:11:10 +02:00
[
(net_type)
(integer_vector_type)
(time_unit)
(integer_atom_type)
(non_integer_type)
2020-08-28 18:11:10 +02:00
] @type.builtin
(data_type
(simple_identifier) @type.builtin)
; variable
(list_of_variable_decl_assignments
(variable_decl_assignment
name: (simple_identifier) @variable))
2020-08-28 18:11:10 +02:00
(hierarchical_identifier
(simple_identifier) @variable)
2020-08-28 18:11:10 +02:00
(tf_port_item
(simple_identifier) @variable)
2020-08-28 18:11:10 +02:00
port_name: (simple_identifier) @variable
(port
(simple_identifier) @variable)
(list_of_port_identifiers
(simple_identifier) @variable)
(net_lvalue
(simple_identifier) @variable)
2020-08-28 18:11:10 +02:00
(sequence_port_item
(simple_identifier) @variable)
2022-10-28 17:08:00 +03:00
(property_port_item
(simple_identifier) @variable)
2020-08-28 18:11:10 +02:00
(net_decl_assignment
(simple_identifier) @variable)
2020-08-28 18:11:10 +02:00
; variable.member
(hierarchical_identifier
(simple_identifier)
(simple_identifier) @variable.member)
2024-06-17 18:19:08 -07:00
(select
(simple_identifier) @variable.member)
2020-08-28 18:11:10 +02:00
(named_port_connection
port_name: (simple_identifier) @variable.member)
2020-08-28 18:11:10 +02:00
(ordered_port_connection
(expression
(primary
(hierarchical_identifier
(simple_identifier) @variable.member))))
(coverage_option
(simple_identifier) @variable.member)
2020-08-28 18:11:10 +02:00
; variable.builtin
(method_call_body
arguments: (list_of_arguments
(expression) @variable.builtin
(#eq? @variable.builtin "this")))
(implicit_class_handle) @variable.builtin
; variable.parameter
(named_parameter_assignment
2024-01-06 15:05:50 +09:00
(simple_identifier) @variable.parameter)
2020-08-28 18:11:10 +02:00
(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
2020-08-28 18:11:10 +02:00
[
(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)
2020-08-28 18:11:10 +02:00
(package_declaration
.
name: (simple_identifier) @constructor
(simple_identifier)? @label)
2020-08-28 18:11:10 +02:00
(checker_declaration
.
name: (simple_identifier) @constructor
(simple_identifier)? @label)
2020-08-28 18:11:10 +02:00
(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)
(generate_block
name: (simple_identifier) @label)
; function.call
(method_call_body
name: (simple_identifier) @function.call)
(tf_call
(hierarchical_identifier
(simple_identifier) @function.call))
; instance
2020-08-28 18:11:10 +02:00
(module_instantiation
instance_type: (simple_identifier) @constructor)
2020-08-28 18:11:10 +02:00
(name_of_instance
instance_name: (simple_identifier) @module)
2020-08-28 18:11:10 +02:00
(sequence_instance
(hierarchical_identifier
(simple_identifier) @module))
2020-08-28 18:11:10 +02:00
(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)
2020-08-28 18:11:10 +02:00
; converge
(cover_point
name: (simple_identifier) @label)
2020-08-28 18:11:10 +02:00
(cover_cross
name: (simple_identifier) @module)
2020-08-28 18:11:10 +02:00
(list_of_cross_items
(simple_identifier) @constructor)
;package
(package_import_item
(simple_identifier) @constructor)
; label
(seq_block
(simple_identifier) @label)
2020-08-28 18:11:10 +02:00
(statement
block_name: (simple_identifier) @label)
2020-08-28 18:11:10 +02:00
; dpi
(dpi_spec_string) @string
c_name: (c_identifier) @function
(dpi_import_export
name: (simple_identifier) @function)
2020-11-18 21:38:58 +01:00
; type def
(class_type
(simple_identifier) @constructor)
(class_type
(simple_identifier)
2024-01-06 15:05:50 +09:00
(simple_identifier) @type)
2020-08-28 18:11:10 +02:00
(data_type
(class_scope
(class_type
(simple_identifier) @constructor)))
2020-08-28 18:11:10 +02:00
(task_prototype
name: (simple_identifier) @function)
2020-08-28 18:11:10 +02:00
(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)
2020-08-28 18:11:10 +02:00
(data_declaration
(type_declaration
type_name: (simple_identifier) @type.definition))
2020-08-28 18:11:10 +02:00
(net_declaration
2024-01-06 15:05:50 +09:00
(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
[
"`define"
"`default_nettype"
(resetall_compiler_directive)
"`timescale"
"`undef"
(undefineall_compiler_directive)
"`ifdef"
"`ifndef"
"`elsif"
"`endif"
"`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)