gcv / julia-snail

An Emacs development environment for Julia
GNU General Public License v3.0
231 stars 21 forks source link

formatter configuration issue? #141

Open just-walk opened 5 months ago

just-walk commented 5 months ago

I cannot seem to get JuliaFormatter to work in julia-snail.

My .dir-locals.el file has the line ((julia-mode . ((julia-snail-extensions . (repl-history formatter))))) But running C-c j f b on a buffer in the project gives Parsing error, formatting failed in the *Messages* buffer and

┌ Error: UndefVarError(:JuliaFormatter)
└ @ Main.JuliaSnail.Extensions.Formatter ~/dotfiles/emacs.d/elpa/julia-snail-20231219.417/extensions/formatter/Formatter.jl:42

in the corresponding REPL

In another project, I get the error

UndefVarError: `Formatter` not defined

eval_in_module(fully_qualified_module_name::Matrix{Symbol}, expr::Expr) at JuliaSnail.jl:217
(::Main.JuliaSnail.var"#30#36"{Sockets.TCPSocket})() at JuliaSnail.jl:913

Are these bugs, or am I missing something?

gcv commented 5 months ago

Are you using Julia 1.10? I managed to reproduce the problem once, but not again. It seems related to initialization and precompilation somehow. Try doing something like import JuliaFormatter at the REPL, see if that kicks off a precompilation. If it does, then quit the REPL, restart Snail, and try using the formatter extension again.

I'm having a hard time figuring out how I got this bug to happen because now that the latest version of the JuliaFormatter is installed in my environment, it started working.

just-walk commented 5 months ago

Yes, I'm using Julia 1.10. I just tried what you said, and it resolved the issue. I didn't appear to precompile, but it worked. Thanks!

Just so I understand, it's not necessary to import JuliaFormatter to a project normally. It's just that the package needed to loaded somewhere initially so that Julia would precompile it, and emacs would be able to call the executable. Is that right?

I did test it with another REPL where I didn't issue the import command, and it worked.

gcv commented 5 months ago

That's right. I think something happened in 1.10 with all the precompilation changes, and the way Snail loads extensions stopped working unless the dependency packages have all been precompiled. Or something like that. I'll keep this ticket open as a reminder to look into fixing this in the future.