Compatibility between Theia and the Julia VS Code extension

I discovered Theia as a possible alternative to VS code in this thread, and decided to give it a try.

It looks like a lot of features from the Julia VScode extension work out of the box, which is in itself an incredible achievement.

However, I keep getting crashes from the LanguageServer, with an output like the following:

[ Info: Starting the Julia Language Server
[ Info: Symbol server store is at '/home/theia/.theia/globalStorage/julialang.language-julia/symbolstorev2'.
[ Info: Received new data from Julia Symbol Server.
┌ Warning: Some Julia code in the VS Code extension crashed with
│   e = KeyError: key "line" not found
└ @ Main ~/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/error_handler.jl:5
ERROR: KeyError: key "line" not found
Stacktrace:
 [1] getindex at ./dict.jl:467 [inlined]
 [2] LanguageServer.Position(::Dict{String,Any}) at /home/theia/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/packages/JSONRPC/src/interface_def.jl:56
 [3] LanguageServer.VersionedTextDocumentPositionParams(::Dict{String,Any}) at /home/theia/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/packages/JSONRPC/src/interface_def.jl:56
 [4] dispatch_msg(::JSONRPC.JSONRPCEndpoint{Base.PipeEndpoint,Base.PipeEndpoint}, ::JSONRPC.MsgDispatcher, ::Dict{String,Any}) at /home/theia/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/packages/JSONRPC/src/typed.jl:64
 [5] run(::LanguageServerInstance) at /home/theia/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/packages/LanguageServer/src/languageserverinstance.jl:309
 [6] top-level scope at /home/theia/.theia/extensions/julialang.language-julia-1.0.6/extension/scripts/languageserver/main.jl:59
 [7] include(::Function, ::Module, ::String) at ./Base.jl:380
 [8] include(::Module, ::String) at ./Base.jl:368
 [9] exec_options(::Base.JLOptions) at ./client.jl:296
 [10] _start() at ./client.jl:506
[Info  - 9:14:38 AM] Connection to server got closed. Server will restart.

At first glance, this looks like a LSP problem, perhaps a mismatch between the protocol versions used by Theia and LanguageServer.jl. In any case, I’m not sure where to file an issue about this. I’m leaning towards filing an issue with Theia, but wanted to double check here beforehand:

  • has anyone tried using the Julia VS code extension with Theia? And perhaps encountered this problem before?
  • would anyone have more insight as to where this issue comes from?
3 Likes

Looks like Theia is serializing a vscode.Position as e.g.

{
    "_line": 8,
    "_character": 4
}

instead of the

{
    "line": 8,
    "character": 4
}

we expect and that VSCod[e/ium] uses.

So yes, this seems like a Theia issue to me. Feel free to ping me on the issue if you get around to opening one!

Edit: And an easy to figure this out is to set the Julia > Trace: Server setting to verbose and then open the Julia Language Server trace output.

3 Likes

Thanks, you’re absolutely right:

[Trace - 10:56:22 AM] Sending request 'julia/getModuleAt - (37)'.
Params: {
    "textDocument": {
        "uri": "file:///home/project/theia-jl/test.jl"
    },
    "version": 30,
    "position": {
        "_line": 11,
        "_character": 0
    }
}

Oddly enough, there are lots of requests for which the position is serialized as expected, e.g:

[Trace - 10:58:21 AM] Sending request 'textDocument/hover - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///home/project/theia-jl/test.jl"
    },
    "position": {
        "line": 7,
        "character": 3
    }
}

I’ll look into it a bit more, and file an issue with Theia, then. Thanks again!

There’s an easy answer to that: VersionedTextDocumentPositionParams isn’t part of the LSP (we defined that ourselves). You could argue that we should handle the serialization part ourselves as well, but imho this is something Theia should handle.

2 Likes

Thanks again!

I opened an issue with Theia:

3 Likes

I am curious as to the look-and-feel of Theia vs VS Code: the latter tends to be resource hungry and a bit sluggish (I am spoiled by Sublime Text). I suspect it is too much to expect for Theia to be less of a resource hog?

I feel like VS Code is getting heavier and more resource-hungry, which will worsen the long startup time issue of Julia over time.

The look-and-feel of Theia seems very similar to that of VS Code. In order to get more a objective / quantitative comparison, I tried measuring the memory footprint of both. It looked like Theia was a bit more lightweight than VS Code in this respect (550Mb vs 700Mb), but I’m not confident that my measurements are reliable enough to draw any meaningful conclusion.

2 Likes

I don’t see the connection, unless the computer is already so memory constrained to make it practically unusable for programming.