You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improving doc comments syntax highlighting in hovering #545
After #97 and #525 have been merged we can provider basic syntax highlight when hovering.
Current state
Apparently vscode does not detect ```res example as rescript syntax. In markdown highlighting works.
Proposal
Convert ```res example to rescript. This can be done on the client side `client/src/extension.ts`, but I'm more +1 to do it in analysis bin as it wouldn't affect other clients.
As the return is markdown we could create sections using the word after ```res?
Rust analyzer and ocaml lsp render with syntax highlights
rust_analyzer use ```rust
[Trace-5:26:15PM] Received response 'textDocument/hover - (14)' in 2ms.
Result: {
"contents": {
"kind": "markdown",
"value": "\n```rust\nstd::macros\n```\n\n```rust\nmacro_rules! println\n```\n\n---\n\nPrints to the standard output, with a newline.\n\nOn all platforms, the newline is the LINE FEED character (`\\n`/`U+000A`) alone\n(no additional CARRIAGE RETURN (`\\r`/`U+000D`)).\n\nUse the [`format`](https://doc.rust-lang.org/nightly/alloc/macros/macro.format.html) syntax to write data to the standard output.\nSee [`std::fmt`] for more information.\n\nUse `println!` only for the primary output of your program. Use\n[`eprintln`] instead to print error and progress messages.\n\n# Panics\n\nPanics if writing to [`io::stdout`] fails.\n\n# Examples\n\n```rust\nprintln!(); // prints just a newline\nprintln!(\"hello there!\");\nprintln!(\"format {} arguments\", \"some\");\n```"
},
"range": {
"start": {
"line": 16,
"character": 4
},
"end": {
"line": 16,
"character": 11
}
}
}
Activity
cristianoc commentedon Aug 4, 2022
CC @zth @ryyppy
ryyppy commentedon Aug 4, 2022
It doesn't detect "res" for syntax highlighting? what happens if it's called "rescript example"?
According to the markdown spec, the meta tags should not impact the language detection.
ryyppy commentedon Aug 4, 2022
It doesn't detect "res" for syntax highlighting? what happens if it's called "rescript example"?
According to the markdown spec, the meta tags should not impact the language detection.
aspeddro commentedon Aug 4, 2022
No.
Doesn't work either
textDocument/hoverresponse{ jsonrpc: '2.0', id: 52, result: { contents: '```rescript\n' + 'string => Js.Re.t\n' + '```\n' + '\n' + '\n' + ' Constructs a RegExp object (Js.Re.t) from a `string`.\n' + ' Regex literals `%re("/.../")` should generally be preferred, but `fromString`\n' + ' is useful when you need to dynamically construct a regex using strings,\n' + ' exactly like when you do so in JavaScript.\n' + '\n' + '```rescript example\n' + '\n' + ' let firstReScriptFileExtension = (filename, content) => {\n' + ' let result = Js.Re.fromString(filename ++ "\\.(res|resi)")->Js.Re.exec_(content)\n' + ' switch result {\n' + ' | Some(r) => Js.Nullable.toOption(Js.Re.captures(r)[1])\n' + ' | None => None\n' + ' }\n' + ' }\n' + '\n' + ' // outputs "res"\n' + ' firstReScriptFileExtension("School", "School.res School.resi Main.js School.bs.js")\n' + ' ```\n' } }Rust analyzer and ocaml lsp render with syntax highlights
rust_analyzer use
```rustocamllsp use
```ocamlMinnozz commentedon Aug 6, 2022
rescript-vscode/package.json
Lines 161 to 177 in 9d7573c
I can't find any reference to
reshere, should that name also be registered in some way?Minnozz commentedon Aug 6, 2022
Ah, here:
rescript-vscode/grammars/rescript.markdown.json
Line 12 in 9d7573c
aspeddro commentedon Nov 5, 2022
I've been exploring this issue using omd to format doc comments. Involves adding a dependency to the binary.