jupyterlab-monaco icon indicating copy to clipboard operation
jupyterlab-monaco copied to clipboard

WIP: Monaco editor as IEditorServices

Open fcollonval opened this issue 6 years ago • 1 comments

This is the prolongation of #22 pushing for higher integration of monaco in Jupyterlab by replacing CodeMirror editor services.

This is highly experimental and raises questions.

LSP integration

  • LSP is based on a rootUri folder. In code editor (like vscode), the package folder is easily identified as such. But in the case of JupyterLab, the root folder of the server may be too broad compare to the folder of interest for the user. In particular in online configuration through JupyterHub, the root folder will be the user home folder that probably will contain multiple study sub folders. So should the user specified a specific folder as rootUri.
  • LSP tags content through file uri (see Location and TextDocumentIdentifier in the specification). But from what I saw, CodeEditor.IModel relies only on mimetypes. I think this is the reason why the current code is raising warning when multiple files are opened - as they are not related to uri. It is kind of lost; lacking context information from text sources. I presumed this could be improved by overwriting the FileEditor to have the LSP connection driven by the file opening/closing action rather than the onMimeTypeChanged event (https://github.com/jupyterlab/jupyterlab-monaco/blob/21e6ef9a343c19e625ca3b2709cbb798dcc9fb2c/src/editor.ts#L633) - but mimetype should still be handled. So presumably a better approach would be to add an optional path attribute in CodeEditor.IModel.
  • Kernel trouble - from my vscode experience, linter package should be installed in every Python environment. So the current approach using one websocket per language is probably too simple for handling multiple kernels of the same language.

CodeMirror suppression

The current implementation is far from complete. Main functions missing:

  • Event connections
  • Command execution
  • ~Undo/Redo connection~
  • Collaboration (marking text, updating value from realtime edition)
  • Editor options
  • What happen with the completer if there is a LSP server it becomes useless.

~Something odd~

~The content text is not available directly in the constructor. I had to introduce a timeout before loading it in the editor.~ corrected by https://github.com/jupyterlab/jupyterlab-monaco/pull/23/commits/34fedb167c0a6d2fb595c9316c5e522223c0010c

fcollonval avatar Nov 15 '18 19:11 fcollonval

This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there:

https://discourse.jupyter.org/t/create-extension-to-provide-custom-cell-editor/2819/2

meeseeksmachine avatar Dec 06 '19 21:12 meeseeksmachine