2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/julia/config.el -*- lexical-binding: t; -*-
|
2016-04-12 15:33:06 -04:00
|
|
|
|
2019-09-13 21:59:03 -04:00
|
|
|
(use-package! julia-mode
|
2016-04-12 15:33:06 -04:00
|
|
|
:interpreter "julia"
|
2016-05-24 22:09:50 -04:00
|
|
|
:config
|
2019-10-04 22:01:09 -04:00
|
|
|
(set-repl-handler! 'julia-mode #'+julia/open-repl)
|
2017-04-26 23:29:31 -04:00
|
|
|
|
2020-04-08 17:34:53 -04:00
|
|
|
;; Borrow matlab.el's fontification of math operators. From
|
|
|
|
;; <https://ogbe.net/emacsconfig.html>
|
2019-02-15 19:42:36 -05:00
|
|
|
(dolist (mode '(julia-mode ess-julia-mode))
|
|
|
|
(font-lock-add-keywords
|
|
|
|
mode
|
|
|
|
`((,(let ((OR "\\|"))
|
2020-04-08 17:34:53 -04:00
|
|
|
(concat "\\(" ; stolen `matlab.el' operators first
|
2020-08-18 21:00:33 -03:00
|
|
|
"[<>]=?" OR
|
2019-02-15 19:42:36 -05:00
|
|
|
"\\.[/*^']" OR
|
2020-08-18 21:00:33 -03:00
|
|
|
"===" OR
|
2019-02-15 19:42:36 -05:00
|
|
|
"==" OR
|
|
|
|
"=>" OR
|
|
|
|
"\\<xor\\>" OR
|
2020-04-08 17:34:53 -04:00
|
|
|
"[-+*\\/^&|$]=?" OR ; this has to come before next (updating operators)
|
2020-08-18 21:00:33 -03:00
|
|
|
"[-^&|*+\\/~]" OR
|
|
|
|
;; `:` defines a symbol in Julia and must not be highlighted
|
|
|
|
;; as an operator. The only operators that start with `:` are
|
|
|
|
;; `:<` and `::`.
|
|
|
|
"[:<]:" OR
|
|
|
|
;; Julia variables and names can have `!`. Thus, `!` must be
|
|
|
|
;; highlighted as a single operator only in some
|
|
|
|
;; circumstances. However, full support can only be
|
|
|
|
;; implemented by a full parser. Thus, here, we will handle
|
|
|
|
;; only the simple cases.
|
|
|
|
"[[:space:]]!=?=?" OR "^!=?=?" OR
|
|
|
|
;; The other math operators that starts with `!`.
|
2019-02-15 19:42:36 -05:00
|
|
|
;; more extra julia operators follow
|
|
|
|
"[%$]" OR
|
|
|
|
;; bitwise operators
|
|
|
|
">>>" OR ">>" OR "<<" OR
|
|
|
|
">>>=" OR ">>" OR "<<" OR
|
|
|
|
"\\)"))
|
|
|
|
1 font-lock-type-face)))))
|
2019-10-04 22:01:09 -04:00
|
|
|
|
|
|
|
|
2020-04-08 17:34:53 -04:00
|
|
|
(use-package! julia-repl
|
2020-04-08 17:43:42 -04:00
|
|
|
:preface (defvar +julia-repl-start-hook nil)
|
|
|
|
:hook (julia-mode . julia-repl-mode)
|
|
|
|
:hook (+julia-repl-start . +julia-override-repl-escape-char-h)
|
|
|
|
:hook (+julia-repl-start . julia-repl-use-emacsclient)
|
2020-04-08 17:34:53 -04:00
|
|
|
:config
|
2020-04-08 14:33:27 -06:00
|
|
|
(set-popup-rule! "^\\*julia.*\\*$" :ttl nil)
|
|
|
|
|
2020-04-08 17:34:53 -04:00
|
|
|
(when (featurep! :ui workspaces)
|
|
|
|
(defadvice! +julia--namespace-repl-buffer-to-workspace-a (&optional executable-key suffix)
|
|
|
|
"Name for a Julia REPL inferior buffer. Uses workspace name for doom emacs"
|
|
|
|
:override #'julia-repl--inferior-buffer-name
|
|
|
|
(concat julia-repl-inferior-buffer-name-base ":" (+workspace-current-name))))
|
|
|
|
|
2020-04-08 17:43:42 -04:00
|
|
|
(defadvice! +julia--run-start-hook-a (inferior-buffer)
|
|
|
|
"Run `+julia-repl-start-hook' before displaying the REPL."
|
2020-04-08 14:33:27 -06:00
|
|
|
:after #'julia-repl--setup-term
|
|
|
|
(with-current-buffer inferior-buffer
|
2020-04-08 17:43:42 -04:00
|
|
|
(run-hooks '+julia-repl-start-hook)))
|
|
|
|
|
|
|
|
(defun +julia-override-repl-escape-char-h ()
|
|
|
|
"Use C-c instead of C-x for escaping."
|
|
|
|
(term-set-escape-char ?\C-c)))
|
2020-04-08 17:34:53 -04:00
|
|
|
|
2020-04-08 14:33:27 -06:00
|
|
|
|
|
|
|
(use-package! lsp-julia
|
|
|
|
:when (featurep! +lsp)
|
|
|
|
:after lsp-clients
|
2020-04-08 17:34:53 -04:00
|
|
|
:preface
|
|
|
|
(setq lsp-julia-default-environment "~/.julia/environments/v1.0")
|
|
|
|
(when (featurep! +lsp)
|
|
|
|
(add-hook 'julia-mode-local-vars-hook #'lsp!)))
|