# Emacs: starting eglot server

**URL:** <https://discourse.julialang.org/t/emacs-starting-eglot-server/91311>\
**Category:** Tooling\
**Tags:** emacs\
**Created:** [December 5, 2022, 6:41pm UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311 "2022-12-05T18:41:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [December 5, 2022, 6:41pm UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311/1 "2022-12-05T18:41:19Z")

</div>

Dear all

I apologize if this has already been discussed elsewhere but I did not come up with a solution.

I installed the melpa version of eglot ` eglot-jl 20221128.1655` but it has some issues:

1. Each time I open a `.jl` file (either in a project or in an “isolated” file), to start the eglot server I need to always do a `M-x eglot-jl-init` and a `M-x eglot`. Then thinks works (almost see point 2). Is it possible to automatize the process such that each time I open a `.jl` file I automatically start the process without typing each time `M-x eglot-jl-init`, `M-x eglot`?

2. The autocomplete feature does not work. I understand that the first time should take some minutes, but even after half an hour, there are no positive signs.

Possibly relevant info about my installation. I am on Mac OS X and using Emacs for Mac last version (28.2).

> [https://emacsformacosx.com/](https://emacsformacosx.com/)

This is the portion of my `.emacs` setup (I do not entirely understand what it is doing: just blindly copied from snippets on this thread)

```julia
(require 'yasnippet)
(use-package julia-mode
  :mode "\\.jl\\'"
  :interpreter ("julia" . julia-mode)
  :init (setenv "JULIA_NUM_THREADS" "6")
  :config
  (add-hook 'julia-mode-hook 'julia-repl-mode)
  (add-hook 'julia-mode-hook 'eglot-jl-init)
  (add-hook 'julia-mode-hook 'eglot-ensure)
  (add-hook 'julia-mode-hook 'company-mode)
  (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm)))
  (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm)))
  (add-hook 'julia-mode-hook (lambda () (setq julia-repl-set-terminal-backend 'vterm))))

(use-package julia-repl)

(setq eglot-jl-julia-command "/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia")
(setq julia-repl-executable-records
      '((default "/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia")
	(master "/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia")))

```

---

<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:** [December 5, 2022, 9:48pm UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311/2 "2022-12-05T21:48:32Z")

</div>

> [@Andrea\_Pagnani](#):
>
> - Each time I open a `.jl` file (either in a project or in an “isolated” file), to start the eglot server I need to always do a `M-x eglot-jl-init` and a `M-x eglot`. Then thinks works (almost see point 2). Is it possible to automatize the process such that each time I open a `.jl` file I automatically start the process without typing each time `M-x eglot-jl-init`, `M-x eglot`?

I don’t immediately see any gross mistake in your `init.el` stanza; it should already start `eglot` automatically. Could please start a fresh Emacs, open a `.jl` file in it and look for a buffer called something like `*EGLOT (xxx/julia-mode) events*` ?

If that buffer exists, it means that `eglot` did start. In that case, it will be interesting to see the beginning of the contents of that buffer, between the first line (it should start with `[internal]`) and the first server reply (it should be marked by a line starting with `[server-reply] (id:1)`).

> [@Andrea\_Pagnani](#):
>
> The autocomplete feature does not work. I understand that the first time should take some minutes, but even after half an hour, there are no positive signs.

Hopefully the same `*EGLOT events*` buffer will have some info regarding this issue. Look for lines starting with `[stderr]`, especially if they look like julia error messages or stack traces.

Judging by the paths set in your init file, I’m assuming you use Julia 1.8?

---

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [December 6, 2022, 8:26am UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311/3 "2022-12-06T08:26:03Z")

</div>

Thanks, @ffevotte for your reply. Yes I am using julia 1.8.2. WRT to you questions:

1. If I start a `.jl` nothing happens although the file is correctly recognized as a julia file (highlighting colors etc … see image below)

> **snapshot of my emacs window**
>
> ![image](https://global.discourse-cdn.com/julialang/original/3X/5/b/5b174d0eea1eda49919a2742b89e10be63d4723b.png)

But there is no eglot buffer.

Below you can find the first part of the \*EGLOT buffer obtained after the usual `M-x eglot-jl-init` and `M-x eglot`. To wrap up I am not able to start automatically the process.

> **Output in \*EGLOT buffer**
>
> ```julia
> [internal] Tue Dec 6 09:06:49 2022:
> (:message "Running language server: (/Applications/Julia-1.8.app/Contents/Resources/julia/bin/julia --startup-file=no --project=/Users/pagnani/.emacs.d/elpa/eglot-jl-20221128.1655/ /Users/pagnani/.emacs.d/elpa/eglot-jl-20221128.1655/eglot-jl.jl /Users/pagnani/CODE/ArDCA/src/ )")
> [client-request] (id:1) Tue Dec 6 09:06:49 2022:
> (:jsonrpc "2.0" :id 1 :method "initialize" :params
> (:processId 1072 :rootPath "/Users/pagnani/CODE/ArDCA/" :rootUri "file:///Users/pagnani/CODE/ArDCA" :initializationOptions #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
> ())
> :capabilities
> (:workspace
> (:applyEdit t :executeCommand
> (:dynamicRegistration :json-false)
> :workspaceEdit
> (:documentChanges t)
> :didChangeWatchedFiles
> (:dynamicRegistration t)
> :symbol
> (:dynamicRegistration :json-false)
> :configuration t :workspaceFolders t)
> :textDocument
> (:synchronization
> (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
> :completion
> (:dynamicRegistration :json-false :completionItem
> (:snippetSupport :json-false :deprecatedSupport t :tagSupport
> (:valueSet
> [1]))
> :contextSupport t)
> :hover
> (:dynamicRegistration :json-false :contentFormat
> ["plaintext"])
> :signatureHelp
> (:dynamicRegistration :json-false :signatureInformation
> (:parameterInformation
> (:labelOffsetSupport t)
> :activeParameterSupport t))
> :references
> (:dynamicRegistration :json-false)
> :definition
> (:dynamicRegistration :json-false :linkSupport t)
> :declaration
> (:dynamicRegistration :json-false :linkSupport t)
> :implementation
> (:dynamicRegistration :json-false :linkSupport t)
> :typeDefinition
> (:dynamicRegistration :json-false :linkSupport t)
> :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"]))
> :isPreferredSupport t)
> :formatting
> (:dynamicRegistration :json-false)
> :rangeFormatting
> (:dynamicRegistration :json-false)
> :rename
> (:dynamicRegistration :json-false)
> :publishDiagnostics
> (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
> (:valueSet
> [1 2])))
> :experimental #s(hash-table size 1 test eql rehash-size 1.5 rehash-threshold 0.8125 data
> ()))
> :workspaceFolders
> [(:uri "file:///Users/pagnani/CODE/ArDCA" :name "~/CODE/ArDCA/")]))
> [stderr] No Changes to `~/.emacs.d/elpa/eglot-jl-20221128.1655/Project.toml`
> [stderr] No Changes to `~/.emacs.d/elpa/eglot-jl-20221128.1655/Manifest.toml`
> [stderr] [ Info: Environment successfully resolved
> [stderr] ┌ Info: Running language server
> [stderr] │ env = "/Users/pagnani/.emacs.d/elpa/eglot-jl-20221128.1655/Project.toml"
> [stderr] │ src_path = "/Users/pagnani/CODE/ArDCA/src/"
> [stderr] │ project_path = "/Users/pagnani/CODE/ArDCA"
> [stderr] └ depot_path = ""
> 
> ```

1. This is the output in the \*EGLOT buffer when I start typing (and hopefully autocompleting) some code

> **stderr line in \*EGLOT buffer**
>
> ```julia
> [stderr] [ Info: Successfully downloaded, scrubbed and saved ChainRules
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved LogExpFunctions
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved NLSolvers
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for MuladdMacro.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/M/MuladdMacro_46d2c3a1-f734-5fdb-9937-b9b9aeba4221/v0.2.4_cac9cc5499c25554cba55cd3c30543cff5ca4fab.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for JuliaInterpreter.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/J/JuliaInterpreter_aa1ae85d-cabe-5617-a682-6adf51b2e16a/v0.9.16_a79c4cf60cc7ddcdcc70acbb7216a5f9b4f8d188.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved Distributions
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved PositiveFactorizations
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved SpecialFunctions
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved SpecializeVarargs
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved ExprTools
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved DiffRules
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved ChainRulesCore
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for Compat.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/C/Compat_34da2185-b29b-5c13-b0c7-acf172513d20/v4.5.0_00a2cccc7f098ff3b66806862d275ca3db9e6e5a.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved StaticArrays
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved ForwardDiff2
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for RecipesBase.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/R/RecipesBase_3cdcf5f2-1ef4-517c-9805-6587b60abb01/v1.3.2_18c35ed630d7229c5584b945641a73ca83fb5213.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved FillArrays
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved StatsFuns
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for Cassette.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/C/Cassette_7057c7e9-c182-5462-911a-8362d720325c/v0.3.11_a70f220ea09ec61401745ff338f8fb340420165c.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved IterativeSolvers
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved Reexport
> [stderr] [ Info: Downloading caches...
> [stderr] ┌ Info: Couldn't retrieve cache file for CodeTracking.
> [stderr] └ exception = HTTP/1.1 404 Not Found while requesting https://www.julia-vscode.org/symbolcache/store/v1/packages/C/CodeTracking_da1fd8a2-8d9e-5ec2-8556-3022fb5608a2/v1.1.1_cc4bd91eba9cdbbb4df4746124c22c0832a460d6.tar.gz
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved StaticArraysCore
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved NaNMath
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved DocStringExtensions
> [stderr] [ Info: Downloading caches...
> [stderr] [ Info: Successfully downloaded, scrubbed and saved DiffResults
> [stderr] [ Info: All cache files downloaded.
> [stderr] [ Info: Loading QuadGK from cache...
> [stderr] [ Info: Loading DataStructures from cache...
> [stderr] ┌ Warning: Compat not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading InteractiveUtils from cache...
> [stderr] [ Info: Loading Markdown from cache...
> [stderr] [ Info: Loading Base64 from cache...
> [stderr] [ Info: Loading OrderedCollections from cache...
> [stderr] [ Info: Loading LinearAlgebra from cache...
> [stderr] ┌ Warning: libblastrampoline_jll not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading Libdl from cache...
> [stderr] [ Info: Loading ForwardDiff2 from cache...
> [stderr] [ Info: Loading StaticArrays from cache...
> [stderr] [ Info: Loading Statistics from cache...
> [stderr] [ Info: Loading SparseArrays from cache...
> [stderr] [ Info: Loading Random from cache...
> [stderr] [ Info: Loading Serialization from cache...
> [stderr] [ Info: Loading SHA from cache...
> [stderr] [ Info: Loading SpecializeVarargs from cache...
> [stderr] [ Info: Loading ExprTools from cache...
> [stderr] [ Info: Loading ChainRulesCore from cache...
> [stderr] ┌ Warning: MuladdMacro not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] ┌ Warning: Cassette not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading ChainRules from cache...
> [stderr] [ Info: Loading Requires from cache...
> [stderr] [ Info: Loading UUIDs from cache...
> [stderr] [ Info: Loading Reexport from cache...
> [stderr] [ Info: Loading Pkg from cache...
> [stderr] [ Info: Loading Downloads from cache...
> [stderr] [ Info: Loading LibCURL from cache...
> [stderr] [ Info: Loading MozillaCACerts_jll from cache...
> [stderr] [ Info: Loading LibCURL_jll from cache...
> [stderr] ┌ Warning: LibSSH2_jll not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] ┌ Warning: MbedTLS_jll not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading nghttp2_jll from cache...
> [stderr] [ Info: Loading Artifacts from cache...
> [stderr] ┌ Warning: Zlib_jll not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading NetworkOptions from cache...
> [stderr] [ Info: Loading FileWatching from cache...
> [stderr] [ Info: Loading ArgTools from cache...
> [stderr] [ Info: Loading Tar from cache...
> [stderr] [ Info: Loading REPL from cache...
> [stderr] [ Info: Loading Sockets from cache...
> [stderr] [ Info: Loading Unicode from cache...
> [stderr] [ Info: Loading LibGit2 from cache...
> [stderr] [ Info: Loading Printf from cache...
> [stderr] [ Info: Loading Dates from cache...
> [stderr] [ Info: Loading p7zip_jll from cache...
> [stderr] [ Info: Loading Logging from cache...
> [stderr] [ Info: Loading TOML from cache...
> [stderr] [ Info: Loading ForwardDiff from cache...
> [stderr] [ Info: Loading LogExpFunctions from cache...
> [stderr] [ Info: Loading IrrationalConstants from cache...
> [stderr] [ Info: Loading DocStringExtensions from cache...
> [stderr] [ Info: Loading DiffResults from cache...
> [stderr] [ Info: Loading StaticArraysCore from cache...
> [stderr] [ Info: Loading CommonSubexpressions from cache...
> [stderr] [ Info: Loading Test from cache...
> [stderr] [ Info: Loading MacroTools from cache...
> [stderr] [ Info: Loading DiffRules from cache...
> [stderr] [ Info: Loading SpecialFunctions from cache...
> [stderr] [ Info: Loading OpenSpecFun_jll from cache...
> [stderr] [ Info: Loading JLLWrappers from cache...
> [stderr] [ Info: Loading Preferences from cache...
> [stderr] [ Info: Loading CompilerSupportLibraries_jll from cache...
> [stderr] [ Info: Loading NaNMath from cache...
> [stderr] [ Info: Loading Distributions from cache...
> [stderr] [ Info: Loading PDMats from cache...
> [stderr] [ Info: Loading SuiteSparse from cache...
> [stderr] [ Info: Loading StatsBase from cache...
> [stderr] [ Info: Loading SortingAlgorithms from cache...
> [stderr] [ Info: Loading Missings from cache...
> [stderr] [ Info: Loading DataAPI from cache...
> [stderr] [ Info: Loading StatsAPI from cache...
> [stderr] [ Info: Loading StatsFuns from cache...
> [stderr] [ Info: Loading Rmath from cache...
> [stderr] [ Info: Loading Rmath_jll from cache...
> [stderr] [ Info: Loading FillArrays from cache...
> [stderr] [ Info: Loading NLSolvers from cache...
> [stderr] [ Info: Loading IterativeSolvers from cache...
> [stderr] ┌ Warning: RecipesBase not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading PositiveFactorizations from cache...
> [stderr] [ Info: Loading PyPlot from cache...
> [stderr] [ Info: Loading VersionParsing from cache...
> [stderr] [ Info: Loading Colors from cache...
> [stderr] [ Info: Loading ColorTypes from cache...
> [stderr] [ Info: Loading FixedPointNumbers from cache...
> [stderr] [ Info: Loading PyCall from cache...
> [stderr] [ Info: Loading Conda from cache...
> [stderr] [ Info: Loading JSON from cache...
> [stderr] [ Info: Loading Parsers from cache...
> [stderr] [ Info: Loading SnoopPrecompile from cache...
> [stderr] [ Info: Loading Mmap from cache...
> [stderr] [ Info: Loading LaTeXStrings from cache...
> [stderr] [ Info: Loading Revise from cache...
> [stderr] [ Info: Loading LoweredCodeUtils from cache...
> [stderr] ┌ Warning: JuliaInterpreter not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading Distributed from cache...
> [stderr] ┌ Warning: CodeTracking not stored on disc
> [stderr] └ @ SymbolServer ~/.julia/packages/SymbolServer/LMSFX/src/SymbolServer.jl:247
> [stderr] [ Info: Loading BenchmarkTools from cache...
> [stderr] [ Info: Loading Profile from cache...
> [stderr] [ Info: Received new data from Julia Symbol Server.
> [server-notification] Tue Dec 6 09:18:07 2022:
> (:method "textDocument/publishDiagnostics" :params
> 
> ```

Thanks a lot for your help

A

---

<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:** [December 6, 2022, 8:47am UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311/4 "2022-12-06T08:47:29Z")

</div>

Try running manually in your newly opened julia-mode buffer:

1. `M-x eglot-jl-init`
2. `M-x eglot`
3. `M-x company-mode`

If that fixes autocompletion, then it means the problem entirely comes from things not starting automatically like they should.

  

Now to investigate why things are not automatic, take a look at the value of the julia mode hook:

C-hv`julia-mode-hook`RET

---

<div class="post-metadata">

**Author:** ![Andrea\_Pagnani](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andrea_pagnani/32/3136_2.png) [@Andrea\_Pagnani](https://discourse.julialang.org/u/Andrea_Pagnani)\
**Post date:** [December 6, 2022, 10:55am UTC](https://discourse.julialang.org/t/emacs-starting-eglot-server/91311/5 "2022-12-06T10:55:57Z")

</div>

Thanks @ffevotte … now everything works

I am ashamed to tell you that I realized I did not install `company`. That somehow screwed up the whole auto-loading thing. Now everything works smoothly.

Sorry for the noise.

A
