Skip to content
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

Improve completer documentation panel: enable latex #506

Merged
merged 3 commits into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
## CHANGELOG

### `@krassowski/jupyterlab-lsp 3.3.1` (unreleased)

- bug fixes:

- LaTeX is now rendered in documentation panel of completer ([#506])
- completion response returned as plain text use pre tag to retain whitespace formatting ([#506])
- pre-formatted code font size was reduced to match font-size of the text in completion panel ([#506])

[#506]: https://github.com/krassowski/jupyterlab-lsp/pull/506

### `jupyter-lsp 1.1.3` (unreleased)

- features:

- add config for the classic notebook server extension ([#504])

[#504]: https://github.com/krassowski/jupyterlab-lsp/pull/504

### `@krassowski/jupyterlab-lsp 3.3.0` (2021-01-31)

- features:
Expand Down
5 changes: 5 additions & 0 deletions packages/completion-theme/style/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,8 @@
content: 'Loading...';
color: #7f7f7f;
}

/* a workaround for code being larger font size than text in markdown-rendered panel */
.jp-Completer-docpanel pre code {
font-size: 90%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export class CompletionLabIntegration implements IFeatureLabIntegration {
this.renderer = new LSPCompletionRenderer({
integrator: this,
markdownRenderer: markdown_renderer,
latexTypesetter: this.renderMimeRegistry.latexTypesetter,
console: console.scope('renderer')
});
this.renderer.activeChanged.connect(this.active_completion_changed, this);
Expand Down
13 changes: 11 additions & 2 deletions packages/jupyterlab-lsp/src/features/completion/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,29 @@ export class LSPCompletionRenderer

createDocumentationNode(item: LazyCompletionItem): HTMLElement {
if (item.isDocumentationMarkdown) {
let documentation = item.documentation;
this.options.markdownRenderer
.renderModel({
data: {
'text/markdown': item.documentation
'text/markdown': documentation
},
trusted: false,
metadata: {},
setData(options: IRenderMime.IMimeModel.ISetDataOptions) {
// empty
}
})
.then(() => {
if (this.options.latexTypesetter && documentation.includes('$')) {
this.options.latexTypesetter.typeset(
this.options.markdownRenderer.node
);
}
})
.catch(this.options.console.warn);
return this.options.markdownRenderer.node;
} else {
let node = document.createElement('div');
let node = document.createElement('pre');
node.textContent = item.documentation;
return node;
}
Expand All @@ -77,6 +85,7 @@ export namespace LSPCompletionRenderer {
export interface IOptions {
integrator: CompletionLabIntegration;
markdownRenderer: IRenderMime.IRenderer;
latexTypesetter?: IRenderMime.ILatexTypesetter;
console: ILSPLogConsole;
}
}
2 changes: 1 addition & 1 deletion python_packages/jupyter_lsp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
(
"etc/jupyter/jupyter_notebook_config.d",
["jupyter_lsp/etc/jupyter_notebook_config.json"],
)
),
],
)