2017-06-08 11:47:56 +02:00
|
|
|
;;; lang/elixir/config.el -*- lexical-binding: t; -*-
|
2017-05-24 13:08:26 +03:00
|
|
|
|
2019-10-19 15:25:29 -04:00
|
|
|
(after! projectile
|
|
|
|
(add-to-list 'projectile-project-root-files "mix.exs"))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! elixir-mode
|
2018-05-25 00:46:11 +02:00
|
|
|
:defer t
|
2018-06-25 15:54:38 +02:00
|
|
|
:init
|
2019-03-02 01:56:32 -05:00
|
|
|
;; Disable default smartparens config. There are too many pairs; we only want
|
|
|
|
;; a subset of them (defined below).
|
2018-06-25 15:54:38 +02:00
|
|
|
(provide 'smartparens-elixir)
|
2017-05-24 13:08:26 +03:00
|
|
|
:config
|
2020-08-12 18:52:14 -04:00
|
|
|
(set-ligatures! 'elixir-mode
|
2020-11-12 08:58:19 -07:00
|
|
|
;; Functional
|
|
|
|
:def "def"
|
|
|
|
:lambda "fn"
|
|
|
|
;; :src_block "do"
|
|
|
|
;; :src_block_end "end"
|
|
|
|
;; Flow
|
|
|
|
:not "!"
|
|
|
|
:in "in" :not-in "not in"
|
|
|
|
:and "and" :or "or"
|
|
|
|
:for "for"
|
|
|
|
:return "return" :yield "use")
|
2018-06-15 02:58:12 +02:00
|
|
|
|
2019-03-02 01:56:32 -05:00
|
|
|
;; ...and only complete the basics
|
2019-07-23 00:30:45 +02:00
|
|
|
(sp-with-modes 'elixir-mode
|
|
|
|
(sp-local-pair "do" "end"
|
|
|
|
:when '(("RET" "<evil-ret>"))
|
|
|
|
:unless '(sp-in-comment-p sp-in-string-p)
|
|
|
|
:post-handlers '("||\n[i]"))
|
|
|
|
(sp-local-pair "do " " end" :unless '(sp-in-comment-p sp-in-string-p))
|
|
|
|
(sp-local-pair "fn " " end" :unless '(sp-in-comment-p sp-in-string-p)))
|
2019-03-02 01:56:32 -05:00
|
|
|
|
2019-07-26 21:32:20 +03:00
|
|
|
(when (featurep! +lsp)
|
2022-03-24 02:19:52 +01:00
|
|
|
(add-hook 'elixir-mode-local-vars-hook #'lsp! 'append)
|
2021-05-05 12:33:33 -04:00
|
|
|
(after! lsp-mode
|
2021-05-14 21:31:41 +02:00
|
|
|
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
|
2020-07-31 01:39:24 -04:00
|
|
|
|
2022-07-25 17:34:44 +02:00
|
|
|
(when (featurep! +tree-sitter)
|
|
|
|
(add-hook 'elixir-mode-local-vars-hook #'tree-sitter! 'append))
|
|
|
|
|
2020-07-31 01:39:24 -04:00
|
|
|
(after! highlight-numbers
|
|
|
|
(puthash 'elixir-mode
|
|
|
|
"\\_<-?[[:digit:]]+\\(?:_[[:digit:]]\\{3\\}\\)*\\_>"
|
|
|
|
highlight-numbers-modelist)))
|
2019-07-26 21:32:20 +03:00
|
|
|
|
2020-03-27 01:25:30 -04:00
|
|
|
|
|
|
|
(use-package! flycheck-credo
|
|
|
|
:when (featurep! :checkers syntax)
|
|
|
|
:after elixir-mode
|
|
|
|
:config (flycheck-credo-setup))
|
2017-12-18 13:12:48 -05:00
|
|
|
|
|
|
|
|
2019-07-23 12:44:03 +02:00
|
|
|
(use-package! alchemist
|
2017-12-18 13:12:48 -05:00
|
|
|
:hook (elixir-mode . alchemist-mode)
|
2020-03-27 01:25:30 -04:00
|
|
|
:config
|
2022-01-04 21:00:25 +01:00
|
|
|
(set-lookup-handlers! 'elixir-mode
|
2020-03-27 01:25:30 -04:00
|
|
|
:definition #'alchemist-goto-definition-at-point
|
|
|
|
:documentation #'alchemist-help-search-at-point)
|
2022-01-04 21:00:25 +01:00
|
|
|
(set-eval-handler! 'elixir-mode #'alchemist-eval-region)
|
|
|
|
(set-repl-handler! 'elixir-mode #'alchemist-iex-project-run)
|
2021-05-04 18:15:42 -04:00
|
|
|
(map! :after elixir-mode
|
|
|
|
:localleader
|
|
|
|
:map elixir-mode-map
|
|
|
|
"m" #'alchemist-mix
|
|
|
|
"c" #'alchemist-mix-compile
|
|
|
|
"i" #'alchemist-iex-project-run
|
|
|
|
"f" #'elixir-format
|
|
|
|
(:prefix ("e" . "eval")
|
|
|
|
"e" #'alchemist-iex-send-last-sexp
|
|
|
|
"r" #'alchemist-iex-send-region
|
|
|
|
"l" #'alchemist-iex-send-current-line
|
|
|
|
"R" #'alchemist-iex-reload-module)))
|
2019-09-13 21:59:03 -04:00
|
|
|
|
|
|
|
|
|
|
|
(use-package! alchemist-company
|
|
|
|
:when (featurep! :completion company)
|
|
|
|
:commands alchemist-company
|
2017-12-18 13:12:48 -05:00
|
|
|
:config
|
2020-03-27 01:25:30 -04:00
|
|
|
(set-company-backend! 'alchemist-mode '(alchemist-company company-yasnippet))
|
2019-09-13 21:59:03 -04:00
|
|
|
;; Alchemist doesn't use hook symbols to add these backends, so we have to use
|
|
|
|
;; the entire closure to get rid of it.
|
|
|
|
(let ((fn (byte-compile (lambda () (add-to-list (make-local-variable 'company-backends) 'alchemist-company)))))
|
|
|
|
(remove-hook 'alchemist-mode-hook fn)
|
|
|
|
(remove-hook 'alchemist-iex-mode-hook fn)))
|
2020-10-22 18:39:59 -06:00
|
|
|
|
|
|
|
(use-package! exunit
|
|
|
|
:hook (elixir-mode . exunit-mode)
|
2020-11-12 08:58:19 -07:00
|
|
|
:init
|
2020-10-22 18:39:59 -06:00
|
|
|
(map! :after elixir-mode
|
2020-11-14 15:35:07 -07:00
|
|
|
:localleader
|
|
|
|
:map elixir-mode-map
|
2021-05-04 18:15:42 -04:00
|
|
|
:prefix ("t" . "test")
|
2020-11-14 15:35:07 -07:00
|
|
|
"a" #'exunit-verify-all
|
|
|
|
"r" #'exunit-rerun
|
|
|
|
"v" #'exunit-verify
|
|
|
|
"T" #'exunit-toggle-file-and-test
|
|
|
|
"t" #'exunit-toggle-file-and-test-other-window
|
|
|
|
"s" #'exunit-verify-single))
|