README.org
December 29, 2021 ยท View on GitHub
[[https://melpa.org/#/lsp-julia][file:https://melpa.org/packages/lsp-julia-badge.svg]] [[https://stable.melpa.org/#/lsp-julia][file:https://stable.melpa.org/packages/lsp-julia-badge.svg]]
- lsp-julia
Julia support for the [[https://github.com/emacs-lsp/lsp-mode][=lsp-mode=]] package using the [[https://github.com/JuliaEditorSupport/LanguageServer.jl][LanguageServer.jl]] package. For information on the features =lsp-mode= provides see their [[https://github.com/emacs-lsp/lsp-mode][git repository]].
/Julia version 1.7 or higher has to be in your path/
/This package is still under development./
** Installation
*** Installing the Julia Language Server
**** Included Language Server
lsp-julia installs LanguageServer.jl by default.
**** Change Language Server version
By default the newest Version of LanguageServer.jl is installed. To Change the
version, open Julia and initiate the Environment in the subdirectory
languageserver from the installation directory of lsp-julia. Then use
Julia's Pkg to change the installed version.
**** Using a Compiled LanguageServer.jl Image
Add the following to you config:
#+BEGIN_SRC emacs-lisp (setq lsp-julia-package-dir nil) (setq lsp-julia-flags `("-J/path/to/languageserver.so")) ;; (require 'lsp-julia) must come after this! #+END_SRC
Additionally because JIT compilation of LanguageServer.jl can cause a long delay
which may cause issues with lsp-mode, I recommend using [[https://github.com/JuliaLang/PackageCompiler.jl][PackageCompiler.jl]] to
AOT compile LanguageServer.jl into your julia image. Something like:
#+BEGIN_EXAMPLE julia julia> using Pkg julia> Pkg.add("PackageCompiler") julia> using PackageCompiler julia> create_sysimage(:LanguageServer, sysimage_path="/path/to/languageserver.so") #+END_EXAMPLE
See the documentation on PackageCompiler.jl for further usage details.
*** Installing =lsp-julia= **** quelpa It's currently easiest to install this package with quelpa. I'll see about getting this added to melpa soon enough.
#+BEGIN_SRC emacs-lisp (quelpa '(lsp-julia :fetcher github :repo "gdkrmr/lsp-julia" :files (:defaults "languageserver"))) #+END_SRC **** use-package #+BEGIN_SRC emacs-lisp (use-package lsp-julia :config (setq lsp-julia-default-environment "~/.julia/environments/v1.7")) #+END_SRC
*** Using =lsp-julia= with a julia major mode
After installing the major mode of your choice for editing Julia files ([[https://github.com/JuliaEditorSupport/julia-emacs][julia-mode]], [[https://ess.r-project.org/][ess]], etc.), add ='lsp-mode= to the hook for that major mode. For example, to use =lsp-julia= with ess, add the following to your =.emacs= file:
#+BEGIN_SRC emacs-lisp (add-hook 'ess-julia-mode-hook #'lsp-mode) #+END_SRC
Please don't hesitate to open an issue in case of problems or create a PR.