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
|
2018-12-06 17:00:24 +11:00
|
|
|
(set-pretty-symbols! 'elixir-mode
|
|
|
|
;; Functional
|
|
|
|
:def "def"
|
|
|
|
:lambda "fn"
|
2018-12-06 17:09:00 +11:00
|
|
|
;; :src_block "do"
|
|
|
|
;; :src_block_end "end"
|
2018-12-06 17:00:24 +11:00
|
|
|
;; 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)
|
2020-07-31 01:39:24 -04:00
|
|
|
(add-hook 'elixir-mode-local-vars-hook #'lsp!))
|
|
|
|
|
|
|
|
(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
|
|
|
|
(set-lookup-handlers! 'alchemist-mode
|
|
|
|
:definition #'alchemist-goto-definition-at-point
|
|
|
|
:documentation #'alchemist-help-search-at-point)
|
|
|
|
(set-eval-handler! 'alchemist-mode #'alchemist-eval-region)
|
|
|
|
(set-repl-handler! 'alchemist-mode #'alchemist-iex-project-run))
|
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)))
|