Using LanguageServer.jl with eglot in emacs

Could you post the contents of the "EGLOT (Env/julia-mode) events buffer please?

Sure!

[client-request] (id:1) Fri Jun  5 16:49:51 2020:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
	  (:processId 3314088 :rootPath "/home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :rootUri "file:///home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :initializationOptions nil :capabilities
		      (:workspace
		       (:applyEdit t :executeCommand
				   (:dynamicRegistration :json-false)
				   :workspaceEdit
				   (:documentChanges :json-false)
				   :didChangeWatchedFiles
				   (:dynamicRegistration t)
				   :symbol
				   (:dynamicRegistration :json-false)
				   :configuration t)
		       :textDocument
		       (:synchronization
			(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
			:completion
			(:dynamicRegistration :json-false :completionItem
					      (:snippetSupport :json-false)
					      :contextSupport t)
			:hover
			(:dynamicRegistration :json-false :contentFormat
					      ["plaintext"])
			:signatureHelp
			(:dynamicRegistration :json-false :signatureInformation
					      (:parameterInformation
					       (:labelOffsetSupport t)))
			:references
			(:dynamicRegistration :json-false)
			:definition
			(:dynamicRegistration :json-false)
			:declaration
			(:dynamicRegistration :json-false)
			:implementation
			(:dynamicRegistration :json-false)
			:typeDefinition
			(:dynamicRegistration :json-false)
			:documentSymbol
			(:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
					      (:valueSet
					       [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
			:documentHighlight
			(:dynamicRegistration :json-false)
			:codeAction
			(:dynamicRegistration :json-false :codeActionLiteralSupport
					      (:codeActionKind
					       (:valueSet
						["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])))
			:formatting
			(:dynamicRegistration :json-false)
			:rangeFormatting
			(:dynamicRegistration :json-false)
			:rename
			(:dynamicRegistration :json-false)
			:publishDiagnostics
			(:relatedInformation :json-false))
		       :experimental nil)))
[stderr] nil
[stderr]    Updating registry at `~/.julia/registries/General`
[stderr] nil
[stderr]    Updating git-repo `https://github.com/JuliaRegistries/General.git`
[stderr] nil
[stderr]   Installed FilePathsBase ── v0.9.2
[stderr]   Installed StaticLint ───── v4.3.0
[stderr]   Installed LanguageServer ─ v3.0.0
[stderr]   Installed SymbolServer ─── v4.4.0
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr]  [1] include(::Module, ::String) at ./Base.jl:377
[stderr]  [2] include(::String) at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:1
[stderr]  [3] top-level scope at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr]  [4] include(::Module, ::String) at ./Base.jl:377
[stderr]  [5] top-level scope at none:2
[stderr]  [6] eval at ./boot.jl:331 [inlined]
[stderr]  [7] eval(::Expr) at ./client.jl:449
[stderr]  [8] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] top-level scope at none:2
[stderr]  [8] eval at ./boot.jl:331 [inlined]
[stderr]  [9] eval(::Expr) at ./client.jl:449
[stderr]  [10] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/LanguageServer/mpNvN/src/LanguageServer.jl:3
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr] nil
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] exec_options(::Base.JLOptions) at ./client.jl:288
[stderr]  [8] _start() at ./client.jl:484
[stderr] in expression starting at /home/dlakelan/.emacs.d/elpa/eglot-jl-20200521.1739/eglot-jl.jl:33
[internal] Fri Jun  5 16:50:16 2020:
(:message "Connection state changed" :change "exited abnormally with code 1\n")

----------b---y---e---b---y---e----------
[stderr] 
[stderr] 
[stderr] nil
[stderr] nil
[stderr] Process EGLOT (JuliaDataTutorials/julia-mode) stderr finished
[client-request] (id:1) Fri Jun  5 16:50:27 2020:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
	  (:processId 3314088 :rootPath "/home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :rootUri "file:///home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :initializationOptions nil :capabilities
		      (:workspace
		       (:applyEdit t :executeCommand
				   (:dynamicRegistration :json-false)
				   :workspaceEdit
				   (:documentChanges :json-false)
				   :didChangeWatchedFiles
				   (:dynamicRegistration t)
				   :symbol
				   (:dynamicRegistration :json-false)
				   :configuration t)
		       :textDocument
		       (:synchronization
			(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
			:completion
			(:dynamicRegistration :json-false :completionItem
					      (:snippetSupport :json-false)
					      :contextSupport t)
			:hover
			(:dynamicRegistration :json-false :contentFormat
					      ["plaintext"])
			:signatureHelp
			(:dynamicRegistration :json-false :signatureInformation
					      (:parameterInformation
					       (:labelOffsetSupport t)))
			:references
			(:dynamicRegistration :json-false)
			:definition
			(:dynamicRegistration :json-false)
			:declaration
			(:dynamicRegistration :json-false)
			:implementation
			(:dynamicRegistration :json-false)
			:typeDefinition
			(:dynamicRegistration :json-false)
			:documentSymbol
			(:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
					      (:valueSet
					       [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
			:documentHighlight
			(:dynamicRegistration :json-false)
			:codeAction
			(:dynamicRegistration :json-false :codeActionLiteralSupport
					      (:codeActionKind
					       (:valueSet
						["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])))
			:formatting
			(:dynamicRegistration :json-false)
			:rangeFormatting
			(:dynamicRegistration :json-false)
			:rename
			(:dynamicRegistration :json-false)
			:publishDiagnostics
			(:relatedInformation :json-false))
		       :experimental nil)))
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr]  [1] include(::Module, ::String) at ./Base.jl:377
[stderr]  [2] include(::String) at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:1
[stderr]  [3] top-level scope at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr]  [4] include(::Module, ::String) at ./Base.jl:377
[stderr]  [5] top-level scope at none:2
[stderr]  [6] eval at ./boot.jl:331 [inlined]
[stderr]  [7] eval(::Expr) at ./client.jl:449
[stderr]  [8] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] top-level scope at none:2
[stderr]  [7] top-level scope at none:2
[stderr]  [8] eval at ./boot.jl:331 [inlined]
[stderr]  [9] eval(::Expr) at ./client.jl:449
[stderr]  [10] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/LanguageServer/mpNvN/src/LanguageServer.jl:3
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr] nil
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] exec_options(::Base.JLOptions) at ./client.jl:288
[stderr]  [8] _start() at ./client.jl:484
[stderr] in expression starting at /home/dlakelan/.emacs.d/elpa/eglot-jl-20200521.1739/eglot-jl.jl:33
[internal] Fri Jun  5 16:50:34 2020:
(:message "Connection state changed" :change "exited abnormally with code 1\n")

----------b---y---e---b---y---e----------
[stderr] 
[stderr] 
[stderr] nil
[stderr] nil
[stderr] Process EGLOT (JuliaDataTutorials/julia-mode) stderr<1> finished
[client-request] (id:1) Fri Jun  5 16:51:45 2020:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
	  (:processId 3314088 :rootPath "/home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :rootUri "file:///home/dlakelan/Consulting/LakelandAppliedSciLLC/JuliaDataTutorials/" :initializationOptions nil :capabilities
		      (:workspace
		       (:applyEdit t :executeCommand
				   (:dynamicRegistration :json-false)
				   :workspaceEdit
				   (:documentChanges :json-false)
				   :didChangeWatchedFiles
				   (:dynamicRegistration t)
				   :symbol
				   (:dynamicRegistration :json-false)
				   :configuration t)
		       :textDocument
		       (:synchronization
			(:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
			:completion
			(:dynamicRegistration :json-false :completionItem
					      (:snippetSupport :json-false)
					      :contextSupport t)
			:hover
			(:dynamicRegistration :json-false :contentFormat
					      ["plaintext"])
			:signatureHelp
			(:dynamicRegistration :json-false :signatureInformation
					      (:parameterInformation
					       (:labelOffsetSupport t)))
			:references
			(:dynamicRegistration :json-false)
			:definition
			(:dynamicRegistration :json-false)
			:declaration
			(:dynamicRegistration :json-false)
			:implementation
			(:dynamicRegistration :json-false)
			:typeDefinition
			(:dynamicRegistration :json-false)
			:documentSymbol
			(:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
					      (:valueSet
					       [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
			:documentHighlight
			(:dynamicRegistration :json-false)
			:codeAction
			(:dynamicRegistration :json-false :codeActionLiteralSupport
					      (:codeActionKind
					       (:valueSet
						["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"])))
			:formatting
			(:dynamicRegistration :json-false)
			:rangeFormatting
			(:dynamicRegistration :json-false)
			:rename
			(:dynamicRegistration :json-false)
			:publishDiagnostics
			(:relatedInformation :json-false))
		       :experimental nil)))
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] ERROR: LoadError: could not open file /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/utils.jl
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr]  [1] include(::Module, ::String) at ./Base.jl:377
[stderr]  [2] include(::String) at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:1
[stderr]  [3] top-level scope at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr]  [4] include(::Module, ::String) at ./Base.jl:377
[stderr]  [5] top-level scope at none:2
[stderr]  [6] eval at ./boot.jl:331 [inlined]
[stderr]  [7] eval(::Expr) at ./client.jl:449
[stderr]  [8] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/DocumentFormat/sra7h/src/DocumentFormat.jl:198
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile DocumentFormat [ffa9a821-9c82-50df-894e-fbcef3ed31cd] to /home/dlakelan/.julia/compiled/v1.4/DocumentFormat/JgtLh_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] top-level scope at none:2
[stderr]  [8] eval at ./boot.jl:331 [inlined]
[stderr]  [9] eval(::Expr) at ./client.jl:449
[stderr]  [10] top-level scope at ./none:3
[stderr] in expression starting at /home/dlakelan/.julia/packages/LanguageServer/mpNvN/src/LanguageServer.jl:3
[stderr] nil
[stderr] nil
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] ERROR: LoadError: Failed to precompile LanguageServer [2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7] to /home/dlakelan/.julia/compiled/v1.4/LanguageServer/ite7n_V7OMW.ji.
[stderr] Stacktrace:
[stderr] Stacktrace:
[stderr] nil
[stderr] nil
[stderr] nil
[stderr]  [1] error(::String) at ./error.jl:33
[stderr]  [2] compilecache(::Base.PkgId, ::String) at ./loading.jl:1272
[stderr]  [3] _require(::Base.PkgId) at ./loading.jl:1029
[stderr]  [4] require(::Base.PkgId) at ./loading.jl:927
[stderr]  [5] require(::Module, ::Symbol) at ./loading.jl:922
[stderr]  [6] include(::Module, ::String) at ./Base.jl:377
[stderr]  [7] exec_options(::Base.JLOptions) at ./client.jl:288
[stderr]  [8] _start() at ./client.jl:484
[stderr] in expression starting at /home/dlakelan/.emacs.d/elpa/eglot-jl-20200521.1739/eglot-jl.jl:33
[internal] Fri Jun  5 16:51:50 2020:
(:message "Connection state changed" :change "exited abnormally with code 1\n")

----------b---y---e---b---y---e----------
[stderr] 
[stderr] 
[stderr] nil
[stderr] nil
[stderr] Process EGLOT (JuliaDataTutorials/julia-mode) stderr finished

I tested the sysimage branch on MacOS, it seems to work and indeed accelerate the startup time.

Not sure whether it matters but I tested it only on a mock project .

I am having some problems with the language server crashing on a real project (not related to this branch) which are probably related to LanguageServer.jl. I will try to open an issue. Is there a way to make eglot to not reconnect after a server crash? I would like to provide the relevant details from the event buffer but eglot just keeps reconnecting (and the server keeps crashing) swamping the event buffer with new info.

1 Like

Thanks for testing!

You can try to customize eglot-autoreconnect:

(setq eglot-autoreconnect nil)

Does that EGLOT events buffer give any clue as to what happened?

It looks like your installation of DocumentFormat.jl in your ~/.julia depot is corrupted in some way. Run rm -fr /home/dlakelan/.julia/packages/DocumentFormat.jl/sra7h and then try eglot again (with long eglot-connect-timeout) to see if it works.

1 Like

Yeah, it looks like that worked. Weird.

I’m now getting eglot features, but I’m not seeing the pop-up completions from company mode. Is that supported?

Should be, ya. There’s a gif of it working with company in the README. Might just be that the symbol server is still indexing (can take literal hours). When it’s finished, you should see something like [ Info: Received new data from Julia Symbol Server. in the events buffer.

1 Like

Yay, I can’t wait… or rather I will wait and then be excited. Will check back if it’s still not doing its thing by tomorrow.

When I use the following code

server = LanguageServerInstance(stdin, stdout, true, "/home/ossifragus/.julia/environments/v1.4", "", Dict())

I got the following error. Did I do anything wrong? Thanks.

ERROR: MethodError: Cannot convert an object of type String to an object of type Function
Closest candidates are:
convert(::Type{T}, ::T) where T at essentials.jl:171
Stacktrace:
[1] convert(::Type{Union{Nothing, Function}}, ::String) at ./some.jl:34
[2] JSONRPC.JSONRPCEndpoint(::Base.TTY, ::Base.TTY, ::String) at /home/ossifragus/.julia/packages/JSONRPC/1Kq3H/src/core.jl:61
[3] LanguageServerInstance(::Base.TTY, ::Base.TTY, ::Bool, ::String, ::String, ::Dict{Any,Any}) at /home/ossifragus/.julia/packages/LanguageServer/y1ebo/src/languageserverinstance.jl:66
[4] top-level scope at REPL[5]:1

Here is my version of your snipped:

using LanguageServer, SymbolServer
import Pkg

env_dir = joinpath(Pkg.envdir(), string("v", VERSION)[1:end-2])
server = LanguageServerInstance(stdin, stdout, true, env_dir, "", Dict())
run(server)

after the command server = ...
The error-message is:

ERROR: MethodError: no method matching JSONRPC.JSONRPCEndpoint(::Base.TTY, ::Base.TTY, ::Channel{Any}, ::Channel{Any}, ::Dict{String, Channel{Any}}, ::String, ::Symbol, ::Nothing, ::Nothing)
Closest candidates are:
  JSONRPC.JSONRPCEndpoint(::IOIn, ::IOOut, ::Channel{Any}, ::Channel{Any}, ::Dict{String, Channel{Any}}, ::Union{Nothing, Function}, ::Symbol, ::Union{Nothing, Task}, ::Union{Nothing, Task}) where {IOIn<:IO, IOOut<:IO} at C:\Users\stefanpofahl\.julia\packages\JSONRPC\P0G1p\src\core.jl:45
  JSONRPC.JSONRPCEndpoint(::Any, ::Any, ::Any) at C:\Users\stefanpofahl\.julia\packages\JSONRPC\P0G1p\src\core.jl:61
  JSONRPC.JSONRPCEndpoint(::Any, ::Any) at C:\Users\stefanpofahl\.julia\packages\JSONRPC\P0G1p\src\core.jl:61
Stacktrace:
 [1] JSONRPC.JSONRPCEndpoint(pipe_in::Base.TTY, pipe_out::Base.TTY, err_handler::String)
   @ JSONRPC C:\Users\stefanpofahl\.julia\packages\JSONRPC\P0G1p\src\core.jl:61
 [2] LanguageServerInstance(pipe_in::Base.TTY, pipe_out::Base.TTY, env_path::Bool, depot_path::String, err_handler::String, symserver_store_path::Dict{Any, Any}, download::Bool, symbolcache_upstream::Nothing) (repeats 2 times)
   @ LanguageServer C:\Users\stefanpofahl\.julia\packages\LanguageServer\0vsx2\src\languageserverinstance.jl:67
 [3] top-level scope
   @ REPL[7]:1

Can you reproduce my error? Julia version is: v1.8.3

I recommend using eglot-jl, and letting it download the server for you and keep it in its separate environment. I’ll share my configuration with you, @ellocco :


(require 'yasnippet)
(yas-reload-all)

(use-package vterm :ensure t)

(use-package julia-mode
    :mode "\\.jl\\'"
    :interpreter ("julia" . julia-mode)
    :init
    (setenv "JULIA_NUM_THREADS" "4")
    :config
    (add-hook 'julia-mode-hook 'company-mode)
    (add-hook 'julia-mode-hook #'yas-minor-mode)
    (add-hook 'julia-mode-hook 'julia-repl-mode)
    (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm)))
    (add-hook 'julia-mode-hook 'eglot-jl-init)
    (add-hook 'julia-mode-hook 'eglot-ensure)
    (add-hook 'julia-mode-hook (lambda () (setq eglot-connect-timeout 120)))
    (add-hook 'julia-mode-hook (lambda () (setq eglot-autoshutdown t)))
    )

I have only left lines that might be relevant for julia editing.
You might want to change

setq eglot-connect-timeout 120

To some ridiculously higher number instead of 120 for the first time you try editing a .jl file, to allow it time to download and install the server code. See here: GitHub - non-Jedi/eglot-jl: Wrapper for using Julia LanguageServer.jl with emacs eglot

I have an issue to install vterm, the problem is the same for Ubunutu 22.02 as well as for MS-Windows 10:

Error (use-package): vterm/:catch: Cannot open load file: No such file or directory, vterm-module

For vterm I found the following snipped on erickgnavar.github.io:

(use-package vterm
  :ensure t
  :defer t
  :hook
  (vterm-mode . (lambda ()
                  (setq-local show-trailing-whitespace nil)))
  :custom
  (vterm-module-cmake-args "-DUSE_SYSTEM_LIBVTERM=yes")
  (vterm-always-compile-module t))

Does this make sense?

Sorry, @ellocco, I had forgotten that using vterm wasn’t as plug-and-play as it seemed.
I forgot to mention that we need to compile vterm on our machine. And I believe that emacs must be compiled with the “with modules” option. I’m not sure if the version you have is compiled like that, but I thought it had become standard starting with 28 or similar.
Here’s a thread that mentions it, and where I based myself when I had exactly the same issue as yourself : Cannot open load file: No such file or directory, vterm-module · Issue #113 · akermu/emacs-libvterm · GitHub
I ended up compiling my own version of emacs, I’m on ubuntu 20.

For using vterm in general, check the readme of the repository for the installation procedure steps, minding what I said above about emacs: GitHub - akermu/emacs-libvterm: Emacs libvterm integration

If I remember correctly, we need to have all the dependencies needed for compilation, and then emacs itself will compile vterm for us on startup if we call the associated package in the config.
The configuration you posted seems to have an option for forcing recompilation everytime you startup - I personally would not include it, I don’t see the point. Once it compiled correctly for me, I never had any problems again. It also defers loading the package, I’m not sure if that is useful but it may be.

My problem was the missing package libtool-bin, the compiler complains about the missing package libtool even, if it is installed, but the error message does not mention the missing libtool-bin.
The current emacs was sufficient, it was not necessary to compile it myself.
MS-Windows:
I wonder if the eshell is an alternative to vterm on MS-Window OS.

I’m glad you managed to solve it nonetheless. I have no experience with using these in Windows so I can’t comment on that.

I am not sure if this is correct thread to post, but here goes:

I am switching from lsp-mode to using eglot and eglot-jl because I could not correctly configure lsp-mode with my current Julia project (e.g. using Pkg.activate("path/to/project")). While the README.md on the eglot-jl clearly states:

After installation, eglot-jl-init will load support for the Julia language server into eglot and project.el. If eglot-jl-init has been run in your emacs session, running eglot in a julia-mode buffer will start a language server for the Julia project to which the buffer belongs.

I still get linting errors that indicate Missing references. Does someone maybe have an idea why this is the case? If I look into the *EGLOT message buffer it appears to have chosen the correct project, but it still cannot find the modules in my /src/ directory.

Here is the relevant elisp:

(use-package eglot
    :ensure t)

(use-package eglot-jl
    :ensure t)

(use-package julia-mode
    :ensure t
    :mode "\\.jl\\'"
    :interpreter "julia"
    :config
    (eglot-jl-init)
    ;; Specify the hook that connects =eglot=
    :hook (julia-mode . eglot-ensure))

And, perhaps useful, an overview of my tree can be checked in this question, but basically boils down to:

Project.toml
|- src/
|--- Main.jl
|- examples/
|--- example.jl

The linting errors appear in example.jl with contents

using Main
Main.someFunction()

Note that the code does work inside a Julia REPL, so I believe it is not an issue of a wrong import/using statement.

1 Like

For those in the future that have the same problem, I solved it by making another Project.toml in the examples/ directory that contains the Main package, e.g.

examples/Projects.toml:

[deps]
Main = "whatever-hash-is-generated-by-julia"

and the Missing reference errors raised by flymake (or flycheck) disappear.

3 Likes

I try to go through discourse every few months and see if there’s any eglot-jl-related questions I missed. Apologies for not replying here sooner. This is a limitation of LanguageServer.jl which is discussed along with possible workarounds here:

1 Like