# Using lsp-julia

**URL:** <https://discourse.julialang.org/t/using-lsp-julia/20085>\
**Category:** Tooling\
**Tags:** emacs\
**Created:** [January 25, 2019, 12:03pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085 "2019-01-25T12:03:14Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 25, 2019, 12:03pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/1 "2019-01-25T12:03:14Z")

</div>

I have tried to use lsp-julia from [https://github.com/non-Jedi/lsp-julia](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.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 25, 2019, 3:31pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/2 "2019-01-25T15:31:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 26, 2019, 4:51pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/3 "2019-01-26T16:51:04Z")

</div>

Thanks. I pasted the output of

```nohighlight
(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

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 26, 2019, 9:03pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/4 "2019-01-26T21:03:34Z")

</div>

> [@Tamas\_Papp](#):
>
> (kill-new (combine-and-quote-strings (lsp-julia–rls-command)))

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

```julia
$ 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).

  

> [@Tamas\_Papp](#):
>
> the modeline stays on `status:starting` , is this normal?

No, the modeline should display

```julia
LSP[julia-ls:23615]

```

after a little while.

  

> [@Tamas\_Papp](#):
>
> I have no errors in the `*julia-ls::stderr*` buffer.

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:

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

```

  

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

- M-x`lsp-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
>>> 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
}

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 27, 2019, 10:05am UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/5 "2019-01-27T10:05:13Z")

</div>

> [@ffevotte](#):
>
> (setq lsp-print-io t)

Thanks for the debug help. This shows a single

```json
Content-Length: 1964

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

```

block in the log and nothing else, and

```julia
[ Info: Started symbol server

```

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

Can you please give me a

```juila
pkg> st --manifest

```

(private message is fine).

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [January 27, 2019, 8:17pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/6 "2019-01-27T20:17:09Z")

</div>

> [@Tamas\_Papp](#):
>
> no StaticLint.

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

  

> [@Tamas\_Papp](#):
>
> Can you please give me a
> 
> ```julia
> pkg> st --manifest
> 
> ```

```julia
(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 

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 28, 2019, 9:21am UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/7 "2019-01-28T09:21:19Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![AmjadHD](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AmjadHD](https://discourse.julialang.org/u/AmjadHD)\
**Post date:** [January 29, 2019, 12:12pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/8 "2019-01-29T12:12:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 29, 2019, 12:13pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/9 "2019-01-29T12:13:54Z")

</div>

M-x `lsp`

---

<div class="post-metadata">

**Author:** ![AmjadHD](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AmjadHD](https://discourse.julialang.org/u/AmjadHD)\
**Post date:** [January 29, 2019, 12:27pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/10 "2019-01-29T12:27:20Z")

</div>

sorry I don’t get it, I’m using sublime text (on Windows) with [LSP](https://github.com/tomv564/LSP) client, these are my configurations:

```json
		"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:

```julia
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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 29, 2019, 12:31pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/11 "2019-01-29T12:31:24Z")

</div>

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

```nohighlight
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?

---

<div class="post-metadata">

**Author:** ![AmjadHD](https://avatars.discourse-cdn.com/v4/letter/a/3d9bf3/32.png) [@AmjadHD](https://discourse.julialang.org/u/AmjadHD)\
**Post date:** [January 29, 2019, 12:45pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/12 "2019-01-29T12:45:39Z")

</div>

> [@Tamas\_Papp](#):
>
> In case this is unclear from the context, I am using Emacs.

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

> [@Tamas\_Papp](#):
>
> But your problem may be related, have you tried
> 
> 1. adding all of the above 3 packages at `#master` ,
> 2. running
> 
> ```julia
> 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

```julia
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

---

<div class="post-metadata">

**Author:** ![hckr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hckr/32/4836_2.png) [@hckr](https://discourse.julialang.org/u/hckr)\
**Post date:** [February 2, 2019, 11:45am UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/13 "2019-02-02T11:45:12Z")

</div>

> `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.

---

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [February 2, 2019, 12:39pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/14 "2019-02-02T12:39:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [February 2, 2019, 12:53pm UTC](https://discourse.julialang.org/t/using-lsp-julia/20085/15 "2019-02-02T12:53:10Z")

</div>

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