Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

changes to import monaco-lsp code into jupyterlab-monaco #12

Closed
wants to merge 17 commits into from

Conversation

juliandolby
Copy link
Collaborator

here is a minimal set of changes i needed to get jupyterlab-monaco to build and run while importing monaco-languageclient

@dhirschfeld
Copy link
Member

Excited to see this progress, especially in light of the upcoming release of the Python Language Server:

https://blogs.msdn.microsoft.com/pythonengineering/2018/07/18/introducing-the-python-language-server/

@juliandolby
Copy link
Collaborator Author

juliandolby commented Jul 24, 2018

I just merged the latest from jupyterlab-monaco, and pushed the merged code to my branch. I think that ought to update the pull request

@ellisonbg
Copy link

@juliandolby JupyterLab 0.33 is coming out this week. Can you update the PR to use that release of JupyterLab and then maybe we can merge this PR. @jasongrout do you think you will have a chance to help review this after the release?

@ellisonbg
Copy link

A few thoughts about LSP integration:

  • We probably want to have a jupyter notebook server extension that can act as a proxy between specific LSPs and the frontend, through a standard web socket protocol and URLs. I am thinking of new endpoints like /lsp/python or /lsp/R and something that can return the list of available and running LSP servers.
  • A new set of classes on jupyterlab services that has a well designed client to those endpoints and which returns the actual client LSP objects that Monaco needs.

Do we want to try to tackle some of these at the JupyterCon sprint on Saturday? I have meetings in NYC the following M/T, but might be available to stay around on W.

@juliandolby
Copy link
Collaborator Author

@ellisonbg My project is a fork of jupyterlab/monaco, and I am not sure how this connects to the overall jupyterlab. My version is slightly back, I think, for when I type

jupyter lab --version

at the command line, I get 0.32.1. I suspect this means I need to build jupyterlab itself from github to get the latest?

I definitely like the ideas for the Saturday sprint. This would allow us to interact with jupyter by simply configuring our analysis as an available server.

@juliandolby
Copy link
Collaborator Author

my latest commits have me reading the LSP server to use from system config. It is totally hackish right now, since I am adding my config item to an existing config entry. I have added a schema for the Monaco extension, but that does not seem to show up.

@juliandolby
Copy link
Collaborator Author

just merged to jupyterlab 0.33.10, and everything still seems to work. i have pushed those merges to the pull request.

@ellisonbg
Copy link

@juliandolby JupyterLab 0.34 is out now - do you think you will have time to update/test with 0.34 this before JupyterCon?

@juliandolby
Copy link
Collaborator Author

juliandolby commented Aug 18, 2018

@ellisonbg I just checked, and conda, which is how I install jupyterlab, only has jupyterlab 0.33.12 using conda-forge. The extension seems to work unchanged with 0.33.12

@ellisonbg
Copy link

ellisonbg commented Aug 18, 2018 via email

@blink1073
Copy link
Member

blink1073 commented Aug 18, 2018 via email

@blink1073
Copy link
Member

blink1073 commented Aug 19, 2018

@juliandolby, jupyterlab 0.34 is now available on conda-forge, and if you rebase you'll pick up #18.

@juliandolby
Copy link
Collaborator Author

Just updated to 0.34. I pushed the very few needed changes, just adjustments of dependency versions.

@blink1073
Copy link
Member

👍

@LeanderK
Copy link

How would the LSP-Server be used? How can I install (or start?) LSPs and connect to them?

@juliandolby
Copy link
Collaborator Author

There is now a 'Monaco Editor' tab in the advanced settings menu, which currently has the sole option 'lspServer'. You can set this to any WebSocket URL that talks to an LSP server. For example, my analysis server uses URLs of the following form: "ws://localhost:8080/com.ibm.wala.cast.lsp.tomcat/websocket". Hence, my Monaco config is as follows:

{
    // Monaco Editor
    // jupyterlab-monaco:plugin
    // Monaco editor settings.
    // ************************

    // [missing schema title]
    // The configuration specific to Monaco editors.
    "lspServer": "ws://localhost:8080/com.ibm.wala.cast.lsp.tomcat/websocket"
}

@gnestor
Copy link
Contributor

gnestor commented Sep 14, 2018

I'm bummed that I wasn't able to attend the JupyterCon sprints and work on this! Do we have any updates since then?

@juliandolby
Copy link
Collaborator Author

juliandolby commented Sep 14, 2018 via email

@jasongrout
Copy link
Contributor

Julian, I've just made you a collaborator, which I think means you should be able to merge things into this repo. Thanks again for working on all this!

@juliandolby
Copy link
Collaborator Author

juliandolby commented Sep 17, 2018

Thanks @jasongrout! I decided to get ambitious and try to update the module to use monaco-languageclient-0.9.0 from TypeFox. The good news is that minimal changes make the code compile and link. The bad news is that 'jupyter labextension link' then blows up with errors that I have never seen before.

I am attaching my output logs, in case anyone else has seen errors like this before, and knows what they mean.

My minimal code changes are on the branch lsp-mlc090 in my fork.

yarn_build.txt
yarn_install.txt
link.txt

@juliandolby
Copy link
Collaborator Author

A bit of hacking, and I have my updated code working in a Monaco demo, and it gets richer LSP information such as the 'related information'. the display looks as rich as vscode now. and it would all work in Jupyter too, but labextension link seems to hate the vscode engine.

@blink1073
Copy link
Member

@juliandolby, I just tried it locally and it installed fine, can you please try jupyter lab clean && jupyter lab build, it looks like the classic broken node_modules problem.

@juliandolby
Copy link
Collaborator Author

I still get the problem, even when i try the commands you suggested. I even tried a fresh git clone first to get a clean directory

git clone git@github.com:juliandolby/jupyterlab-monaco jupyterlab-monaco-mlc090
cd jupyterlab-monaco-mlc090/
git checkout lsp-mlc090
jupyter lab clean && jupyter lab build

@blink1073
Copy link
Member

What is node -v?

@juliandolby
Copy link
Collaborator Author

bash-3.2$ node -v
v8.12.0

@blink1073
Copy link
Member

What is your PATH?

@juliandolby
Copy link
Collaborator Author

bash-4.4$ echo $PATH 
/Users/dolby/anaconda3/bin:/Users/dolby/.opam/system/bin:/Users/dolby/.rvm/gems/ruby-2.4.1/bin:/Users/dolby/.rvm/gems/ruby-2.4.1@global/bin:/Users/dolby/.rvm/rubies/ruby-2.4.1/bin:/opt/local/bin:/opt/local/sbin:/Users/dolby/.opam/system/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/dolby/.rvm/bin:/opt/X11/bin:/Users/dolby/.rvm/bin:/Users/dolby/.rvm/bin
bash-4.4$ which node
/opt/local/bin/node
bash-4.4$ which jupyter
/Users/dolby/anaconda3/bin/jupyter
bash-4.4$ which yarn
/opt/local/bin/yarn

@blink1073
Copy link
Member

From /Users/dolby/anaconda3/share/jupyter/lab/staging/, what does yarn list --pattern=vscode give?

@juliandolby
Copy link
Collaborator Author

I get an error, I think:

bash-3.2$ pwd
/Users/dolby/anaconda3/share/jupyter/lab/staging
bash-3.2$ yarn list --pattern=vscode
yarn list v1.9.4
error No lockfile in this directory. Run `yarn install` to generate one.
info Visit https://yarnpkg.com/en/docs/cli/list for documentation about this command.

@blink1073
Copy link
Member

Ahh, I see, the error occurs when yarn is creating the lock file. Do you have any user or system level .npmrc or .yarnrc files?

@juliandolby
Copy link
Collaborator Author

There are no such files in my home directory, and I did not create any system ones knowingly.

One thing I notice in the staging area: the vscode module seems to be installed in /Users/dolby/anaconda3/share/jupyter/lab/staging/node_modules/ rather than /Users/dolby/anaconda3/share/jupyter/lab/staging/node_modules/jupyterlab-monaco/node_modules/, even though it is jupyterlab-monaco that asks for vscode. And then the jupyterlab-monaco post-install script is run in the latter and cannot find the install script.

@blink1073
Copy link
Member

Wow, this is the problem: ./vscode-base-languageclient/package.json:30: "prepublish": "node ./node_modules/vscode/bin/install && npm run compile", cf TypeFox/monaco-languageclient#89 (comment). yarn is hoisting that package in your case but not in mine, even though we are both using 1.9.4. I'm not sure what can be done. This is highly indicative of how tightly coupled monaco is to vscode still...

@juliandolby
Copy link
Collaborator Author

After a bit of searching on the Web, I found a promising-looking 'nohoist' option for package.json and managed to eliminate the first error. I am attaching the latest log of jupyter labextension link where you can see the error of being unable to find the install command goes away. I added the following to my package.json:

 "workspaces": {
      "nohoist": ["vscode"]
  },

It still dies in the final webpack, though, unable to find something else, so I wonder if it makes sense to try adding 'nohoist' in the overall jupyterlab package.json?

@juliandolby
Copy link
Collaborator Author

If it works for you, could you create the extension for JupyterLab so that I could test it?

@blink1073
Copy link
Member

You can test locally by updating this file: https://github.com/jupyterlab/jupyterlab/blob/master/jupyterlab/staging/package.json, which gets used in you application staging directory.

@choldgraf
Copy link

Just jumping in here to say thanks @juliandolby and @blink1073 for continuing to push on this <3

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants