Skip to content

Add julia +snail #6578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/lang/julia/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ This module adds support for [[https://julialang.org/][the Julia language]] to D
- +tree-sitter ::
Leverages tree-sitter for better syntax highlighting and structural text
editing. Requires [[doom-module::tools tree-sitter]].
- +snail :: Use Snail, a development environment and REPL interaction package
for Julia in the spirit of Common Lisp’s SLIME and Clojure’s CIDER. It enables
convenient and dynamic REPL-driven development.

** Packages
- [[doom-package:julia-mode]]
Expand All @@ -31,6 +34,8 @@ This module adds support for [[https://julialang.org/][the Julia language]] to D
- if [[doom-module::tools lsp +eglot]]
- [[doom-package:eglot-jl]]
- [[doom-package:eglot]]
- if [[doom-package:][+snail]]
- [[doom-package:][julia-snail]]

** Hacks
/No hacks documented for this module./
Expand Down Expand Up @@ -104,6 +109,19 @@ But to let [[doom-package:eglot-jl]] use the environment bundled with it, set it
[[doom-package:eglot]] features. It requires ~LanguageServer.jl~, the installation of which is
described above.

** Snail

| Keybind | Command |
|-----------------------------+-----------------------------------|
| [[kbd:][<localleader> ']] | ~julia-snail~ |
| [[kbd:][<localleader> a]] | ~julia-snail-package-activate~ |
| [[kbd:][<localleader> r]] | ~julia-snail-update-module-cache~ |
| [[kbd:][<localleader> d]] | ~julia-snail-doc-lookup~ |
| [[kbd:][<localleader> e b]] | ~julia-snail-send-buffer-file~ |
| [[kbd:][<localleader> e l]] | ~julia-snail-send-line~ |
| [[kbd:][<localleader> e r]] | ~julia-snail-send-region~ |
| [[kbd:][<localleader> e e]] | ~julia-snail-send-dwim~ |

* TODO Configuration
#+begin_quote
🔨 /This module's configuration documentation is incomplete./ [[doom-contrib-module:][Complete it?]]
Expand Down
7 changes: 7 additions & 0 deletions modules/lang/julia/autoload.el
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,10 @@
(with-current-buffer buffer
(inferior-julia-mode))
buffer)))

;;;###autoload
(defun +julia/open-snail-repl ()
"A wrapper for julia-snail"
(interactive)
(julia-snail)
(current-buffer))
43 changes: 41 additions & 2 deletions modules/lang/julia/config.el
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(use-package! julia-mode
:interpreter "julia"
:config
(set-repl-handler! 'julia-mode #'+julia/open-repl)
(unless (modulep! +snail)
(set-repl-handler! 'julia-mode #'+julia/open-repl))

(when (modulep! +lsp)
(add-hook 'julia-mode-local-vars-hook #'lsp! 'append))
Expand Down Expand Up @@ -91,8 +92,46 @@
:after eglot
:preface
;; Prevent auto-install of LanguageServer.jl
(setq eglot-jl-language-server-project "~/.julia/environments/v1.6")
(setq eglot-jl-language-server-project
(or (car (last (doom-glob "~/.julia/environments/v*")))
"~/.julia/environments/v1.6"))
:init
;; Prevent timeout while installing LanguageServer.jl
(setq-hook! 'julia-mode-hook eglot-connect-timeout (max eglot-connect-timeout 60))
:config (eglot-jl-init))


(use-package! julia-snail
:when (modulep! +snail)
:when (modulep! :term vterm)
:hook (julia-mode . julia-snail-mode)
:config
(setq julia-snail-popup-display-eval-results :command)
(setq julia-snail-multimedia-enable t)
(setq julia-snail-popup-display-face '(:background base3 :box `(:line-width -1 :color base5)))

(set-popup-rule! "^\\*julia.*\\*$" :ttl nil :select nil :quit nil)

(after! julia-mode
(set-repl-handler! 'julia-mode #'+julia/open-snail-repl
:persist t
;; FIXME These aren't working as expected
:send-region #'julia-snail-send-region
:send-buffer #'julia-snail-send-buffer-file))

(map! (:localleader
(:map (julia-snail-mode-map)
"'" #'julia-snail
"a" #'julia-snail-package-activate
"r" #'julia-snail-update-module-cache
"d" #'julia-snail-doc-lookup
(:prefix ("e" . "eval")
"b" #'julia-snail-send-buffer-file
"l" #'julia-snail-send-line
"r" #'julia-snail-send-region
"e" #'julia-snail-send-dwim))
(:map (julia-snail-repl-mode-map)
"a" #'julia-snail-package-activate
"d" #'julia-snail-doc-lookup
"m" #'julia-snail-repl-go-back
"r" #'julia-snail-update-module-cache))))
2 changes: 2 additions & 0 deletions modules/lang/julia/doctor.el
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@
"-e" "using LanguageServer, SymbolServer")))))
(unless (zerop (car (apply #'doom-call-process args)))
(warn! "Couldn't find LanguageServer.jl and/or SymbolServer.jl"))))

;; TODO Check for snail
11 changes: 7 additions & 4 deletions modules/lang/julia/packages.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
;; -*- no-byte-compile: t; -*-
;;; lang/julia/packages.el

(package! julia-mode :pin "7aafa8e77df64a47fa4729a0c1ea572b5bc8e30e")
(package! julia-repl :pin "57a15dfafed680ad7d81f779d414e8cb6717417c")
(package! julia-mode :pin "7a8c868e0d3e51ba4a2c621ee22ca9599e0e4bbb")
(package! julia-repl :pin "9503ef7110732e444e686e815c5b2ae8228d274d")

(when (modulep! +lsp)
(if (modulep! :tools lsp +eglot)
(package! eglot-jl :pin "2e04597223553a369dd5b6520b6365b41e6ea508")
(package! lsp-julia :pin "d6688bb131ff4a5a0201f6d3826ef0b018265389")))
(package! eglot-jl :pin "7dc604fe42a459a987853d065cd6d0f3c4cbc02a")
(package! lsp-julia :pin "c584f79c7fee6176bbb6120f4cb0f1001bcf8113")))

(when (modulep! +snail)
(package! julia-snail :pin "18b891b4569096d541e996cf7e24da01efdf2e03"))