Skip to content

Commit

Permalink
Add fsharp language support (#7619)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaashyapan authored Jul 15, 2023
1 parent 86bf0e0 commit 2ace603
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 0 deletions.
1 change: 1 addition & 0 deletions book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
| fish |||| |
| forth || | | `forth-lsp` |
| fortran || || `fortls` |
| fsharp || | | `fsautocomplete` |
| gdscript |||| |
| git-attributes || | | |
| git-commit ||| | |
Expand Down
16 changes: 16 additions & 0 deletions languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ erlang-ls = { command = "erlang_ls" }
forc = { command = "forc", args = ["lsp"] }
forth-lsp = { command = "forth-lsp" }
fortls = { command = "fortls", args = ["--lowercase_intrinsics"] }
fsharp-ls = { command = "fsautocomplete", config = { AutomaticWorkspaceInit = true } }
gleam = { command = "gleam", args = ["lsp"] }
haskell-language-server = { command = "haskell-language-server-wrapper", args = ["--lsp"] }
idris2-lsp = { command = "idris2-lsp" }
Expand Down Expand Up @@ -2661,6 +2662,21 @@ indent = { tab-width = 3, unit = " " }
name = "forth"
source = { git = "https://github.com/alexanderbrevig/tree-sitter-forth", rev = "304ed77beb113e37af38b20ff14e3c37bf350d10" }

[[language]]
name = "fsharp"
scope = "source.fs"
roots = ["sln", "fsproj"]
injection-regex = "fsharp"
file-types = ["fs", "fsx"]
comment-token = "//"
indent = { tab-width = 4, unit = " " }
auto-format = true
language-servers = ["fsharp-ls"]

[[grammar]]
name = "fsharp"
source = { git = "https://github.com/kaashyapan/tree-sitter-fsharp", rev = "1b5a315e003024db6181744f1d25b8f525732665" }

[[language]]
name = "t32"
scope = "source.t32"
Expand Down
196 changes: 196 additions & 0 deletions runtime/queries/fsharp/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
;; ----------------------------------------------------------------------------
;; Literals and comments

[
(line_comment)
(block_comment)
(block_comment_content)
] @comment


;; ----------------------------------------------------------------------------
;; Punctuation

[
"("
")"
"{"
"}"
"["
"]"
"[|"
"|]"
"[<"
">]"
] @punctuation.bracket

[
","
";"
] @punctuation.delimiter

[
"|"
"="
">"
"<"
"-"
"~"
(infix_op)
(prefix_op)
(symbolic_op)
] @operator



(attribute) @attribute

[
"if"
"then"
"else"
"elif"
"when"
"match"
"match!"
"and"
"or"
"&&"
"||"
"then"
] @keyword.control.conditional

[
"return"
"return!"
] @keyword.control.return

[
"for"
"while"
] @keyword.control.return


[
"open"
"#r"
"#load"
] @keyword.control.import

[
"abstract"
"delegate"
"static"
"inline"
"internal"
"mutable"
"override"
"private"
"public"
"rec"
] @keyword.storage.modifier

[
"enum"
"let"
"let!"
"member"
"module"
"namespace"
"type"
] @keyword.storage

[
"as"
"assert"
"begin"
"default"
"do"
"do!"
"done"
"downcast"
"downto"
"end"
"event"
"field"
"finally"
"fun"
"function"
"get"
"global"
"inherit"
"interface"
"lazy"
"new"
"not"
"null"
"of"
"param"
"property"
"set"
"struct"
"try"
"upcast"
"use"
"use!"
"val"
"with"
"yield"
"yield!"
] @keyword

[
"true"
"false"
"unit"
] @constant.builtin

[
(type)
(const)
] @constant

[
(union_type_case)
(rules (rule (identifier_pattern)))
] @type.enum

(fsi_directive_decl (string) @namespace)

[
(import_decl (long_identifier))
(named_module (long_identifier))
(namespace (long_identifier))
(named_module
name: (long_identifier) )
(namespace
name: (long_identifier) )
] @namespace


(dot_expression
base: (long_identifier_or_op) @variable.other.member
field: (long_identifier_or_op) @function)

[
;;(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

[
(string)
(triple_quoted_string)
] @string

[
(int)
(int16)
(int32)
(int64)
(float)
(decimal)
] @constant.numeric


0 comments on commit 2ace603

Please sign in to comment.