Closed ablaom closed 4 years ago
Then a I open a .jl buffer (putting me into julia-mode). Running eglot gives this:
This looks like you're invoking eglot
from a buffer in emacs-lisp-mode
. Are you sure that julia-mode is active in the buffer?
eglot-jl-julia-command
is a variable rather than a function. But in this case, it's irrelevant--it's not the julia installation failing to be detected but eglot failing to use the julia language server.
Thanks for that!
Sorry, the message (from a julia buffer is much the same):
[eglot] Sorry, couldn't guess for `julia-mode'!
Enter program to execute (or <host>:<port>):
Could you confirm that you've actually run eglot-jl-int
in this emacs session? If so, what's the content of the eglot-server-programs
variable?
You were right, I hadn't realised I needed to redo elgot-jl-init. There was a problem with running eglot but an informative message explained I needed julia in PATH (which it isn't by default in a Mac install of julia).
After adding a version of julia to my PATH, and running the two commands again, I seem to have got things working!
Two questions:
How do I switch julia versions. With julia-repl mode, the solution is the following code in my emacs init.el:
(julia-repl-set-executable (getenv "JULIA_PATH"))
and I switch the JULIA_PATH between emacs sessions when I need to. Can I do something similar with eglot? Or maybe there is a better solution that does not require me to restart emacs?
Do I still need julia-repl to interact with the REPL from emacs, or does eglot provide this? What is the relationship between eglot-jl and julia-repl?
- How do I switch julia versions.
Something like this should work and fit your previous way of doing things:
(setq eglot-jl-julia-command (getenv "JULIA_PATH"))
- Do I still need julia-repl to interact with the REPL from emacs, or does eglot provide this? What is the relationship between eglot-jl and julia-repl?
I don't think there's any relationship between eglot-jl and julia-repl. AFAIK eglot-jl handles interactions between emacs and the Julia LSP language server. So you still need an other package to provide REPL interaction if you want it.
Thanks @ffevotte and @non-Jedi for your help!
Or maybe there is a better solution that does not require me to restart emacs?
Note that for either julia-repl
or eglot-jl
, you can switch the location of the julia executable without restarting julia:
For julia-repl:
(julia-repl-set-executable "/path/to/julia/executable")
Or for eglot-jl
(setq eglot-jl-julia-command "/path/to/julia/executable")
You could create interactive functions in emacs doing both of these and mirroring your jeX
bash aliases if you wanted.
Alternatively you can do this interactively for eglot-jl by invoking M-x customize-option
(probably there's also a customizable variable used for this purpose by julia-repl as well).
I'm still having some problems. Be great if someone can help out.
I have this in my init.el:
(setq eglot-jl-julia-command (getenv "JULIA_PATH"))
Then if I do M-x eglot-jl-init
and M-x eglot
everything works and I don't need to enter anything interactively. But it seems I have to do both of these every session, which is a pain. So I added these lines to my init.el:
(add-hook 'julia-mode-hook 'eglot-jl-ini)
(add-hook 'julia-mode-hook 'eglot-ensure)
But then booting up an emacs session with julia file gives the "[eglot] Couldn't guess for `julia-mode'!" error:
File mode specification error: (void-function eglot-jl-ini)
Error in post-command-hook (#[0 "\303\304\301\242\305#\210\300\306!\205 r\211q\210
?\205 \307\310\311 \")\207" [#<buffer MLJ.jl> (#0) eglot--managed-mode remove-hook post-command-hook nil buffer-live-p apply eglot--connect eglot--guess-contact] 4]): (error "[eglot] Couldn't guess for `julia-mode'!")
Looks like you've got a typo: eglot-jl-ini
instead of eglot-jl-init
. ;)
Thanks! All good now.
Have successfully installed the MELPA elglot-jl packages and run eglot-jl-init.
Then a I open a .jl buffer (putting me into julia-mode). Running
eglot
gives this:What should be my response? Note that I am a julia developer who needs to run multiple versions of julia. Previously, using julia-repl I controlled this with an
JULIA_PATH
env variable.My .bashrc has stuff like this:
On issue #17 I saw reference to
eglot-jl-julia-command
but this command does not to exist in my installation. There is onlyeglot-jl-init
.