extend highlight queries

pull/625/head^2
Nikolaj Sidorenco 2024-04-07 20:18:27 +07:00
parent 8e9ab7232a
commit 4a235170c5
No known key found for this signature in database
11 changed files with 31158 additions and 33497 deletions

@ -1632,6 +1632,8 @@ module.exports = grammar({
triple_quoted_string: $ => seq('"""', repeat($._string_char), $._triple_quoted_end),
bool: _ => token(choice('true', 'false')),
unit: _ => '()',
const: $ => choice(
@ -1639,7 +1641,7 @@ module.exports = grammar({
$.nativeint, $.unativeint, $.decimal,
$.uint64, $.ieee32, $.ieee64, $.bignum, $.char, $.string,
$.verbatim_string, $.triple_quoted_string, $.bytearray,
$.verbatim_bytearray, $.bytechar, 'false', 'true', $.unit),
$.verbatim_bytearray, $.bytechar, $.bool, $.unit),
// Identifiers:
long_identifier_or_op: $ => prec.right(

@ -46,6 +46,7 @@
],
"injection-regex": "fs",
"highlights": "queries/highlights.scm",
"injections": "queries/injections.scm",
"tags": "queries/tags.scm"
}
],

@ -4,10 +4,11 @@
[
(line_comment)
(block_comment)
(block_comment_content)
] @comment
] @comment @spell
(identifier) @variable (#set! "priority" 90)
;; ----------------------------------------------------------------------------
;; Punctuation
@ -20,6 +21,8 @@
"]"
"[|"
"|]"
; "{|"
; "|}"
"[<"
">]"
] @punctuation.bracket
@ -39,10 +42,9 @@
(infix_op)
(prefix_op)
(symbolic_op)
; TODO: split _indent_or_op
] @operator
(attribute) @attribute
[
@ -58,24 +60,24 @@
"&&"
"||"
"then"
] @keyword.control.conditional
] @keyword.conditional
[
"return"
"return!"
] @keyword.control.return
] @keyword.return
[
"for"
"while"
] @keyword.control.repeat
] @keyword.repeat
[
"open"
"#r"
"#load"
] @keyword.control.import
] @keyword.import
[
"abstract"
@ -86,17 +88,18 @@
"override"
"rec"
(access_modifier)
] @keyword.storage.modifier
] @keyword.modifier
[
"enum"
"let"
"let!"
"member"
"module"
"namespace"
] @keyword.function
[
"enum"
"type"
] @keyword.storage
] @keyword.type
[
"as"
@ -135,30 +138,26 @@
"with"
"yield"
"yield!"
"module"
"namespace"
] @keyword
[
"true"
"false"
] @boolean
(bool) @boolean
(type) @variable
[
(type)
(const)
"unit"
] @constant
(const) @constant
[
(type_name)
] @type.definition
(wildcard_pattern) @variable.parameter.builtin
(type_definition (_ (type_name (identifier) @type.definition))) @type
[
(union_type_case)
(rules (rule (identifier_pattern)))
] @type.enum
] @type
(fsi_directive_decl (string) @namespace)
(fsi_directive_decl (string) @module)
[
(import_decl (long_identifier))
@ -168,19 +167,21 @@
name: (long_identifier) )
(namespace
name: (long_identifier) )
] @namespace
] @module
(dot_expression
base: (long_identifier_or_op) @variable.other.member
field: (long_identifier_or_op) @function)
base: (long_identifier_or_op) @variable.member
field: (long_identifier_or_op) @property)
[
;;(value_declaration_left (identifier_pattern) )
(function_declaration_left (identifier) )
(call_expression (long_identifier_or_op (long_identifier)))
;;(application_expression (long_identifier_or_op (long_identifier)))
] @function
(value_declaration_left (identifier_pattern) @variable)
(function_declaration_left
(identifier)* @function
(argument_patterns (long_identifier (identifier) @variable.parameter)))
(call_expression (long_identifier_or_op (long_identifier))) @function.method.call
(application_expression (long_identifier_or_op (long_identifier))) @function.call
[
(string)
@ -192,6 +193,9 @@
(int16)
(int32)
(int64)
] @number
[
(float)
(decimal)
] @constant.numeric
] @number.float

@ -0,0 +1,6 @@
; Comments
((line_comment) @injection.content
(#set! injection.language "comment"))
((block_comment) @injection.content
(#set! injection.language "comment"))

24
src/grammar.json generated

@ -6392,6 +6392,22 @@
}
]
},
"bool": {
"type": "TOKEN",
"content": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "true"
},
{
"type": "STRING",
"value": "false"
}
]
}
},
"unit": {
"type": "STRING",
"value": "()"
@ -6488,12 +6504,8 @@
"name": "bytechar"
},
{
"type": "STRING",
"value": "false"
},
{
"type": "STRING",
"value": "true"
"type": "SYMBOL",
"name": "bool"
},
{
"type": "SYMBOL",

28
src/node-types.json generated

@ -880,12 +880,16 @@
"fields": {},
"children": {
"multiple": false,
"required": false,
"required": true,
"types": [
{
"type": "bignum",
"named": true
},
{
"type": "bool",
"named": true
},
{
"type": "byte",
"named": true
@ -983,12 +987,16 @@
"fields": {},
"children": {
"multiple": false,
"required": false,
"required": true,
"types": [
{
"type": "bignum",
"named": true
},
{
"type": "bool",
"named": true
},
{
"type": "byte",
"named": true
@ -3616,6 +3624,10 @@
"type": "block_comment_content",
"named": true
},
{
"type": "bool",
"named": true
},
{
"type": "comparison",
"named": false
@ -3680,10 +3692,6 @@
"type": "f",
"named": false
},
{
"type": "false",
"named": false
},
{
"type": "field",
"named": false
@ -3876,10 +3884,6 @@
"type": "to",
"named": false
},
{
"type": "true",
"named": false
},
{
"type": "try",
"named": false
@ -3894,11 +3898,11 @@
},
{
"type": "unit",
"named": false
"named": true
},
{
"type": "unit",
"named": true
"named": false
},
{
"type": "unmanaged",

64386
src/parser.c generated

File diff suppressed because it is too large Load Diff

@ -954,9 +954,12 @@ do
(value_declaration
(do
(if_expression
(const)
(const (int))
(const (int))))))
(const
(bool))
(const
(int))
(const
(int))))))
================================================================================
if-then-else expression 2
@ -971,9 +974,12 @@ do
(value_declaration
(do
(if_expression
(const)
(const (int))
(const (int))))))
(const
(bool))
(const
(int))
(const
(int))))))
================================================================================
if-then-else expression
@ -991,9 +997,12 @@ do
(value_declaration
(do
(if_expression
(const)
(const (int))
(const (int))))))
(const
(bool))
(const
(int))
(const
(int))))))
================================================================================
if-then expression 1
@ -1009,8 +1018,10 @@ do
(value_declaration
(do
(if_expression
(const)
(const (int))))))
(const
(bool))
(const
(int))))))
================================================================================
if-then expression 2
@ -1025,8 +1036,10 @@ do
(value_declaration
(do
(if_expression
(const)
(const (int))))))
(const
(bool))
(const
(int))))))
================================================================================
if-then-else expression 3
@ -1042,14 +1055,15 @@ do
--------------------------------------------------------------------------------
(file
(value_declaration
(do
(if_expression
(const)
(const
(int))
(const
(int))))))
(value_declaration
(do
(if_expression
(const
(bool))
(const
(int))
(const
(int))))))
================================================================================
anonymous function expression
@ -1335,37 +1349,38 @@ let test f =
--------------------------------------------------------------------------------
(file
(value_declaration
(function_or_value_defn
(function_declaration_left
(identifier)
(argument_patterns
(long_identifier
(identifier))))
(sequential_expression
(application_expression
(if_expression
(const)
(long_identifier_or_op
(long_identifier
(identifier))))
(long_identifier_or_op
(value_declaration
(function_or_value_defn
(function_declaration_left
(identifier)
(argument_patterns
(long_identifier
(identifier))))
(call_expression
(dot_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(sequential_expression
(application_expression
(if_expression
(const
(bool))
(long_identifier_or_op
(long_identifier
(identifier))))
(long_identifier_or_op
(long_identifier
(identifier))))
(tuple_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(const
(string))))))))
(call_expression
(dot_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(long_identifier_or_op
(long_identifier
(identifier))))
(tuple_expression
(long_identifier_or_op
(long_identifier
(identifier)))
(const
(string))))))))
================================================================================
if-expression in sequence expression
@ -1387,7 +1402,8 @@ let test =
(identifier))))
(sequential_expression
(if_expression
(const)
(const
(bool))
(const
(int)))
(const

@ -0,0 +1,8 @@
let f x = x + 1
// <- keyword.function
// ^ function
// ^ variable.parameter
// ^ operator
// ^ variable
// ^ operator
// ^ number

@ -1,9 +1,9 @@
#r "nuget: FSharp.Compiler.Service, 43.7.300"
//<- keyword.control.import
//<- keyword.import
// ^ string
#r "/home/bin/MyApp.dll"
//<- keyword.control.import
//<- keyword.import
// ^ string
#load "Strings.fsx"
//<- keyword.control.import
//<- keyword.import
// ^ string

@ -1,4 +1,4 @@
type A = int
//<- keyword.storage
//<- keyword.type
// ^ type.definition