Could someone knowledgeable in these matters list all the possible options? I understand there is julia-snail, julia-ts-mode, … But how do they fit together? What is hot and what is not?
Many thanks!
Could someone knowledgeable in these matters list all the possible options? I understand there is julia-snail, julia-ts-mode, … But how do they fit together? What is hot and what is not?
Many thanks!
Maybe a good start here?
This is a good illustration of my point. Several things are mentioned in that thread, with very little indication on how they fit together.
GitHub - JuliaEditorSupport/julia-emacs: Julia support in Emacs. sounds like the “official” (endorsed?) way of using Julia with Emacs, and curiously there is no mention of LSP or julia-repl…
Again, it would be nice to see how these things fit together. (Diagram?)
I would suggest using julia-mode
, instead of julia-ts-mode
. The julia-ts-mode
relies on Julia’s tree-sitter grammar which is not mature enough, in my opinion.
Julia-snail
is good and it also provides completion for the juila code, and it also provides elementary org-babel support. If you like to develop code with an REPL (i.e. sending some code to the REPL to execute), this might be the best option in Emacs.
I also recommend julia-vterm
and its sibling ob-julia-vterm
, if you use org-babel
. In my opinion, this is probably the best org-babel package for Julia so far. Org-mode has built-in julia babel support but the quality is not good, IMO.
At a basic level, emacs is just a text editor. julia-mode
is the major mode for editing julia files, this mainly means syntax highlighting. julia-ts-mode
is a replacement for that, which uses a tree sitter grammar rather than regex for parsing and syntax highlighting.
So far there are no “interactive” features yet.
On top of that there is julia-repl
, which defines how to launch a repl, shortcuts for activating environments, changing directories and so on. Also “sending” selections of your buffer o the repl (similar to shift+enter
in vs code).
On top of that, you could use lsp-julia as an minor mode integrating with the julia lsp server through lsp-mode
or eglot-jl
to integrate with julia lsp server through eglot-mode
.
I have no personal experience with julia-snail
, but afaik this is more of an alternative approach to julia-repl
, which launches a repl and a helper process in that repl. Your editor directly interacts with the running julia process you use for interactive work rather than a completely different julia process (LSP approach).
One feature that I really like about julia-snail is its ability to run more than one Julia REPL at a time. To make this work, you have to add a .dir-locals.el
file (which I leave out of version control) that tells julia-snail what port to use to communicate with the Julia process. Every julia-snail REPL needs its own port if you intend to run multiple REPLs. Here’s what that typically looks like for me.
((julia-mode . ((julia-snail-port . 10013)
(julia-snail-repl-buffer . "*julia CryptoMarketData*")
(julia-snail-extra-args . ("--project=~/src/github.com/g-gundam/CryptoMarketData.jl"
"-e 'cd(\"..\")'"
"-i"))
)))
I put a .dir-locals.el
file that looks like this at the root of every Julia project I work on. If you frequently move between 2 or more Julia projects in a session, this can be a huge help.
To force Emacs to reload .dir-locals.el
, I found a little interactive function that’ll do just that. This may come in handy while you figure things out.
;; force reload .dir-locals.el
;; https://emacs.stackexchange.com/a/13096/37580
(defun i/dir-locals-reload ()
"Reload .dir-locals.el for the current buffer."
(interactive)
(let ((enable-local-variables :all))
(hack-dir-local-variables-non-file-buffer)))
M-x i/dir-locals-reload
That port you specify for julia-snail is specific to your system, and I don’t think it’s relevant to anyone else who clones your repo. That’s why I choose to exclude .dir-locals.el
from version control.
I had no idea those existed. At a quick glance, it looks like it improves the org-mode experience for Julia code blocks significantly. I will definitely be trying these out.
If you’re brand new to Emacs, I would start with just julia-mode (i.e. julia-emacs), while working in the REPL, while you’re getting comfortable. If you configure JULIA_EDITOR
to emacs-client
, then @edit
and Ctrl-q
works great in the REPL.
Thanks!
I just mostly want to find out what the path forward is. Does one go with julia-mode + julia-repl-mode? Or julia-snail? Or julia-ts-mode? And where does lsp-mode come into it? Is it compatible with all the preceding?
Edit: And, there is also ESS-Julia, and eglot…
Edit 2: Further, there is lsp-julia.
This might help you understand what choices you have. I tried to summarize this thread’s contents visually, and I added a little extra info for julia-snail
and eglot
since I had a little extra knowledge on those topics that I haven’t posted in this thread.
You can input the following code at nomnoml to edit it.
[<start>] -> [<choice> syntax]
[<start>] -> [<choice> repl]
[<start>] -> [<choice> lsp]
[<choice> syntax] -> [julia-mode]
[<choice> syntax] -> [julia-ts-mode]
[<choice> repl] -> [julia-repl]
[<choice> repl] -> [julia-snail]
[julia-snail] -> [<choice> terminal]
[<choice> terminal] -> [eat]
[<choice> terminal] -> [vterm]
[<choice> repl] -> [julia-vterm] -> [ob-julia-vterm]
[julia-vterm] -> [vterm]
[<choice> lsp] -> [lsp-mode] -> [lsp-julia]
[<choice> lsp] -> [eglot] -> [eglot-jl]
[eglot] -> [breadcrumb]
[<choice> lsp] -> [lsp-bridge]
Every package mentioned should be available here.
Everyone is going to have a different preference, but my own is:
julia-snail also has lightweight code completion and navigation features without the heavy LSP dependence. For example, there are shortcuts Ctrl-Alt-i
for completion and Alt-.
for finding definition.
I sometimes use LSP through eglot. It takes like 1~2 minutes to start up. Otherwise it is good. Indeed, julia-snail
gives some functionalities of LSP, but not all of them. It all depends on what you want.
One of the maintainers of emacs-libvterm is the same person who gave a talk about Julia and Emacs at EmacsConf 2024 a few days ago.
Sorry, what does ctrl-q do? I thought it was for fixing terminal problems…?
I am now using vterm. It works well.
One thing to note about julia-snail: its REPL integration is module-aware. So when you tell it to update a function definition, it’ll do so in the right place. AFAIK no other Julia REPL integration does this. (Revise users probably don’t care about this very much.) That was the main reason I wrote Snail. That, and LSP didn’t exist when I started.
I have to admit I have no idea how to use eglot. I installed eglot-jl, but I get nothing: no completions, no information. I can’t even find which keybindings I should be using. The commands such as eglot-find-definition give me
Interesting. vterm
is arguably the best terminal emulator in Emacs ecosystem. I really hope they can integrate this terminal emulator into Emacs core.
Hi, you need to run eglot-jl-init
once in your Emacs session. Then you can run eglot
in a julia buffer, as described in the github page. The error you got I think is because the language server does not really start.
The julia LSP needs long time to start (see the bottom of eglot-jl
github page). I set eglot-connet-timeout
to 180, in order to start up the julia LSP. Yes, it takes like 2 mins on my machine to start…