From 682ff5500a57edbb0c86f9ccada123a305cb98b2 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 18 Dec 2017 13:12:48 -0500 Subject: [PATCH] lang/elixir: refactor; fix smartparens & alchemist integration Fixes #294 --- modules/lang/elixir/config.el | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/lang/elixir/config.el b/modules/lang/elixir/config.el index 7405d13d2..20044b36d 100644 --- a/modules/lang/elixir/config.el +++ b/modules/lang/elixir/config.el @@ -2,8 +2,36 @@ (def-package! elixir-mode :mode "\\.exs?$" - :init - (add-hook! 'elixir-mode-hook #'(turn-off-smartparens-mode alchemist)) + :mode "\\.elixir2$" :config + ;; disable standard config; more disruptive than it needs to be + (dolist (beg '("fn" "do" "def" "defp" "defmodule" "if" "unless" "case" "receive")) + (sp-local-pair 'elixir-mode beg nil :actions :rem)) + ;; only complete the basics + (sp-with-modes 'elixir-mode + (sp-local-pair "do" "end" :when '(("RET" "")) :post-handlers '("||\n[i]")) + (sp-local-pair "do " " end") + (sp-local-pair "fn " " end"))) + + +(def-package! alchemist + :after elixir-mode + :hook (elixir-mode . alchemist-mode) + :config + (set! :jump 'elixir-mode + :definition #'alchemist-goto-definition-at-point + :documentation #'alchemist-help-search-at-point) + (set! :eval 'elixir-mode #'alchemist-eval-region)) + + +(def-package! alchemist-company + :when (featurep! :completion company) + :after (:all company elixir-mode) + :config + ;; Let Doom handle this + (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)) + (set! :company-backend 'elixir-mode '(alchemist-company company-yasnippet)))