Eglot-jl无法对我导入的Julia包建立索引

编程语言 2026-07-11

Julia 1.12与我的.emacs配置一起使用,我把我的LanguageServer.jj和 SymbolServer.jl放在我的.../lsp-isolated目录中:

(use-package eglot-jl
  :after julia-mode
  :config
  (eglot-jl-init)
  (setq eglot-jl-language-server-project "~/.julia/environments/lsp-isolated")
)

(add-hook 'julia-mode-hook 'eglot-ensure)

(setq eglot-connect-timeout 1200)

然而,我没有成功让它识别我的包,eglot给出如下信息:

[jsonrpc] e[19:46:51.136] <-- $/progress {"method":"$/progress","params":{"token":"83b1829c-5d1d-4644-b5fc-afc5af7a5300","value":{"kind":"report","message":"Processing Graphs... (33%)"}},"jsonrpc":"2.0"}
[stderr]  [ Info: Processing Graphs... (33%)
[stderr]  nil
[stderr]  nil
[stderr]  nil
[stderr]  ERROR: LoadError: UndefVarError: `Graphs` not defined in `Main.SymbolServer.LoadingBay`
[stderr]  ERROR: LoadError: UndefVarError: `Graphs` not defined in `Main.SymbolServer.LoadingBay`
[stderr]  The binding may be too new: running in world age 39203, while current world is 44989.
[stderr]  The binding may be too new: running in world age 39203, while current world is 44989.
[stderr]  Hint: Graphs is loaded but not imported in the active module Main.
[stderr]  Stacktrace:
[stderr]  Stacktrace:

我的Project.toml包含以下这些包:

name = "GraphForManufacturing"
uuid = "dac46c34-b7fe-4314-b27c-54ba0df5eca0"
version = "0.1.0"
authors = ["msamiolo <[email protected]>"]

[deps]
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
LanguageServer = "2b0e0bc5-e4fd-59b4-8912-456d1b03d8d7"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MetaGraphsNext = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SymbolServer = "cf896787-08d5-524d-9de7-132aaa0cb996"

[compat]
Graphs = "1.14.0"
LanguageServer = "4.1.0"
LinearAlgebra = "1.12.0"
MetaGraphsNext = "0.8.0"
Printf = "1.11.0"
SymbolServer = "7.4.0"

解决方案

我找到了一个变通办法:如果使用Julia > 1.12.1,就使用不同的语言服务器。
我使用JETLS,我的Emacs配置就简单地变成如下:

(use-package julia-mode
  :ensure t
  :mode "\\.jl\\'")

(add-to-list 'exec-path "~/.julia/bin")

(with-eval-after-load 'eglot
  (add-to-list 'eglot-server-programs
               '(((julia-mode :language-id "julia")
                  (julia-ts-mode :language-id "julia"))
                 "jetls"
                 "serve"
                 "--socket"
                 :autoport)))

(add-hook 'julia-mode-hook #'eglot-ensure)

(setq eglot-connect-timeout 300       ;; Give Julia 5 minutes to start
      eglot-sync-connect 0            ;; Don't block the UI while connecting
      eglot-autoshutdown t)
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章