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:
parent
980d4f1003
commit
998f6cf80d
19 changed files with 784 additions and 9 deletions
|
@ -332,11 +332,36 @@ impl LanguageServer {
|
|||
};
|
||||
|
||||
let header = std::str::from_utf8(&buffer)?;
|
||||
let message_len: usize = header
|
||||
let mut segments = header.lines();
|
||||
|
||||
let message_len: usize = segments
|
||||
.next()
|
||||
.context("unable to find the first line of the LSP message header")?
|
||||
.strip_prefix(CONTENT_LEN_HEADER)
|
||||
.ok_or_else(|| anyhow!("invalid LSP message header {header:?}"))?
|
||||
.trim_end()
|
||||
.parse()?;
|
||||
.context("invalid LSP message header")?
|
||||
.parse()
|
||||
.with_context(|| {
|
||||
format!(
|
||||
"failed to parse Content-Length of LSP message header: {}",
|
||||
header
|
||||
)
|
||||
})?;
|
||||
|
||||
if let Some(second_segment) = segments.next() {
|
||||
match second_segment {
|
||||
"" => (), // Header end
|
||||
header_field if header_field.starts_with("Content-Type:") => {
|
||||
stdout.read_until(b'\n', &mut buffer).await?;
|
||||
}
|
||||
_ => {
|
||||
anyhow::bail!(
|
||||
"expected a Content-Type header field or a header ending CRLF, got {second_segment:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
anyhow::bail!("unable to find the second line of the LSP message header");
|
||||
}
|
||||
|
||||
buffer.resize(message_len, 0);
|
||||
stdout.read_exact(&mut buffer).await?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue