lang/julia: improve lsp support (#4012)
* lang/julia: include lsp-julia w/o language server Use nonrecursive clone to get lsp-julia without bundled LanguageServer.jl (plus dependencies) and include instructions in the README on how to install the language server (bundled or otherwise). * lang/julia: add checks for julia +lsp in doctor Add two checks, both only for when the +lsp feature is enabled: - Check if (:tools lsp) is selected - Check if LanguageServer.jl is installed * lang/julia: indicate SymbolServer.jl as dependency It is itself a dependency of LanguageServer.jl, but it's necessary to add it separately in order to do `using SymbolServer`. * tools/lsp: add julia language server to list * lang/julia: add eglot support using eglot-jl Forcing eglot-jl to not install its own LanguageServer.jl is a bit of a hack though. * lang/julia: make timeout increase buffer-local Suggestion by @benneti to use `setq-local` instead of `setq` to prevent a timeout increase in non-Julia eglot buffers. * Fix issues Co-authored-by: Henrik Lissner <henrik@lissner.net>
This commit is contained in:
parent
88e18fc7c1
commit
ba0f791b05
6 changed files with 109 additions and 26 deletions
|
@ -118,7 +118,7 @@ Modules that bring support for a language or group of languages to Emacs.
|
||||||
+ java =+meghanada +eclim +lsp= - TODO
|
+ java =+meghanada +eclim +lsp= - TODO
|
||||||
+ [[file:../modules/lang/javascript/README.org][javascript]] =+lsp= - JavaScript, TypeScript, and CoffeeScript support
|
+ [[file:../modules/lang/javascript/README.org][javascript]] =+lsp= - JavaScript, TypeScript, and CoffeeScript support
|
||||||
+ [[file:../modules/lang/json/README.org][json]] =+lsp= - TODO
|
+ [[file:../modules/lang/json/README.org][json]] =+lsp= - TODO
|
||||||
+ julia =+lsp= - TODO
|
+ [[file:../modules/lang/julia/README.org][julia]] =+lsp= - TODO
|
||||||
+ kotlin =+lsp+= - TODO
|
+ kotlin =+lsp+= - TODO
|
||||||
+ [[file:../modules/lang/latex/README.org][latex]] =+latexmk +cdlatex +fold +lsp= - TODO
|
+ [[file:../modules/lang/latex/README.org][latex]] =+latexmk +cdlatex +fold +lsp= - TODO
|
||||||
+ lean - TODO
|
+ lean - TODO
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#+TITLE: lang/julia
|
#+TITLE: lang/julia
|
||||||
#+DATE: April 8, 2020
|
#+DATE: April 8, 2020
|
||||||
#+SINCE: {replace with next tagged release version}
|
#+SINCE: v1.3
|
||||||
#+STARTUP: inlineimages nofold
|
#+STARTUP: inlineimages nofold
|
||||||
|
|
||||||
* Table of Contents :TOC_3:noexport:
|
* Table of Contents :TOC_3:noexport:
|
||||||
|
@ -9,47 +9,97 @@
|
||||||
- [[#plugins][Plugins]]
|
- [[#plugins][Plugins]]
|
||||||
- [[#prerequisites][Prerequisites]]
|
- [[#prerequisites][Prerequisites]]
|
||||||
- [[#language-server][Language Server]]
|
- [[#language-server][Language Server]]
|
||||||
|
- [[#lsp-julia][~lsp-julia~]]
|
||||||
|
- [[#eglot-jl][~eglot-jl~]]
|
||||||
- [[#features][Features]]
|
- [[#features][Features]]
|
||||||
- [[#language-server-1][Language Server]]
|
- [[#language-server-1][Language Server]]
|
||||||
- [[#configuration][Configuration]]
|
- [[#configuration][Configuration]]
|
||||||
|
- [[#change-the-default-environment-for-the-julia-language-server][Change the default environment for the Julia language server]]
|
||||||
|
|
||||||
* Description
|
* Description
|
||||||
Adds Julia support to Doom Emacs
|
This module adds support for [[https://julialang.org/][the Julia language]] to Doom Emacs.
|
||||||
|
|
||||||
+ Syntax highlighting and latex symbols from ~julia-mode~
|
+ Syntax highlighting and latex symbols from ~julia-mode~
|
||||||
+ REPL integration from ~julia-repl~
|
+ REPL integration from ~julia-repl~
|
||||||
+ Code completion and syntax checking, requires ~:tools lsp~ and ~+lsp~
|
+ Code completion and syntax checking, requires ~:tools lsp~ and ~+lsp~
|
||||||
|
|
||||||
** Module Flags
|
** Module Flags
|
||||||
+ =+lsp= Language Server Protocol support
|
+ =+lsp= Enable LSP server support.
|
||||||
|
|
||||||
** Plugins
|
** Plugins
|
||||||
+ [[https://github.com/tpapp/julia-repl][julia-mode]]
|
+ [[https://github.com/tpapp/julia-repl][julia-mode]]
|
||||||
+ [[https://github.com/JuliaEditorSupport/julia-emacs/][julia-repl]]
|
+ [[https://github.com/JuliaEditorSupport/julia-emacs/][julia-repl]]
|
||||||
+ =+lsp= and =:tools lsp=
|
+ =+lsp= and =:tools lsp=
|
||||||
+ [[https://github.com/non-jedi/lsp-julia][lsp-julia]]*
|
+ [[https://github.com/non-jedi/lsp-julia][lsp-julia]]
|
||||||
+ [[https://github.com/emacs-lsp/lsp-mode][lsp]]
|
+ [[https://github.com/emacs-lsp/lsp-mode][lsp]]
|
||||||
|
+ =+lsp= and =:tools lsp +eglot=
|
||||||
|
+ [[https://github.com/non-jedi/eglot-jl][eglot-jl]]
|
||||||
|
+ [[https://github.com/joaotavora/eglot][eglot]]
|
||||||
|
|
||||||
* Prerequisites
|
* Prerequisites
|
||||||
This module has no direct prerequisites.
|
This module requires =julia= and an language server if =+lsp= is enabled.
|
||||||
|
|
||||||
** Language Server
|
** Language Server
|
||||||
|
~+lsp~ requires ~LanguageServer.jl~ and ~SymbolServer.jl~. The =lsp-julia= and
|
||||||
|
=eglot-jl= packages both come bundled with their own versions of these servers,
|
||||||
|
which is used by default. If you're happy with that, no further configuration is
|
||||||
|
necessary.
|
||||||
|
|
||||||
~+lsp~ requires the a manual installation of ~lsp-julia~ as it comes with a
|
However, to use your own installation you will need to install then configure
|
||||||
packaged version of ~LanguageServer.jl~ and its dependencies.
|
them. To install them, execute these commands in a Julia REPL:
|
||||||
|
|
||||||
|
#+BEGIN_SRC julia
|
||||||
|
using Pkg
|
||||||
|
Pkg.add("LanguageServer")
|
||||||
|
Pkg.add("SymbolServer")
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
Then configure =lsp-julia= or =eglot-jl= depending on whether you have enabled
|
||||||
|
=:tools lsp= or =:tools (lsp +eglot)=, respectively:
|
||||||
|
|
||||||
|
*** ~lsp-julia~
|
||||||
|
To instruct =lsp-julia= not to use the built-in package:
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
#+BEGIN_SRC elisp
|
||||||
;; ~/.doom.d/packages.el
|
;; ~/.doom.d/config.el
|
||||||
(package! lsp-julia :recipe (:host github :repo "non-jedi/lsp-julia"))
|
(setq lsp-julia-package-dir nil)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
To find your installation of ~LanguageServer.jl~, ~eglot-jl~ needs to know the
|
||||||
|
environment in which it is installed. This is set to v1.0 by default as it is
|
||||||
|
the current LTS:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** ~eglot-jl~
|
||||||
|
To find your installation of ~LanguageServer.jl~, ~eglot-jl~ must know the
|
||||||
|
environment in which it is installed. This is set to v1.0 by default as it is
|
||||||
|
the current LTS:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
;; ~/.doom.d/config.el
|
||||||
|
(setq eglot-jl-language-server-project "~/.julia/environments/v1.0")
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
But to let ~eglot-jl~ use the environment bundled with it, set it to
|
||||||
|
~eglot-jl-base~ instead:
|
||||||
|
|
||||||
|
#+BEGIN_SRC elisp
|
||||||
|
;; ~/.doom.d/config.el
|
||||||
|
(after! eglot-jl
|
||||||
|
(setq eglot-jl-language-server-project eglot-jl-base))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
* Features
|
* Features
|
||||||
# An in-depth list of features, how to use them, and their dependencies.
|
|
||||||
** Language Server
|
** Language Server
|
||||||
~+lsp~ adds code completion, syntax checking, formatting and other ~lsp-mode~
|
~+lsp~ adds code completion, syntax checking, formatting and other ~lsp-mode~ or
|
||||||
features. This requires a manual installation of ~lsp-julia~ as it bundles
|
~eglot~ features. It requires ~LanguageServer.jl~, the installation of which is
|
||||||
~LanguageServer.jl~ and its dependencies.
|
described above.
|
||||||
|
|
||||||
* Configuration
|
* Configuration
|
||||||
|
** Change the default environment for the Julia language server
|
||||||
~lsp-julia~ requires a variable be set for the Julia environment. This is set to
|
~lsp-julia~ requires a variable be set for the Julia environment. This is set to
|
||||||
v1.0 by default as it is the current LTS.
|
v1.0 by default as it is the current LTS.
|
||||||
|
|
||||||
|
@ -57,11 +107,3 @@ v1.0 by default as it is the current LTS.
|
||||||
;; ~/.doom.d/config.el
|
;; ~/.doom.d/config.el
|
||||||
(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
|
(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
|
||||||
If you would like to use your own installation of ~LanguageServer.jl~, put the
|
|
||||||
following in your personal ~config.el~.
|
|
||||||
|
|
||||||
#+BEGIN_SRC elisp
|
|
||||||
;; ~/.doom.d/config.el
|
|
||||||
(setq lsp-julia-package-dir nil)
|
|
||||||
#+END_SRC
|
|
||||||
|
|
|
@ -65,10 +65,26 @@
|
||||||
(term-set-escape-char ?\C-c)))
|
(term-set-escape-char ?\C-c)))
|
||||||
|
|
||||||
|
|
||||||
|
(when (featurep! +lsp)
|
||||||
|
(add-hook 'julia-mode-local-vars-hook #'lsp!))
|
||||||
|
|
||||||
|
|
||||||
(use-package! lsp-julia
|
(use-package! lsp-julia
|
||||||
:when (featurep! +lsp)
|
:when (featurep! +lsp)
|
||||||
|
:unless (featurep! :tools lsp +eglot)
|
||||||
:after lsp-mode
|
:after lsp-mode
|
||||||
:preface
|
:preface
|
||||||
(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
|
(setq lsp-julia-default-environment "~/.julia/environments/v1.0"))
|
||||||
(when (featurep! +lsp)
|
|
||||||
(add-hook 'julia-mode-local-vars-hook #'lsp!)))
|
|
||||||
|
(use-package! eglot-jl
|
||||||
|
:when (featurep! +lsp)
|
||||||
|
:when (featurep! :tools lsp +eglot)
|
||||||
|
:after eglot
|
||||||
|
:preface
|
||||||
|
;; Prevent auto-install of LanguageServer.jl
|
||||||
|
(setq eglot-jl-language-server-project "~/.julia/environments/v1.0")
|
||||||
|
:init
|
||||||
|
;; Prevent timeout while installing LanguageServer.jl
|
||||||
|
(setq-hook! 'julia-mode-hook eglot-connect-timeout (max eglot-connect-timeout 60))
|
||||||
|
:config (eglot-jl-init))
|
||||||
|
|
19
modules/lang/julia/doctor.el
Normal file
19
modules/lang/julia/doctor.el
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
;;; lang/julia/doctor.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
(assert! (or (not (featurep! +lsp))
|
||||||
|
(featurep! :tools lsp))
|
||||||
|
"This module requires (:tools lsp)")
|
||||||
|
|
||||||
|
(when (featurep! +lsp)
|
||||||
|
(let ((args
|
||||||
|
(cond ((require 'eglot-jl nil t)
|
||||||
|
`(,eglot-jl-julia-command
|
||||||
|
,(concat "--project=" eglot-jl-language-server-project)
|
||||||
|
,@eglot-jl-julia-flags
|
||||||
|
"-e" "empty!(LOAD_PATH); push!(LOAD_PATH, \"@\"); using LanguageServer, SymbolServer"))
|
||||||
|
((require 'lsp-julia nil t)
|
||||||
|
`(,lsp-julia-command
|
||||||
|
,@lsp-julia-flags
|
||||||
|
"-e" "using LanguageServer, SymbolServer")))))
|
||||||
|
(unless (zerop (car (apply #'doom-call-process args)))
|
||||||
|
(warn! "Couldn't find LanguageServer.jl and/or SymbolServer.jl"))))
|
|
@ -3,3 +3,8 @@
|
||||||
|
|
||||||
(package! julia-mode :pin "8ea90c7927f6d87a291cfb0216f34dacf43c722e")
|
(package! julia-mode :pin "8ea90c7927f6d87a291cfb0216f34dacf43c722e")
|
||||||
(package! julia-repl :pin "7ce38a9caf2a9c105afe66f464a2f30e816d69f3")
|
(package! julia-repl :pin "7ce38a9caf2a9c105afe66f464a2f30e816d69f3")
|
||||||
|
|
||||||
|
(when (featurep! +lsp)
|
||||||
|
(if (featurep! :tools lsp +eglot)
|
||||||
|
(package! eglot-jl :pin "84cff9d6ef1643f3eac6c9d620cc1e380a9847d9")
|
||||||
|
(package! lsp-julia :recipe (:nonrecursive t) :pin "c523c250c4bd2777203101ab417e9b7312472f46")))
|
||||||
|
|
|
@ -45,6 +45,7 @@ As of this writing, this is the state of LSP support in Doom Emacs:
|
||||||
| [[../../lang/haskell/README.org][:lang haskell]] | haskell-mode | haskell-language-server |
|
| [[../../lang/haskell/README.org][:lang haskell]] | haskell-mode | haskell-language-server |
|
||||||
| [[../../lang/java/README.org][:lang java]] | java-mode | lsp-java |
|
| [[../../lang/java/README.org][:lang java]] | java-mode | lsp-java |
|
||||||
| [[../../lang/javascript/README.org][:lang javascript]] | js2-mode, rjsx-mode, typescript-mode | typescript-language-server |
|
| [[../../lang/javascript/README.org][:lang javascript]] | js2-mode, rjsx-mode, typescript-mode | typescript-language-server |
|
||||||
|
| [[../../lang/julia/README.org][:lang julia]] | julia-mode | LanguageServer.jl |
|
||||||
| [[../../lang/ocaml/README.org][:lang ocaml]] | tuareg-mode | ocaml-language-server |
|
| [[../../lang/ocaml/README.org][:lang ocaml]] | tuareg-mode | ocaml-language-server |
|
||||||
| [[../../lang/php/README.org][:lang php]] | php-mode | php-language-server |
|
| [[../../lang/php/README.org][:lang php]] | php-mode | php-language-server |
|
||||||
| [[../../lang/python/README.org][:lang python]] | python-mode | lsp-python-ms |
|
| [[../../lang/python/README.org][:lang python]] | python-mode | lsp-python-ms |
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue