aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNikolaj Sidorenco <Nikolaj176@hotmail.com>2024-09-29 11:08:21 +0200
committerGitHub <noreply@github.com>2024-09-29 11:08:21 +0200
commit707313b80a2f1e65fa06dba2052cc49ce6762a60 (patch)
tree193c0da9bb62f8a8868a6c7cef2c04410c839c2d
parentbot(lockfile): update arduino, elixir, templ, tlaplus (diff)
downloadnvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar.gz
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar.bz2
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar.lz
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar.xz
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.tar.zst
nvim-treesitter-707313b80a2f1e65fa06dba2052cc49ce6762a60.zip
feat(fsharp): add parser and queries (#7166)
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/fsharp/highlights.scm411
-rw-r--r--queries/fsharp/injections.scm11
5 files changed, 435 insertions, 0 deletions
diff --git a/README.md b/README.md
index a953df38f..40ac497f1 100644
--- a/README.md
+++ b/README.md
@@ -239,6 +239,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [forth](https://github.com/AlexanderBrevig/tree-sitter-forth) (maintained by @amaanq)
- [x] [fortran](https://github.com/stadelmanma/tree-sitter-fortran) (maintained by @amaanq)
- [x] [fsh](https://github.com/mgramigna/tree-sitter-fsh) (maintained by @mgramigna)
+- [x] [fsharp](https://github.com/ionide/tree-sitter-fsharp) (maintained by @nsidorenco)
- [x] [func](https://github.com/amaanq/tree-sitter-func) (maintained by @amaanq)
- [x] [fusion](https://gitlab.com/jirgn/tree-sitter-fusion.git) (maintained by @jirgn)
- [x] [GAP system](https://github.com/gap-system/tree-sitter-gap) (maintained by @reiniscirpons)
diff --git a/lockfile.json b/lockfile.json
index 525cc8a3b..945d50e4a 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -197,6 +197,9 @@
"fsh": {
"revision": "fad2e175099a45efbc98f000cc196d3674cc45e0"
},
+ "fsharp": {
+ "revision": "f920105eec2d574eb911d7a25c81cdaa079a3f72"
+ },
"func": {
"revision": "f780ca55e65e7d7360d0229331763e16c452fc98"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index b975ec41c..22800a9bd 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -617,6 +617,15 @@ list.fsh = {
maintainers = { "@mgramigna" },
}
+list.fsharp = {
+ install_info = {
+ url = "https://github.com/ionide/tree-sitter-fsharp",
+ files = { "src/parser.c", "src/scanner.c" },
+ location = "fsharp",
+ },
+ maintainers = { "@nsidorenco" },
+}
+
list.func = {
install_info = {
url = "https://github.com/amaanq/tree-sitter-func",
diff --git a/queries/fsharp/highlights.scm b/queries/fsharp/highlights.scm
new file mode 100644
index 000000000..e400e3522
--- /dev/null
+++ b/queries/fsharp/highlights.scm
@@ -0,0 +1,411 @@
+[
+ (line_comment)
+ (block_comment)
+] @comment @spell
+
+((line_comment) @comment.documentation @spell
+ (#lua-match? @comment.documentation "^///"))
+
+(const
+ [
+ (_) @constant
+ (unit) @constant.builtin
+ ])
+
+(primary_constr_args
+ (_) @variable.parameter)
+
+(class_as_reference
+ (_) @variable.parameter.builtin)
+
+(type_name
+ type_name: (_) @type.definition)
+
+[
+ (_type)
+ (atomic_type)
+] @type
+
+(member_signature
+ .
+ (identifier) @function.method)
+
+(member_signature
+ (curried_spec
+ (arguments_spec
+ (argument_spec
+ (argument_name_spec
+ "?"? @character.special
+ name: (_) @variable.parameter)))))
+
+(union_type_case
+ (identifier) @constant)
+
+(rules
+ (rule
+ pattern: (_) @constant
+ block: (_)))
+
+(wildcard_pattern) @character.special
+
+(identifier_pattern
+ .
+ (_) @constant
+ .
+ (_) @variable)
+
+(optional_pattern
+ "?" @character.special)
+
+(fsi_directive_decl
+ .
+ (string) @module)
+
+(import_decl
+ .
+ (_) @module)
+
+(named_module
+ name: (_) @module)
+
+(namespace
+ name: (_) @module)
+
+(module_defn
+ (identifier) @module)
+
+(ce_expression
+ .
+ (_) @constant.macro)
+
+(field_initializer
+ field: (_) @property)
+
+(record_fields
+ (record_field
+ .
+ (identifier) @property))
+
+(value_declaration_left
+ .
+ (_) @variable)
+
+(function_declaration_left
+ .
+ (_) @function)
+
+(argument_patterns
+ [
+ (const)
+ (long_identifier)
+ (_pattern)
+ ] @variable.parameter)
+
+(argument_patterns
+ (typed_pattern
+ (_pattern) @variable.parameter
+ (_type) @type))
+
+(argument_patterns
+ (record_pattern
+ (field_pattern
+ .
+ (long_identifier) @variable.parameter)))
+
+(argument_patterns
+ (array_pattern
+ (_pattern)? @variable.parameter))
+
+(argument_patterns
+ (list_pattern
+ (_pattern)? @variable.parameter))
+
+((argument_patterns
+ (long_identifier
+ (identifier) @character.special))
+ (#lua-match? @character.special "^\_.*"))
+
+(member_defn
+ (method_or_prop_defn
+ [
+ (property_or_ident) @function
+ (property_or_ident
+ instance: (identifier) @variable.parameter.builtin
+ method: (identifier) @function.method)
+ ]
+ args: (_)* @variable.parameter))
+
+(dot_expression
+ .
+ (_) @variable.member
+ .
+ (_))
+
+(application_expression
+ .
+ (_) @function.call
+ .
+ (_) @variable)
+
+((infix_expression
+ .
+ (_)
+ .
+ (infix_op) @operator
+ .
+ (_) @function.call)
+ (#eq? @operator "|>"))
+
+((infix_expression
+ .
+ (_) @function.call
+ .
+ (infix_op) @operator
+ .
+ (_))
+ (#eq? @operator "<|"))
+
+[
+ (xint)
+ (int)
+ (int16)
+ (uint16)
+ (int32)
+ (uint32)
+ (int64)
+ (uint64)
+ (nativeint)
+ (unativeint)
+] @number
+
+[
+ (ieee32)
+ (ieee64)
+ (float)
+ (decimal)
+] @number.float
+
+(bool) @boolean
+
+[
+ (string)
+ (triple_quoted_string)
+ (verbatim_string)
+ (char)
+] @spell @string
+
+(compiler_directive_decl) @keyword.directive
+
+(preproc_line
+ "#line" @keyword.directive)
+
+(attribute
+ target: (identifier)? @keyword
+ (_type) @attribute)
+
+[
+ "("
+ ")"
+ "{"
+ "}"
+ ".["
+ "["
+ "]"
+ "[|"
+ "|]"
+ "{|"
+ "|}"
+] @punctuation.bracket
+
+[
+ "[<"
+ ">]"
+] @punctuation.special
+
+(format_string_eval
+ [
+ "{"
+ "}"
+ ] @punctuation.special)
+
+[
+ ","
+ ";"
+ ":"
+ "."
+] @punctuation.delimiter
+
+[
+ "|"
+ "="
+ ">"
+ "<"
+ "-"
+ "~"
+ "->"
+ "<-"
+ "&"
+ "&&"
+ "|"
+ "||"
+ ":>"
+ ":?>"
+ ".."
+ "*"
+ (infix_op)
+ (prefix_op)
+ (op_identifier)
+] @operator
+
+(generic_type
+ [
+ "<"
+ ">"
+ ] @punctuation.bracket)
+
+[
+ "if"
+ "then"
+ "else"
+ "elif"
+ "when"
+ "match"
+ "match!"
+] @keyword.conditional
+
+[
+ "and"
+ "or"
+ "not"
+ "upcast"
+ "downcast"
+] @keyword.operator
+
+[
+ "return"
+ "return!"
+ "yield"
+ "yield!"
+] @keyword.return
+
+[
+ "for"
+ "while"
+ "downto"
+ "to"
+] @keyword.repeat
+
+[
+ "open"
+ "#r"
+ "#load"
+] @keyword.import
+
+[
+ "abstract"
+ "delegate"
+ "static"
+ "inline"
+ "mutable"
+ "override"
+ "rec"
+ "global"
+ (access_modifier)
+] @keyword.modifier
+
+[
+ "let"
+ "let!"
+ "use"
+ "use!"
+ "member"
+] @keyword.function
+
+[
+ "enum"
+ "type"
+ "inherit"
+ "interface"
+ "and"
+ "class"
+ "struct"
+] @keyword.type
+
+((identifier) @keyword.exception
+ (#any-of? @keyword.exception "failwith" "failwithf" "raise" "reraise"))
+
+[
+ "as"
+ "assert"
+ "begin"
+ "end"
+ "done"
+ "default"
+ "in"
+ "do"
+ "do!"
+ "fun"
+ "function"
+ "get"
+ "set"
+ "lazy"
+ "new"
+ "of"
+ "struct"
+ "val"
+ "module"
+ "namespace"
+ "with"
+] @keyword
+
+[
+ "null"
+ (unit)
+] @constant.builtin
+
+(match_expression
+ "with" @keyword.conditional)
+
+(try_expression
+ [
+ "try"
+ "with"
+ "finally"
+ ] @keyword.exception)
+
+(application_expression
+ (unit) @function.call)
+
+((_type
+ (long_identifier
+ (identifier) @type.builtin))
+ (#any-of? @type.builtin
+ "bool" "byte" "sbyte" "int16" "uint16" "int" "uint" "int64" "uint64" "nativeint" "unativeint"
+ "decimal" "float" "double" "float32" "single" "char" "string" "unit"))
+
+(preproc_if
+ [
+ "#if" @keyword.directive
+ "#endif" @keyword.directive
+ ]
+ condition: (_)? @keyword.directive)
+
+(preproc_else
+ "#else" @keyword.directive)
+
+((identifier) @module.builtin
+ (#any-of? @module.builtin
+ "Array" "Async" "Directory" "File" "List" "Option" "Path" "Map" "Set" "Lazy" "Seq" "Task"
+ "String" "Result"))
+
+((value_declaration
+ (attributes
+ (attribute
+ (_type
+ (long_identifier
+ (identifier) @attribute))))
+ (function_or_value_defn
+ (value_declaration_left
+ .
+ (_) @constant)))
+ (#eq? @attribute "Literal"))
diff --git a/queries/fsharp/injections.scm b/queries/fsharp/injections.scm
new file mode 100644
index 000000000..211b263f3
--- /dev/null
+++ b/queries/fsharp/injections.scm
@@ -0,0 +1,11 @@
+([
+ (line_comment)
+ (block_comment_content)
+] @injection.content
+ (#set! injection.language "comment"))
+
+((line_comment) @injection.content
+ (#lua-match? @injection.content "^///")
+ (#offset! @injection.content 0 3 0 0)
+ (#set! injection.language "xml")
+ (#set! injection.combined))