-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render hover documentation as Markdown in LSP #1559
Conversation
lsp/nls/src/requests/hover.rs
Outdated
MarkedString::String( | ||
meta.iter() | ||
.flat_map(|s| s.lines()) | ||
.map(|s| s.trim()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to trim the identation from code snippets, which is probably not intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, it seems like the desired behavior should be like that of the indoc!
macro which removes only the common indentation in the lines. Should I add the implementation for that macro, unindent, as a dependency, or make a seperate function for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since unindent
is in our dependency tree already for indoc
, using that seems like a reasonable thing to do 👍
lsp/nls/src/requests/hover.rs
Outdated
meta.iter() | ||
.map(|s| { | ||
s.lines() | ||
.map(|s| if s.is_empty() { " " } else { s }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be worth adding this information directly in the code, via a comment.
aca2ffb
to
87e8fd1
Compare
87e8fd1
to
5d2c8bf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! However, I'm a bit confused as to why we need to unindent here. The doc is parsed without the common indentation prefix (which I just checked by println!
the raw documentation of std.contract.apply
after parsing), that is, Nickel multiline strings should have the same effect as unindent already. Do you have any idea where does this indentation come from?
I'm |
Ah, |
Perfect, many thanks! |
* Render documentation as markdown in LSP * Use unindent crate to retain code indentation * Render contracts seperate from documentation * Remove usages of unindent * Remove unindent from `Cargo.lock` --------- Co-authored-by: BuildTools <[email protected]>
Renders hover documentation as markdown instead of plaintext in LSP
Before:
After: