doomemacs/modules/lang/elixir/config.el

102 lines
3.1 KiB
EmacsLisp
Raw Normal View History

;;; lang/elixir/config.el -*- lexical-binding: t; -*-
2017-05-24 13:08:26 +03:00
(after! projectile
(add-to-list 'projectile-project-root-files "mix.exs"))
;;
;;; Packages
(use-package! elixir-mode
:defer t
: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).
(provide 'smartparens-elixir)
2017-05-24 13:08:26 +03:00
:config
(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")
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
(when (featurep! +lsp)
(add-hook 'elixir-mode-local-vars-hook #'lsp! 'append)
(after! lsp-mode
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
(after! highlight-numbers
(puthash 'elixir-mode
"\\_<-?[[:digit:]]+\\(?:_[[:digit:]]\\{3\\}\\)*\\_>"
highlight-numbers-modelist)))
2020-03-27 01:25:30 -04:00
(use-package! flycheck-credo
:when (featurep! :checkers syntax)
:after elixir-mode
:config (flycheck-credo-setup))
(use-package! alchemist
:hook (elixir-mode . alchemist-mode)
2020-03-27 01:25:30 -04:00
:config
(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)
(set-eval-handler! 'elixir-mode #'alchemist-eval-region)
(set-repl-handler! 'elixir-mode #'alchemist-iex-project-run)
(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)))
(use-package! alchemist-company
:when (featurep! :completion company)
:commands alchemist-company
:config
2020-03-27 01:25:30 -04:00
(set-company-backend! 'alchemist-mode '(alchemist-company company-yasnippet))
;; 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)))
(use-package! exunit
:hook (elixir-mode . exunit-mode)
2020-11-12 08:58:19 -07:00
:init
(map! :after elixir-mode
2020-11-14 15:35:07 -07:00
:localleader
:map elixir-mode-map
: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))