emacs/lisp/langs/icejam-lang-elixir.el
Maciej Szlosarczyk f03cae68b3
Some checks failed
/ Test config on 20 (push) Failing after 51s
Update August 2025
2025-08-04 11:39:09 +03:00

72 lines
2.6 KiB
EmacsLisp

;;; languages/elixir -- summary -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(eval-when-compile
(declare-function column-enforce-n 'column-enforce-mode (number))
(declare-function -> 'dash)
(declare-function lsp 'lsp-mode)
(declare-function yas--table-get-create 'yasnippet)
(declare-function yas--remove-template-by-uuid 'yasnippet)
(declare-function icejam-set-indent 'icejam-prog-mode)
(declare-function icejam-set-lsp-capfs 'icejam-complete-at-point)
(defvar icejam-language-transient-alist)
(defvar apheleia-mode-alist))
(use-package elixir-ts-mode :ensure t :defer t :after (apheleia)
:config
(add-to-list 'apheleia-mode-alist '(heex-ts-mode . mix-format)))
(transient-define-prefix icejam-elixir-lang-menu ()
[[:description
(lambda ()
(concat (propertize "Code actions for " 'face 'transient-heading)
(propertize (format "%s" major-mode) 'face 'transient-key)
(propertize ":\n" 'face 'transient-heading)))
("m" "LSP iMenu" lsp-ui-imenu)
("r" "Reload buffer" icejam-revert-buffer-no-confirm)
("e" "Show errors" flymake-show-buffer-diagnostics)
("f" "Format buffer with Elixir formatter" apheleia-format-buffer)
("q" "Quit" keyboard-quit)]])
(defun icejam-delete-elixir-snippets ()
"This function deletes Elixir snippets I don't use."
(-> 'elixir-mode
(yas--table-get-create)
(yas--remove-template-by-uuid "defmodule XXX end")))
(add-to-list
'icejam-language-transient-alist '(elixir-ts-mode . icejam-elixir-lang-menu))
(defun icejam-activate-elixir-ts-mode ()
"All things Elixir."
(icejam-set-indent 2)
(column-enforce-n 98)
(lsp)
;; If needed, switch the one below to false to disable documentation pop-ups
;; (setq-local lsp-ui-doc-enable t)
(setq-local lsp-eldoc-enable-hover nil
lsp-completion-enable-additional-text-edit nil)
(icejam-set-lsp-capfs)
(icejam-delete-elixir-snippets))
(add-hook 'heex-ts-mode-hook 'icejam-activate-elixir-ts-mode)
(add-hook 'elixir-ts-mode-hook 'icejam-activate-elixir-ts-mode)
;; (use-package ert :ensure nil :defer t)
;; (ert-deftest icejam-activate-elixir-ts-mode ()
;; "Test `elixir-ts-mode` activation."
;; (with-temp-buffer
;; (elixir-ts-mode)
;; (icejam-activate-elixir-ts-mode)
;; (should (eq major-mode 'elixir-ts-mode))
;; (should (bound-and-true-p column-enforce-mode))
;; (should (equal " 98col" (buffer-local-value 'column-enforce-mode-line-string
;; (current-buffer))))
;; (should (eq 2 (buffer-local-value 'tab-width (current-buffer))))))
(provide 'icejam-lang-elixir)
;;; icejam-lang-elixir.el ends here