forked from syl20bnr/spacemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#+TITLE: julia layer | ||
|
||
# The maximum height of the logo should be 200 pixels. | ||
[[file:img/julia.png]] | ||
# TOC links should be GitHub style anchors. | ||
|
||
* Table of Contents :TOC_4_gh:noexport: | ||
- [[#description][Description]] | ||
- [[#features][Features:]] | ||
- [[#install][Install]] | ||
- [[#lsp][LSP]] | ||
- [[#options][Options]] | ||
- [[#key-bindings][Key bindings]] | ||
|
||
* Description | ||
This layer adds support for [[https://julialang.org][Julia]] to Spacemacs. | ||
|
||
** Features: | ||
- Syntax highlighting | ||
- Repl support | ||
- Linting | ||
- Completion | ||
- Jump-to-definition | ||
- Documentation on hover | ||
|
||
* Install | ||
To use this configuration layer, add it to your =~/.spacemacs=. You will need to | ||
add =julia= to the existing =dotspacemacs-configuration-layers= list in this | ||
file. | ||
|
||
** LSP | ||
Warning: enabling the LSP functionality within this package can cause emacs to | ||
hang for significant lengths of time when opening a Julia file. See tip below on | ||
using PackageCompiler.jl to mitigate this issue. | ||
|
||
This layer can be used with [[https://github.com/JuliaEditorSupport/LanguageServer.jl][=LanguageServer.jl=]] and emacs [[https://github.com/emacs-lsp/lsp-mode][=lsp-mode=]] to provide | ||
richer, IDE-like capabilities. To use this layer with lsp, you must do the | ||
following: | ||
|
||
1. Add =lsp= to =dotspacemacs-configuration-layers=. | ||
2. Install =LanguageServer.jl= by invoking =Pkg.add("LanguageServer") in the | ||
Julia REPL. | ||
3. Enable layer integration with lsp as described in section below. | ||
|
||
=LanguageServer.jl= tends to have a very long startup time. In the worst case, | ||
=lsp-mode= might give up on the language server before its started, but | ||
regardless usage of =lsp-mode= with Julia can cause long delays when first | ||
opening files. To mitigate this issue, you can try compiling =LanguageServer.jl= | ||
ahead of time using [[https://github.com/JuliaLang/PackageCompiler.jl][=PackageCompiler.jl=]] this drastically reduces startup time | ||
if successful. | ||
|
||
* Options | ||
While =julia-mode= is perfectly usable without configuration or other packages, | ||
you can choose to replace the default functionality of using [[https://github.com/tpapp/julia-repl/][=julia-repl=]] as the | ||
layer's interactive REPL with the ess REPL and other functionality that comes | ||
with it. To do so, install this layer with: | ||
|
||
#+BEGIN_SRC emacs-lisp | ||
(setq-default | ||
dotspacemacs-configuration-layers | ||
'( | ||
(julia :variables julia-mode-enable-ess t))) | ||
#+END_SRC | ||
|
||
This layer also includes experimental support for =lsp-mode=. To enable language | ||
server functionality with this layer, follow [[#lsp][the instructions for installation]], | ||
and then install this layer with: | ||
|
||
#+BEGIN_SRC emacs-lisp | ||
(setq-default | ||
dotspacemacs-configuration-layers | ||
'( | ||
(julia :variables julia-mode-enable-lsp t))) | ||
#+END_SRC | ||
|
||
* Key bindings | ||
|
||
| Key Binding | Description | | ||
|-------------+------------------------------------------------------------| | ||
| ~SPC m h h~ | Calls ~@doc~ macro on symbol under cursor. | | ||
| ~SPC m e m~ | Expands macro under cursor. | | ||
| ~SPC m w~ | Calls ~workspace()~ in Repl to give clean namespace. | | ||
| ~SPC e l~ | Expands latex macro (e.g. =\delta=). | | ||
| ~SPC m s b~ | Sends buffer to REPL. | | ||
| ~SPC m s l~ | Sends line to REPL. | | ||
| ~SPC m s r~ | Sends region to REPL. | | ||
| ~SPC m r~ | Brings up Julia Repl (starts new one or focuses existing). | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
;;; config.el --- Python Layer Configuration File for Spacemacs | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Adam Beckmeyer <[email protected]> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
;; variables | ||
|
||
(spacemacs|define-jump-handlers julia-mode) | ||
|
||
;; ess-mode is what the majority of people developing julia in emacs currently use | ||
(defvar julia-mode-enable-ess nil | ||
"If non-nil, enable ESS in julia-mode buffers and disable julia-repl.") | ||
|
||
;; disabled by default since most won't have lsp-mode working | ||
(defvar julia-mode-enable-lsp nil | ||
"If non-nil, enable lsp-mode in julia-mode buffers.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
;;; funcs.el --- Julia Layer functions File for Spacemacs | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Adam Beckmeyer <[email protected]> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
(defun spacemacs//julia-setup-buffer () | ||
"Setup ESS and/or lsp for buffer depending on config." | ||
(if (not julia-mode-enable-ess) | ||
(spacemacs//julia-setup-repl)) | ||
(if julia-mode-enable-lsp | ||
(spacemacs//julia-setup-lsp))) | ||
|
||
(defun spacemacs//julia-setup-repl () | ||
"Start julia-repl minor mode and configure for buffer." | ||
(julia-repl-mode)) | ||
|
||
(defun spacemacs//julia-setup-lsp () | ||
"Start lsp-mode and configure for buffer." | ||
(if (configuration-layer/layer-used-p 'lsp) | ||
(lsp-julia-enable) | ||
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile."))) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
;;; packages.el --- julia layer packages file for Spacemacs. | ||
;; | ||
;; Copyright (c) 2012-2018 Sylvain Benner & Contributors | ||
;; | ||
;; Author: Adam Beckmeyer <[email protected]> | ||
;; URL: https://github.com/syl20bnr/spacemacs | ||
;; | ||
;; This file is not part of GNU Emacs. | ||
;; | ||
;;; License: GPLv3 | ||
|
||
(defconst julia-packages | ||
'( | ||
(julia-mode :location elpa) | ||
(julia-repl :location elpa) | ||
(lsp-julia :location (recipe :fetcher github | ||
:repo "non-Jedi/lsp-julia")) | ||
flycheck | ||
company-lsp | ||
)) | ||
|
||
(defun julia/init-julia-mode () | ||
(use-package julia-mode | ||
:defer t | ||
:init (progn | ||
(add-hook 'julia-mode-hook #'spacemacs//julia-setup-buffer) | ||
(if (and (configuration-layer/layer-used-p 'ess) | ||
julia-mode-enable-ess) | ||
(add-to-list 'auto-mode-alist | ||
'("\\.jl\\'" . ess-julia-mode))) | ||
(if (and (not (configuration-layer/layer-used-p 'ess)) | ||
julia-mode-enable-ess) | ||
(message "`ess' layer is not installed. Please add `ess' layer to your dotfile."))) | ||
:config (progn | ||
(spacemacs/declare-prefix-for-mode 'julia-mode | ||
"mh" "help") | ||
(spacemacs/declare-prefix-for-mode 'julia-mode | ||
"me" "eval") | ||
(spacemacs/declare-prefix-for-mode 'julia-mode | ||
"m=" "format") | ||
(spacemacs/set-leader-keys-for-major-mode 'julia-mode | ||
"el" 'julia-latexsub | ||
"==" 'julia-indent-line)))) | ||
|
||
(defun julia/init-julia-repl () | ||
(use-package julia-repl | ||
:defer t | ||
:init (progn | ||
(spacemacs/register-repl 'julia-repl 'julia-repl | ||
"julia-repl")) | ||
:config (progn | ||
(spacemacs/declare-prefix-for-mode 'julia-repl-mode | ||
"ms" "send") | ||
(spacemacs/set-leader-keys-for-minor-mode | ||
'julia-repl-mode | ||
"'" 'julia-repl-edit | ||
"hh" 'julia-repl-doc | ||
"w" 'julia-repl-workspace | ||
"em" 'julia-repl-macroexpand | ||
"r" 'julia-repl | ||
"si" 'julia-repl | ||
"sb" 'julia-repl-send-buffer | ||
"sl" 'julia-repl-send-line | ||
"sr" 'julia-repl-send-region-or-line | ||
"em" 'julia-repl-macroexpand)))) | ||
|
||
(defun julia/init-lsp-julia () | ||
(use-package lsp-julia | ||
:config (progn | ||
(push 'xref-find-definitions spacemacs-jump-handlers-julia-mode)) | ||
:commands lsp-julia-enable)) | ||
|
||
(defun julia/post-init-company-lsp () | ||
(spacemacs|add-company-backends | ||
:backends company-lsp | ||
:modes julia-mode | ||
:variables | ||
company-minimum-prefix-length 0 | ||
company-idle-delay 0.5)) | ||
|
||
(defun julia/post-init-flycheck () | ||
(spacemacs/enable-flycheck 'julia-mode)) | ||
;;; packages.el ends here |