-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathontop-julia.el
140 lines (119 loc) · 4.85 KB
/
ontop-julia.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
;;; ontop-julia.el --- Julia configuration -*- lexical-binding: t; -*-
;; This file is part of Emacs ONTOP
;; https://github.com/monkeyjunglejuice/emacs.ontop
;;; Commentary:
;; You can also use this file/configuration independently from Emacs ONTOP
;; Load it from anywhere via `(load-file "/path/to/ontop-julia.el")'.
;;; Code:
;; ____________________________________________________________________________
;;; USE-PACKAGE
;; <https://github.com/jwiegley/use-package>
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package nil))
(eval-when-compile
(require 'use-package))
;; ____________________________________________________________________________
;;; JULIA TREESITTER MODE
;; <https://github.com/ronisbr/julia-ts-mode>
(use-package julia-ts-mode
:ensure t
:mode "\\.jl$")
;; In order to use Tree Sitter, install the tree-sitter binary with your OS
;; package manager. Then install the language grammar via
;; 'M-x treesit-install-language-grammar'
(use-package treesit
:ensure nil
:config
(add-to-list 'treesit-language-source-alist
'(julia "https://github.com/tree-sitter/tree-sitter-julia")))
;; ____________________________________________________________________________
;;; JULIA SNAIL
;; <https://github.com/gcv/julia-snail/>
;; Interactive Julia with REPL
(use-package julia-snail
:ensure t
:custom
;; Needs a terminal emulator within Emacs; alternative: vterm
(julia-snail-terminal-type :eat)
;; Print the result of evaluating code to the REPL
(julia-snail-repl-display-eval-results t) ; `nil' to disable
;; Show result of evaluating code in the source buffer
(julia-snail-popup-display-eval-results nil) ; `:command', `:change' or `nil'
;; The default works with Consult and Helm
(julia-snail-imenu-style :module-tree) ; `:module-tree', `:flat' or `nil'
:hook
(julia-ts-mode . julia-snail-mode))
;; ____________________________________________________________________________
;;; EAT
;; <https://codeberg.org/akib/emacs-eat>
;; <https://elpa.nongnu.org/nongnu-devel/doc/eat.html>
;; Julia Snail requires a terminal emulator within Emacs for the REPL
(use-package eat
:ensure t
:custom
(eat-kill-buffer-on-exit t)
:config
;; make C-u work in Eat terminals like in normal terminals
(delete [?\C-u] eat-semi-char-non-bound-keys)
;; ditto for C-g
(delete [?\C-g] eat-semi-char-non-bound-keys)
(eat-update-semi-char-mode-map)
;; XXX: Awkward workaround for the need to call eat-reload after changing
;; Eat's keymaps, but reloading from :config section causes infinite recursion
;; because :config wraps with-eval-after-load.
(defvar eat--prevent-use-package-config-recursion nil)
(unless eat--prevent-use-package-config-recursion
(setq eat--prevent-use-package-config-recursion t)
(eat-reload))
(makunbound 'eat--prevent-use-package-config-recursion))
;; ____________________________________________________________________________
;;; EGLOT LANGUAGE SERVER
;; <https://github.com/joaotavora/eglot/blob/master/MANUAL.md>
;; Common keybindings are configured in `./ontop-core.el'
;; Setup Eglot for Julia and install the language server binary if necessary
;; <https://github.com/non-Jedi/eglot-jl>
(use-package eglot-jl
:ensure t
:init
(eglot-jl-init))
(use-package eglot
:ensure t
:hook
;; Start language server automatically
(julia-ts-mode . eglot-ensure)
;; Tell the language server to format the buffer before saving
(julia-ts-mode . (lambda ()
(add-hook 'before-save-hook
#'eglot-format-buffer nil 'local))))
;; ____________________________________________________________________________
;;; PARENTHESIS DISPLAY
;; Rainbow-delimiters color-coding of nested parens is already enabled
;; for all prog-modes in `ontop-core.el'
(use-package rainbow-delimiters
:ensure t
:hook
(julia-snail-mode . rainbow-delimiters-mode))
;; Make parens styleable, e.g. more or less prominent
;; <https://github.com/tarsius/paren-face>
;; (use-package paren-face
;; :ensure t
;; :hook
;; ((julia-ts-mode julia-snail-mode) . paren-face-mode))
;; ____________________________________________________________________________
;;; ORG-MODE BABEL
;; <https://orgmode.org/worg/org-contrib/babel/index.html>
;; Notebook-like literate programming in Emacs
;; Evaluate Julia code in Org source code blocks via "C-c C-c".
;; 2 Julia packages must be added for this to work: DataFrames and CSV.
;; <https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-julia.html>
(use-package org
:ensure nil
:hook
(org-mode . (lambda ()
(org-babel-do-load-languages
'org-babel-load-languages
(add-to-list 'org-babel-load-languages '(julia . t))))))
;; ____________________________________________________________________________
(provide 'ontop-julia)
;;; ontop-julia.el ends here