diff --git a/languages.toml b/languages.toml index 8776947a8..6bed6cf9f 100644 --- a/languages.toml +++ b/languages.toml @@ -3129,7 +3129,7 @@ language-servers = ["fsharp-ls"] [[grammar]] name = "fsharp" -source = { git = "https://github.com/kaashyapan/tree-sitter-fsharp", rev = "18da392fd9bd5e79f357abcce13f61f3a15e3951" } +source = { git = "https://github.com/ionide/tree-sitter-fsharp", rev = "ed675061da3df4b5a27d1d2e19297abd807268c2" } [[language]] name = "t32" diff --git a/runtime/queries/fsharp/highlights.scm b/runtime/queries/fsharp/highlights.scm index 68b70ba7d..6487d72f5 100644 --- a/runtime/queries/fsharp/highlights.scm +++ b/runtime/queries/fsharp/highlights.scm @@ -4,9 +4,11 @@ [ (line_comment) (block_comment) - (block_comment_content) -] @comment +] @comment @spell +(xml_doc) @comment.doc @spell + +(identifier) @variable (#set! "priority" 90) ;; ---------------------------------------------------------------------------- ;; Punctuation @@ -20,17 +22,19 @@ "]" "[|" "|]" + ; "{|" + ; "|}" "[<" ">]" ] @punctuation.bracket [ - "," + "," ";" + "|" ] @punctuation.delimiter [ - "|" "=" ">" "<" @@ -38,11 +42,8 @@ "~" (infix_op) (prefix_op) - (symbolic_op) ] @operator - - (attribute) @attribute [ @@ -53,131 +54,150 @@ "when" "match" "match!" - "and" - "or" + "then" "&&" "||" - "then" -] @keyword.control.conditional +] @keyword.conditional + +[ + "and" + "or" + "not" + "upcast" + "downcast" +] @keyword.operator [ "return" "return!" -] @keyword.control.return + "yield" + "yield!" +] @keyword.return [ "for" "while" -] @keyword.control.return + "downto" + "to" +] @keyword.repeat [ "open" "#r" "#load" -] @keyword.control.import +] @keyword.import [ "abstract" "delegate" "static" "inline" - "internal" "mutable" "override" - "private" - "public" "rec" -] @keyword.storage.modifier + "global" + (access_modifier) +] @keyword.modifier [ - "enum" "let" "let!" + "use" + "use!" "member" - "module" - "namespace" +] @keyword.function + +[ + "enum" "type" -] @keyword.storage + "inherit" + "interface" +] @keyword.type + +[ + "try" + "with" + "finally" +] @keyword.exception [ "as" "assert" "begin" + "end" + "done" "default" "do" "do!" - "done" - "downcast" - "downto" - "end" "event" "field" - "finally" "fun" "function" "get" - "global" - "inherit" - "interface" + "set" "lazy" "new" - "not" "null" "of" "param" "property" - "set" "struct" - "try" - "upcast" - "use" - "use!" "val" - "with" - "yield" - "yield!" + "module" + "namespace" ] @keyword -[ - "true" - "false" - "unit" - ] @constant.builtin +(bool) @boolean -[ - (type) - (const) -] @constant +(type) @variable + +(const) @constant + +(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)) - (named_module (long_identifier)) - (namespace (long_identifier)) - (named_module + (named_module (long_identifier)) + (namespace (long_identifier)) + (named_module name: (long_identifier) ) - (namespace + (namespace name: (long_identifier) ) -] @namespace +] @module (dot_expression - base: (long_identifier_or_op) @variable.other.member - field: (long_identifier_or_op) @function) + base: (_) @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) + (argument_patterns (long_identifier (identifier))) + ] @variable.parameter) + +(member_defn + (method_or_prop_defn + (property_or_ident + instance: (identifier) @variable.parameter.builtin + method: (identifier) @variable.member) + args: _ @variable.parameter)) + +(call_expression (long_identifier_or_op (long_identifier))) @function.method.call +(application_expression (long_identifier_or_op (long_identifier))) @function.call [ (string) @@ -189,8 +209,9 @@ (int16) (int32) (int64) +] @number + +[ (float) (decimal) -] @constant.numeric - - +] @number.float \ No newline at end of file diff --git a/runtime/queries/fsharp/injections.scm b/runtime/queries/fsharp/injections.scm new file mode 100644 index 000000000..bbdd8f1a8 --- /dev/null +++ b/runtime/queries/fsharp/injections.scm @@ -0,0 +1,10 @@ +; Comments +((line_comment) @injection.content + (#set! injection.language "comment")) + +((block_comment) @injection.content + (#set! injection.language "comment")) + +((xml_doc + (xml_doc_content) @injection.content) + (#set! injection.language "comment")) \ No newline at end of file