This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/layers/+lang/julia/funcs.el
Lucius Hu 40c72dc437 julia: refactor
- Moved backend determination to `config.el`
- Replaced `pcase` form with only one-arm with `when` or `unless` form
- Replaced `(when (not foo) bar)` with `(unless foo bar)`
- Refactored function
2021-04-04 12:48:21 +02:00

70 lines
2.2 KiB
EmacsLisp
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

;;; funcs.el --- Julia Layer functions File for Spacemacs
;;
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
;;
;; Author: Adam Beckmeyer <adam_git@thebeckmeyers.xyz>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
(defun spacemacs//julia-setup-backend ()
"Conditionally setup julia backend."
(when (eq julia-backend 'lsp)
(spacemacs//julia-setup-lsp)))
(defun spacemacs//julia-setup-buffer ()
"Configure julia-mode"
(unless julia-mode-enable-ess
(spacemacs//julia-setup-repl)))
;; lsp
(defun spacemacs//julia-setup-lsp ()
"Start lsp-mode and configure for buffer."
(if (configuration-layer/layer-used-p 'lsp)
(lsp)
(message "`lsp' layer is not installed, please add `lsp' layer to your dotfile.")))
;; repl
(defun spacemacs//julia-setup-repl ()
"Start julia-repl minor mode and configure for buffer."
(julia-repl-mode))
;; misc
(defun spacemacs//julia-hash-to-alist (hash)
"Convert a `hash-table' to an `alist' for the use in a helm buffer."
(let (res)
(maphash (lambda (key value)
(push `(,key . ,value) res))
hash)
res))
(when (configuration-layer/layer-used-p 'helm)
(defun spacemacs//julia-helm-math-insert ()
"Insert a utf8 symbol from `julia-latexsubs'"
(interactive)
(helm :sources (helm-build-sync-source "test"
:candidates (spacemacs//julia-hash-to-alist julia-latexsubs)
:fuzzy-match t
:action (lambda (candidate) (insert candidate)))
:buffer "*helm julia latex insert*")))