Add OCaml support (#6929)
This pull request implements support for the [OCaml Language](https://ocaml.org/). ### Additions - [x] [tree-sitter-ocaml](https://github.com/tree-sitter/tree-sitter-ocaml) grammar - [x] Highlight, Indents, Outline queries - [x] A new file icon for .ml(i) files. Based on [ocaml/ocaml-logo](https://github.com/ocaml/ocaml-logo/blob/master/Colour/SVG/colour-transparent-icon.svg) - [x] LSP Integration with [ocaml-language-server](https://github.com/ocaml/ocaml-lsp) - [x] Completion Labels - [x] Symbol Labels ### Bug Fixes - [x] Improper parsing of LSP headers. ### Missing [will file a separate issue] - Documentation on completionItem, requires: `completionItem/resolve` with support for `documentation` as a provider. ### Screenshots <details><summary>Zed</summary> <img width="1800" alt="Screenshot 2024-02-01 at 03 33 20" src="https://github.com/zed-industries/zed/assets/69181766/e17c184e-203e-40c3-a08f-4de46226b79c"> </details> Release Notes: - Added OCaml Support ([#5316](https://github.com/zed-industries/zed/issues/5316)). > [!NOTE] > Partially completes #5316 > To complete #5316: > 1. addition of a reason tree-sitter grammar. > 2. opam/esy integration, however it may be better as it's own plugin.
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
("(" @open ")" @close)
|
||||
("{" @open "}" @close)
|
||||
("<" @open ">" @close)
|
||||
|
||||
("sig" @open "end" @close)
|
||||
("object" @open "end" @close)
|
||||
@@ -0,0 +1,13 @@
|
||||
name = "OCaml Interface"
|
||||
path_suffixes = ["mli"]
|
||||
block_comment = ["(* ", "*)"]
|
||||
autoclose_before = ";,=)}"
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "<", end = ">", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "sig", end = " end", close = true, newline = true },
|
||||
# HACK: For some reason `object` alone does not work
|
||||
{ start = "object ", end = "end", close = true, newline = true },
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
../ocaml/highlights.scm
|
||||
@@ -0,0 +1,21 @@
|
||||
[
|
||||
(type_binding)
|
||||
|
||||
(value_specification)
|
||||
(method_specification)
|
||||
|
||||
(external)
|
||||
(field_declaration)
|
||||
] @indent
|
||||
|
||||
(_ "<" ">" @end) @indent
|
||||
(_ "{" "}" @end) @indent
|
||||
(_ "(" ")" @end) @indent
|
||||
|
||||
(_ "object" @start "end" @end) @indent
|
||||
|
||||
(signature
|
||||
"sig" @start
|
||||
"end" @end) @indent
|
||||
|
||||
";;" @outdent
|
||||
@@ -0,0 +1,48 @@
|
||||
(module_type_definition
|
||||
"module" @context
|
||||
"type" @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(module_definition
|
||||
"module" @context
|
||||
(module_binding name: (_) @name)) @item
|
||||
|
||||
(type_definition
|
||||
"type" @context
|
||||
(type_binding name: (_) @name)) @item
|
||||
|
||||
(class_definition
|
||||
"class" @context
|
||||
(class_binding
|
||||
"virtual"? @context
|
||||
name: (_) @name)) @item
|
||||
|
||||
(class_type_definition
|
||||
"class" @context
|
||||
"type" @context
|
||||
(class_type_binding
|
||||
"virtual"? @context
|
||||
name: (_) @name)) @item
|
||||
|
||||
(instance_variable_definition
|
||||
"val" @context
|
||||
"method"? @context
|
||||
name: (_) @name) @item
|
||||
|
||||
(method_specification
|
||||
"method" @context
|
||||
"virtual"? @context
|
||||
(method_name) @name) @item
|
||||
|
||||
(value_specification
|
||||
"val" @context
|
||||
(value_name) @name) @item
|
||||
|
||||
(external
|
||||
"external" @context
|
||||
(value_name) @name) @item
|
||||
|
||||
(exception_definition
|
||||
"exception" @context
|
||||
(constructor_declaration
|
||||
(constructor_name) @name)) @item
|
||||
Reference in New Issue
Block a user