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

Are there any ways to do auto code completion? #897

Open
Duality142857 opened this issue Nov 19, 2021 · 1 comment
Open

Are there any ways to do auto code completion? #897

Duality142857 opened this issue Nov 19, 2021 · 1 comment

Comments

@Duality142857
Copy link

like sth in scala shell, show possible completions?

@Quafadas
Copy link
Contributor

Quafadas commented Nov 22, 2021

I got this working in some form although it isn't perfect... YMMV. I'd welcome feedback if there was a better way.

TL;DR : Install metals server and leverage juypter LSP support...

Docs here;
https://jupyterlab-lsp.readthedocs.io/en/latest/Configuring.html

Docker snippets: cs = Coursier - great tool that is.

RUN /tmp/cs bootstrap almond:0.11.2 --scala 2.13.4 --no-default -i user -M almond.ScalaKernel --default=true --sources -o almond

RUN /tmp/cs bootstrap \
  --java-opt -XX:+UseG1GC \
  --java-opt -XX:+UseStringDeduplication  \
  --java-opt -Xss6m \
  --java-opt -Xms150m \
  org.scalameta:metals_2.12:0.10.5 -o metals -f

RUN chmod +x ./almond
RUN chmod +x ./metals
#COPY metals_lsp.json /opt/conda/etc/jupyter/jupyter_server_config.d/metals.json

# This should enable some logging which might make figuring out if it's working easier
#RUN touch ~/.cache/metals/lsp.trace.json # text editor
#RUN touch ~/.cache/metals/bsp.trace.json # build server
#RUN touch ~/.cache/metals/dap-server.trace.json # debug adapter
#RUN touch ~/.cache/metals/dap-client.trace.json # debug adapter

RUN ./almond --install --log info --metabrowse --variable-inspector --id scala2_13 --display-name "Scala 2.13" --global --jupyter-path /opt/conda/share/jupyter/kernels --extra-repository 

RUN rm -f almond

I have this in metals_lsp.json

{
    "LanguageServerManager": {
        "language_servers": {
            "metals": {
                "version": 2,
                "argv": ["/home/jovyan/metals"],
                "languages": ["scala"],
                "mime_types": ["text/x-scala"]
            }
        }
    }
}

And this in jupyter notebook config. I'm not sure which or both are needed in truth :-(...

c.LanguageServerManager.language_servers = {
    "scala": {
        # if installed as a binary
        "argv": ["/home/jovyan/metals"],
        "languages": ["scala"],
        "version": 2
    }
}

It took me some experimenting, but I did get there in the end. YMMV.

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

No branches or pull requests

2 participants