question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Language server not starting for custom language type

See original GitHub issue

Hi. Firstly jupyter-lsp is an awesome project.

Description

I’m struggling to get my custom language server to actually start when editing my custom language.

What’s particularly strange is, it starts without an issue if I configure it to work with python. I just can’t get it to start when I’m using my custom kernel.

I wonder if you could help me work around this issue? I’ve looked at all the existing issues and get the impression there might be ambiguity around how languages are discovered (eg. https://github.com/krassowski/jupyterlab-lsp/issues/190, https://github.com/robocorp/robotframework-lsp/issues/13).

Thanks in advance.

Steps to reproduce

$ mkdir test

test/kernel.json:

{
 "argv": ["python", "-m",
          "testkernel", "-f",
          "{connection_file}"],
 "display_name": "test",
 "name": "test",
 "language": "test"
}
$ jupyter kernelspec install --user test

testkernel.py:

from ipykernel.kernelbase import Kernel

class TestKernel(Kernel):
    implementation = 'test'
    implementation_version = '2'
    banner = "Test banner"
    language_version = '2'
    language = 'test'
    language_info = {
                     'mimetype': 'text/x-test',
                     'name': 'test'
    }

    def do_execute(self, code, silent, store_history=True, user_expressions=None, allow_stdin=False):
        if not silent:
            stream_content = {'name': 'stdout', 'text': code}
            self.send_response(self.iopub_socket, 'stream', stream_content)

        return {'status': 'ok',
                'execution_count': self.execution_count,
                'payload': [],
                'user_expressions': {},
               }

if __name__ == '__main__':
    from ipykernel.kernelapp import IPKernelApp
    IPKernelApp.launch_instance(kernel_class=TestKernel)

~/.jupyter/jupyter_notebook_config.py (put any language server in the argv here if desired)

c.LanguageServerManager.language_servers = {
    "test-language-server": {
        "version": 2,
        "argv": ["touch", "language-server-started"],
        "languages": ["test"],
        "mime_types": [
            "text/x-test",
        ]
    }
}

Findings

When a new notebook is made with the Test kernel, the kernel works as expected. However the langauge server doesn’t start up.

Logs

jupyter lab --log-level=DEBUG

[D 09:32:58.078 LabApp] [lsp] The following Language Servers will be available: {
      "test-language-server": {
        "argv": [
          "touch",
          "language-server-started"
        ],
        "languages": [
          "test"
        ],
        "mime_types": [
          "text/x-test"
        ],
        "version": 2
      }
    }

[D 10:17:15.959 LabApp] Received kernel info: {'status': 'ok', 'protocol_version': '5.3', 'implementation': 'test', 'implementation_version': '2', 'language_info': {'mimetype': 'text/x-test', 'name': 'test'}, 'banner': 'Test banner', 'help_links': []}

Enironment

Running in latest scipy-notebook docker. Using conda for package management. jupyter-lsp 0.9.2
jupyterlab 2.2.8

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:28 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
mike-vogelcommented, Jan 25, 2021

Just after typing the above I realized I been just looking at the config files. I added the file_extension into the language_info returned by the Kernel and things connected.

1reaction
mikesligocommented, Oct 22, 2020

The language server is implemented in scala, using LSP4J as a base (similiar to scala meta https://github.com/krassowski/jupyterlab-lsp/issues/17). At the moment I only have hover implemented but it looks like it works well with jupyter-lsp.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom language server not starting #656 - neoclide/coc.nvim
I'm trying to setup a custom language service running on node. I installed the vim-node-rpc module globally using yarn, and created on entry...
Read more >
Language Server Extension Guide - Visual Studio Code
Learn how to create Language Servers to provide rich language features in Visual Studio Code.
Read more >
Example language server - vscode-docs
Language servers allow you to add your own validation logic to files open in VS Code. Typically you just validate programming languages. However...
Read more >
Implementing a Language Server…How Hard Can It Be??
If you have ever worked with an IDE for programming languages like Java, C# you have probably experience that how easy it is...
Read more >
VSCode Extension API: Programmatic features of custom ...
Each custom VSCode Notebook can support a number of languages. It is possible that the custom notebook is not setting the language properly ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found