Using lsp-julia

I have tried to use lsp-julia from https://github.com/non-Jedi/lsp-julia. I installed everything as described, but I have an LSP[Disconnected] in my modeline.

If I try to M-x lsp, I get a prompt telling me that it is not part of a project. I am not sure how to proceed here. I am using Emacs 26.1 and Julia 1.2-dev.

1 Like

What I do is select the “Import project root : /path/to/cwd/” option proposed by M-x lsp. It seems to somehow remember from then (never asks again for the directory)

I’m not sure exactly what this does. I suspect only one server is launched for a “project”. And the directory set here is meant to be the root of the current “project”, i.e. all buffers/files open in the this directory will share the same lsp server.

Thanks. I pasted the output of

(kill-new (combine-and-quote-strings (lsp-julia--rls-command)))

to the command line and it turned out I had to install SymbolServer.

Now I have a

LSP[julia-ls:23615 status:starting]

modeline, that stays on status:starting, is this normal? I have no errors in the *julia-ls::stderr* buffer.

For reference/comparison, here is what this outputs for me:

$ julia --startup-file=no --history-file=no "-e using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance( stdin, stdout, false, \"/home/francois/.julia/environments/v1.0\", \"\",Dict()); server.runlinter = true; run(server);"
[ Info: Started symbol server
[ Info: StaticLint store set

and then it waits for input (and errors out if you input something incorrect, terminated by a blank line).


No, the modeline should display

LSP[julia-ls:23615]

after a little while.


Most of the time I don’t, either. The only times when I managed to have an error in the modeline were when I tried using advanced LSP features which the julia server does not implement. In these cases, the server did start, then crashed. Some info was available in the *julia-ls::stderr* buffer, and I was prompted (in the minibuffer) to restart the LSP server.

You should however find in *julia-ls::sterr* the same output as in the command line above:

[ Info: Started symbol server
[ Info: StaticLint store set

Here are two things that the LSP documentation mentions to help troubleshoot server issues:

  • M-xlsp-describe-session opens an *lsp-session* buffer showing some information about active servers and registered project.
  • M-:(setq lsp-print-io t): this makes lsp-mode trace all client-server exchanges in the *lsp-log* buffer

For me, a typical *lsp-log* buffer starts like this:

>>> julia-ls:5202 status:starting(async)
Content-Length: 1867

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
      [...]
  },
  "id": 1
}

<<<< julia-ls:5202 status:starting
{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
     [...]
  }
}

>>> julia-ls:5202(async)
Content-Length: 69

{
  "jsonrpc": "2.0",
  "method": "initialized",
  "params": {
  }
}

>>> julia-ls:5202(async)
Content-Length: 345

{
  "jsonrpc": "2.0",
  "method": "textDocument/didOpen",
  "params": {
       [...]
  }
}

<<<< julia-ls:5202
{
  "method": "client/registerCapability",
  "id": "278352324",
  "params": {
      [...]
  },
  "jsonrpc": "2.0"
}

>>> julia-ls:5202(async)
Content-Length: 62

{
  "jsonrpc": "2.0",
  "id": "278352324",
  "result": null
}
1 Like

Thanks for the debug help. This shows a single

Content-Length: 1964

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {

block in the log and nothing else, and

[ Info: Started symbol server

in the *julia-ls::sterr*, ie no StaticLint.

Can you please give me a

pkg> st --manifest

(private message is fine).

And do you get the message about StaticLint when starting the server in a regular console?


(v1.0) pkg> st --manifest
    Status `~/.julia/environments/v1.0/Manifest.toml`
  [dce04be8] ArgCheck v1.0.0
  [6e4b80f9] BenchmarkTools v0.4.1
  [9e28174c] BinDeps v0.8.10
  [b99e7846] BinaryProvider v0.5.3
  [e1450e63] BufferedStreams v1.0.0
  [00ebfdb7] CSTParser v0.5.2
  [159f3aea] Cairo v0.5.6
  [3da002f7] ColorTypes v0.7.5
  [5ae59095] Colors v0.9.5
  [34da2185] Compat v1.4.0
  [864edb3b] DataStructures v0.15.0
  [ffa9a821] DocumentFormat v0.3.0+ #master (https://github.com/ZacLN/DocumentFormat.jl.git)
  [5789e2e9] FileIO v1.0.5
  [53c48c17] FixedPointNumbers v0.5.3
  [1fa38f19] Format v0.7.2
  [59287772] Formatting v0.3.5
  [a2bd30eb] Graphics v0.4.0
  [4c0ca9eb] Gtk v0.16.4
  [27996c0f] GtkReactive v0.5.3
  [0862f596] HTTPClient v0.2.1
  [d9be37ee] Homebrew v0.7.1
  [54eb57ff] InteractiveCodeSearch v0.3.0
  [8197267c] IntervalSets v0.3.1
  [682c06a0] JSON v0.20.0
  [ba5e3d4b] Jive v0.1.6
  [5cadff95] JuliennedArrays v0.1.0
  [25c06242] Keys v0.5.0
  [2b0e0bc5] LanguageServer v0.5.1+ #master (https://github.com/JuliaEditorSupport/LanguageServer.jl.git)
  [50d2b5c4] Lazy v0.13.2
  [b27032c2] LibCURL v0.4.1
  [522f3ed2] LibExpat v0.5.0
  [2ec943e9] Libz v1.0.0
  [1914dd2f] MacroTools v0.4.4
  [e1d29d7a] Missings v0.4.0
  [77ba4419] NaNMath v0.3.2
  [bac558e1] OrderedCollections v1.0.2
  [c46f51b8] ProfileView v0.4.0
  [a223df75] Reactive v0.8.3
  [189a3867] Reexport v0.2.0
  [c5292f4c] ResumableFunctions v0.4.2
  [a89eb83c] Retest v0.1.0 #master (/home/francois/projets/git/Retest.jl)
  [295af30f] Revise v1.0.2
  [d5f540fe] RoundingIntegers v0.2.0
  [a2af1166] SortingAlgorithms v0.3.1
  [b3cc710f] StaticLint v0.1.1+ #master (https://github.com/ZacLN/StaticLint.jl.git)
  [2913bbd2] StatsBase v0.27.0
  [cf896787] SymbolServer v0.1.2+ #master (https://github.com/JuliaEditorSupport/SymbolServer.jl.git)
  [0796e94c] Tokenize v0.5.3
  [28d57a85] Transducers v0.1.0
  [30578b45] URIParser v0.4.0
  [b8865327] UnicodePlots v1.0.1
  [c17dfb99] WinRPM v0.4.2
  [2a0f44e3] Base64 
  [ade2ca70] Dates 
  [8bb1440f] DelimitedFiles 
  [8ba89e20] Distributed 
  [7b1f6079] FileWatching 
  [b77e0a4c] InteractiveUtils 
  [76f85450] LibGit2 
  [8f399da3] Libdl 
  [37e2e46d] LinearAlgebra 
  [56ddb016] Logging 
  [d6f4376e] Markdown 
  [a63ad114] Mmap 
  [44cfe95a] Pkg 
  [de0858da] Printf 
  [9abbd945] Profile 
  [3fa0cd96] REPL 
  [9a3f8284] Random 
  [ea8e919c] SHA 
  [9e88b42a] Serialization 
  [1a1011a3] SharedArrays 
  [6462fe0b] Sockets 
  [2f01184e] SparseArrays 
  [10745b16] Statistics 
  [8dfed614] Test 
  [cf7118a7] UUIDs 
  [4ec0a83e] Unicode 
1 Like

Thanks for the manifest, it helped me debug the issue.

The following (applied jointly) made LanguageServer work for me:

  1. pkg> add StaticLint#master LanguageServer#master SymbolServer#master
  2. using Julia v1.1.0 instead of master
1 Like

@Tamas_Papp, what is the exact command you used to run the server ?

M-x lsp

sorry I don’t get it, I’m using sublime text (on Windows) with LSP client, these are my configurations:

		"julials":
		{
			"command":
			[
				"julia",
				"--startup-file=no",
				"--history-file=no",
				"-e",
				"using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false, \"C:/Users/Youzer/.julia/environments/v1.1\", \"\",Dict()); server.runlinter = true; run(server);"
			],
			"enabled": true,
			"languageId": "julia",
			"scopes":
			[
				"source.julia"
			],
			"syntaxes":
			[
				"Packages/Julia/Julia.sublime-syntax"
			]
		},

LSP outputs:

LSP: starting ['julia', '--startup-file=no', '--history-file=no', '-e', 'using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false, "C:/Users/Youzer/.julia/environments/v1.0", "",Dict()); server.runlinter = true; run(server);']
LSP:  --> initialize
LSP: window 2 added session julials
server: [ Info: Started symbol server

and then does nothing.

In case this is unclear from the context, I am using Emacs.

But your problem may be related, have you tried

  1. adding all of the above 3 packages at #master,
  2. running
julia --startup-file=no --history-file=no "-e using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance( stdin, stdout, false, \"/home/francois/.julia/environments/v1.0\", \"\",Dict()); server.runlinter = true; run(server);"

from the command line?

yes it is clear, I was looking for help in my case.

yes

C:\Users\Youzer>julia --startup-file=no --history-file=no "-e using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false, \"C:/Users/Youzer/.julia/environments/v1.0\", \"\",Dict()); server.runlinter = true; run(server);"
[ Info: Started symbol server

and then it’s stuck

julia --startup-file=no --history-file=no "-e using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance( stdin, stdout, false, \"/home/francois/.julia/environments/v1.0\", \"\",Dict()); server.runlinter = true; run(server);"

Are you sure you are trying this with Julia 1.1.0? You seem to use 1.0 environment in this command. May I ask what your OS is? I cannot get the server working on 1.1.0. It works in 1.0.3 though.

The command you’re quoting comes from my environment. I’m using 1.0.3 as you guessed.

Tamas_papp seems to be using 1.1, though.

yes, I am. it works with 1.0.3. I opened an issue here:
https://github.com/JuliaEditorSupport/LanguageServer.jl/issues/331