doomemacs/modules/lang/elixir/config.el
Henrik Lissner 6acf163cf7
refactor!: replace smartparens with electric
BREAKING CHANGE: This moves smartparens out of core and formally
deprecates it. The package has been a performance liability and is only
being used for pair management, so the rest of its functionality was
overkill for what we needed it for.

Instead, I'm waiting for electric.el's support for N-character pairs in
Emacs 31. In the meantime, I delegate to yasnippet (later, tempel)
snippets to handle more complex pairs like /* ... */ or <?php ... ?>.

- To restore auto-pairing functionality (which is all Doom was using
  smartparens for, really), enable :emacs (electric +pair). This is not
  a perfect replacement for all of smartparens' capabilities. More
  complex pairing is being relegated to snippets (for example, /* ... */
  and <?php ... ?> comment blocks will soon have snippets for them).

- To restore the old smartparens functionality, enable :config (default
  +smartparens). Keep in mind that this is temporary! In v3, smartparens
  will be removed entirely OR moved to its own module; this hasn't been
  decided yet.

Fix: #5759
Fix: #5894
Fix: #6223
Fix: #8093
Fix: #8620
2026-02-21 17:00:48 -05:00

74 lines
2.4 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)
(when (modulep! +lsp)
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append))
(use-package! flycheck-credo
:when (modulep! :checkers syntax -flymake)
:config (flycheck-credo-setup))
(use-package! exunit
:defer t
:init
(add-hook (intern (format "%s-hook" mode)) #'exunit-mode)
(map! :localleader
:map ,(intern (format "%s-map" mode))
: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)))
(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\\'"))
(after! lsp-elixir
;; HACK: lsp-elixir is hardcoded to use the server `lsp-install-server'
;; installs, ignoring any system-provided executables. This fixes that,
;; so long as the user hasn't changed `lsp-elixir-server-command'
;; themselves,
(when (and (member lsp-elixir-server-command
'(("language_server.bat")
("language_server.sh")))
(executable-find "elixir-ls"))
(setq lsp-elixir-server-command '("elixir-ls")))))
:config
(+elixir-common-config 'elixir-mode))
(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 "d24cecee673c4c770f797bac6f87ae4b6d7ddec5")
(heex :url "https://github.com/phoenixframework/tree-sitter-heex"
:commit "b5a7cb5f74dc695a9ff5f04919f872ebc7a895e9")))
: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\\'")