Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Julia 1.0 Support #3

Closed
non-Jedi opened this issue Oct 13, 2018 · 9 comments
Closed

Julia 1.0 Support #3

non-Jedi opened this issue Oct 13, 2018 · 9 comments

Comments

@non-Jedi
Copy link
Collaborator

See MartinWolke#13

@gdkrmr
Copy link
Owner

gdkrmr commented Oct 13, 2018

👍

@gdkrmr
Copy link
Owner

gdkrmr commented Nov 17, 2018

I got it working with the latest master of LanguageServer.jl.

  • I think VSCode looks for "Project.toml", see here, this is not 100% water tight, it could also be "JuliaProject.toml" or "Manifest", I am not sure if the environment has to be initialized for LanguageServer to work.
  • I cannot test this on Windows.
    (defcustom lsp-julia-default-environment "~/.julia/environments/v1.0"
      "The path to the default environment."
      :type 'string
      :group 'lsp-julia)
    (defun lsp-julia--get-root ()
      (let ((dir (locate-dominating-file default-directory "Project.toml")))
        (if dir (expand-file-name dir)
          (expand-file-name lsp-julia-default-environment))))
    (defun lsp-julia--rls-command ()
      `(,lsp-julia-command
        ,@lsp-julia-flags
        ,(concat "-e using LanguageServer, Sockets, SymbolServer;"
                 " server = LanguageServer.LanguageServerInstance("
                 " stdin, stdout, false,"
                 " \"" (lsp-julia--get-root) "\","
                 " \"\", Dict());"
                 " server.runlinter = true;"
                 " run(server);")))

UPDATE: changed Manifest.toml to Project.toml

@benneti
Copy link

benneti commented Nov 18, 2018

@gdkrmr what is your setup exactly, I tried this (using spacemacs devel@26.1 , julia 1.0.2) by replacing the corresponding two lines in the LSP-julia.el file with your code and pointing the quelpa recipe from the julia layer to the changed file.
This gives me the following error in emacs:
~/.julia/environments/v1.0: lsp-julia has exited (exited abnormally with code 1)
Do you know how to get a more verbose error?
(I tried it without a precompiled version of LanguageServer.jl and with a precompiled sysimage by

  ;; use precompiled sysimage for julia-lsp
  (with-eval-after-load 'lsp-julia
    ;; use the precompiled version of LanguageServer
    (add-to-list 'lsp-julia-flags "-J ~/.julia/packages/PackageCompiler/BBtC7/sysimg/sys.so"))

)

@gdkrmr
Copy link
Owner

gdkrmr commented Nov 18, 2018

  • It's more than two lines.
  • On Windows/Mac the paths may not match, in this case edit the value of lsp-julia-default-environment.
  • Julia is the latest on the 1.0 release branch.
  • Emacs 26.1 with spacemacs develop and the julia layer installed.
  • lsp-julia is master installed from elpa and I added the code block above inside a (with-eval-after-load 'lsp-julia ...) statement in the user config function.
  • LanguageServer.jl is latest master with all its dependencies latest master (SymbolServer, CSTParser, DocumentFormat, StaticLint), I had some trouble with just using Pkg.update() and had to update all the packages by hand.

For debugging:

  • You can look in the *lsp-julia* buffer which should give you backtraces and error messages in case of crashes.
  • Try to run the server manually from a julia session.
  • In the code above I put Manifest.toml which requires the Project to be instantiated, else it falls back to the standard evironment, change it to Project.toml.

@benneti
Copy link

benneti commented Nov 18, 2018

Thank you very much, manually installing the dependencies as #master makes it now possible to launch, without the precompiled version of LanguageServer.
(As a note I meant two lines in the original lsp-julia.el)
Do you currently use the package with PackageCompile?
Because if I try to add the sys.so (as above) file lsp-server fails to start with this in the lsp-julia stderr buffer

ERROR: could not load library "/dir/to/current/file/ ~/.julia/packages/PackageCompiler/BBtC7/sysimg/sys.so"
/dir/to/current/file/ ~/.julia/packages/PackageCompiler/BBtC7/sysimg/sys.so: cannot open shared object file: No such file or directory

Process lsp-julia stderr finished

I do not understand why the path to the current file gets added here and from the shell I can start
julia -J ./.julia/packages/PackageCompiler/BBtC7/sysimg/sys.so --startup-file=no --history-file=no -e 'using LanguageServer, Sockets, SymbolServer; server = LanguageServer.LanguageServerInstance(stdin, stdout, false, "~/.julia/environments/v1.0", "", Dict()); server.runlinter = true; run(server);'.
(I added the ' to your code, too, because else it even fails in the shell)

EDIT:
Using (add-to-list 'lsp-julia-flags "--sysimage=~/.julia/packages/PackageCompiler/BBtC7/sysimg/sys.so")
instead of the -J flag works even without changing any of your code.

Another thing, does autocompletion work for you as intended?
If I type functi and then use autocompletion it gets replaced by

on ()
end

@gdkrmr
Copy link
Owner

gdkrmr commented Nov 18, 2018

Do you currently use the package with PackageCompile?

No, sorry, I cannot help you with that.

Another thing, does autocompletion work for you as intended?
If I type functi and then use autocompletion it gets replaced by

You are right, pressing RET gives me the same behavior. I always used TAB and it works fine but only completes the keyword and does not insert the braces and end. It appears as a "Keyword" in the autocompletion menu.

Is it working for you now?

@benneti
Copy link

benneti commented Nov 18, 2018

Yeah even with the comiled sysimage if one uses "--sysimage=" instead of "-J".
But it is really slow if you install more packages, I think the reason for this is that it tries to load all of them and it is only the case if one uses the precompiled package so the simple solution is to just not do this.

What do you mean with

It appears as a "Keyword" in the autocompletion menu.

?

@gdkrmr
Copy link
Owner

gdkrmr commented Nov 18, 2018

What do you mean with

It appears as a "Keyword" in the autocompletion menu.

screenshot_2018-11-18_21-51-55

I guess that this triggers some different behavior, i.e. creating the function skeleton.

@benneti
Copy link

benneti commented Nov 19, 2018

Ah indeed, the theme I use made the Keyword invisible as long as the line is the selected one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants