Files
doomemacs/modules/lang/elixir/config.el
Henrik Lissner d545fccf47 fix(:lang): missing grammar recipes
I removed the grammar recipes in 3b58741 to avoid redundancy with the
upstream recipes, but didn't realize that those upstream recipes weren't
added until Emacs 31, so users on 30 and older would get errors when
trying to install any missing grammars.

This also establishes a hard dependency between :lang (php +tree-sitter)
and :lang ({javascript,web} +tree-sitter).

Amend: 3b58741522
2025-08-31 14:39:38 +02:00

95 lines
2.6 KiB
EmacsLisp

;;; lang/elixir/config.el -*- lexical-binding: t; -*-
;; DEPRECATED: Remove when projectile is replaced with project.el
(after! projectile
(add-to-list 'projectile-project-root-files "mix.exs"))
;;
;;; Packages
(defun +elixir-common-config (mode)
(set-ligatures! mode
;; 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")
;; ...and only complete the basics
(sp-with-modes 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)))
(when (modulep! +lsp)
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append)))
(use-package! elixir-mode
:defer t
:init
;; Disable default smartparens config. There are too many pairs; we only want
;; a subset of them (defined below).
(provide 'smartparens-elixir)
(when (modulep! +lsp)
(after! lsp-mode
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
:config
(+elixir-common-config 'elixir-mode)
(after! highlight-numbers
(puthash 'elixir-mode
"\\_<-?[[:digit:]]+\\(?:_[[:digit:]]\\{3\\}\\)*\\_>"
highlight-numbers-modelist)))
(use-package! elixir-ts-mode ; 30.1+ only
:when (modulep! +tree-sitter)
:defer t
:init
(set-tree-sitter! 'elixir-mode 'elixir-ts-mode
'((elixir :url "https://github.com/elixir-lang/tree-sitter-elixir"
:commit "02a6f7fd4be28dd94ee4dd2ca19cb777053ea74e")
(heex :url "https://github.com/phoenixframework/tree-sitter-heex"
:commit "f6b83f305a755cd49cf5f6a66b2b789be93dc7b9")))
:config
(+elixir-common-config 'elixir-ts-mode))
(use-package! heex-ts-mode
:when (modulep! +tree-sitter)
:when (fboundp 'heex-ts-mode) ; 30.1+ only
:mode "\\.[hl]?eex\\'")
(use-package! flycheck-credo
:when (modulep! :checkers syntax -flymake)
:after elixir-mode
:config (flycheck-credo-setup))
(use-package! exunit
:hook (elixir-mode . exunit-mode)
:init
(map! :after elixir-mode
:localleader
:map elixir-mode-map
:prefix ("t" . "test")
"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))