yeet
This commit is contained in:
79
.config/emacs/modules/lang/elixir/README.org
Normal file
79
.config/emacs/modules/lang/elixir/README.org
Normal file
@@ -0,0 +1,79 @@
|
||||
#+TITLE: lang/elixir
|
||||
#+DATE: June 24, 2019
|
||||
#+SINCE: v2.0.9
|
||||
|
||||
* Table of Contents :TOC_3:noexport:
|
||||
- [[#description][Description]]
|
||||
- [[#module-flags][Module flags]]
|
||||
- [[#plugins][Plugins]]
|
||||
- [[#prerequisites][Prerequisites]]
|
||||
- [[#install-elixir][Install Elixir]]
|
||||
- [[#with-asdf][With ~asdf~]]
|
||||
- [[#arch-linux][Arch Linux]]
|
||||
- [[#gentoo-linux][Gentoo Linux]]
|
||||
- [[#opensuse][openSUSE]]
|
||||
- [[#features][Features]]
|
||||
- [[#appendix][Appendix]]
|
||||
- [[#commands][Commands]]
|
||||
|
||||
* Description
|
||||
This module provides support for [[https://elixir-lang.org/][Elixir programming language]] via [[https://github.com/tonini/alchemist.el][alchemist.el]]
|
||||
or [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]].
|
||||
|
||||
** Module flags
|
||||
+ ~+lsp~ Enable LSP support. Requires [[https://github.com/elixir-lsp/elixir-ls/][elixir-ls]].
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/elixir-editors/emacs-elixir][elixir-mode]]
|
||||
+ [[https://github.com/tonini/alchemist.el][alchemist.el]]
|
||||
+ [[https://github.com/aaronjensen/flycheck-credo][flycheck-credo]]
|
||||
+ [[https://github.com/ananthakumaran/exunit.el][exunit]]
|
||||
|
||||
* Prerequisites
|
||||
You should have Elixir installed, for example, via your distribution's package
|
||||
manager or a version management tool such as [[https://github.com/asdf-vm/asdf-elixir][asdf]].
|
||||
|
||||
If you want to add support for LSP ([[modules/tools/lsp][:tools lsp]]), be sure to install [[https://github.com/JakeBecker/elixir-ls/][elixir-ls]]
|
||||
and enable ~:tools lsp~ in your ~init.el~.
|
||||
|
||||
To support linting with [[https://github.com/rrrene/credo][credo]], add ~:checkers syntax~ to your ~init.el~
|
||||
** Install Elixir
|
||||
*** With ~asdf~
|
||||
#+BEGIN_SRC sh
|
||||
asdf plugin-add elixir
|
||||
asdf install elixir 1.9.1
|
||||
#+END_SRC
|
||||
*** Arch Linux
|
||||
#+BEGIN_SRC sh :dir /sudo::
|
||||
sudo pacman -S elixir
|
||||
#+END_SRC
|
||||
*** Gentoo Linux
|
||||
#+BEGIN_SRC sh :dir /sudo::
|
||||
sudo emerge -v dev-lang/elixir
|
||||
#+END_SRC
|
||||
|
||||
*** openSUSE
|
||||
#+BEGIN_SRC sh :dir /sudo::
|
||||
sudo zypper install elixir
|
||||
#+END_SRC
|
||||
See [[https://elixir-lang.org/install.html]] for other operating systems
|
||||
* Features
|
||||
- Code completion (~:completion company~)
|
||||
- Documentation lookup (~:tools lookup~)
|
||||
- Mix integration
|
||||
- Phoenix support
|
||||
- ~iex~ integration (~:tools eval~)
|
||||
- Syntax checking (~:checkers syntax~, using [[https://github.com/aaronjensen/flycheck-credo][flycheck-credo]]~)
|
||||
* Appendix
|
||||
** Commands
|
||||
*** exunit-mode
|
||||
The exunit-mode prefix is =SPC m t=. Here is some examples:
|
||||
| | | |
|
||||
| command | key / ex command | description |
|
||||
|------------------------------------------+------------------+--------------------------------------------------------|
|
||||
| ~exunit-verify-all~ | =SPC m t a= | Runs exunit on all files |
|
||||
| ~exunit-rerun~ | =SPC m t r= | Re-runs last exunit command |
|
||||
| ~exunit-verify~ | =SPC m t v= | Runs exunit on current file |
|
||||
| ~exunit-verify-single~ | =SPC m t s= | Runs exunit for the item on cursor |
|
||||
| ~exunit-toggle-file-and-test~ | =SPC m t t= | Switch between implementation and test |
|
||||
| ~exunit-toggle-file-and-test-other-window~ | =SPC m t T= | Switch between implementation and test in other window |
|
||||
101
.config/emacs/modules/lang/elixir/config.el
Normal file
101
.config/emacs/modules/lang/elixir/config.el
Normal file
@@ -0,0 +1,101 @@
|
||||
;;; lang/elixir/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(after! projectile
|
||||
(add-to-list 'projectile-project-root-files "mix.exs"))
|
||||
|
||||
|
||||
;;
|
||||
;;; Packages
|
||||
|
||||
(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)
|
||||
:config
|
||||
(set-ligatures! 'elixir-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 '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)))
|
||||
|
||||
(when (featurep! +lsp)
|
||||
(add-hook 'elixir-mode-local-vars-hook #'lsp!)
|
||||
(after! lsp-mode
|
||||
(add-to-list 'lsp-file-watch-ignored-directories "[/\\\\]_build\\'")))
|
||||
|
||||
(after! highlight-numbers
|
||||
(puthash 'elixir-mode
|
||||
"\\_<-?[[:digit:]]+\\(?:_[[:digit:]]\\{3\\}\\)*\\_>"
|
||||
highlight-numbers-modelist)))
|
||||
|
||||
|
||||
(use-package! flycheck-credo
|
||||
:when (featurep! :checkers syntax)
|
||||
:after elixir-mode
|
||||
:config (flycheck-credo-setup))
|
||||
|
||||
|
||||
(use-package! alchemist
|
||||
:hook (elixir-mode . alchemist-mode)
|
||||
:config
|
||||
(set-lookup-handlers! 'elixir-mode
|
||||
: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
|
||||
(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)
|
||||
: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))
|
||||
9
.config/emacs/modules/lang/elixir/packages.el
Normal file
9
.config/emacs/modules/lang/elixir/packages.el
Normal file
@@ -0,0 +1,9 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/elixir/packages.el
|
||||
|
||||
;; +elixir.el
|
||||
(package! elixir-mode :pin "6bbc1e5ac46064613c982cedc60566ed077e7a58")
|
||||
(package! alchemist :pin "6f99367511ae209f8fe2c990779764bbb4ccb6ed")
|
||||
(package! exunit :pin "5bb115f3270cfe29d36286da889f0ee5bba03cfd")
|
||||
(when (featurep! :checkers syntax)
|
||||
(package! flycheck-credo :pin "e88f11ead53805c361ec7706e44c3dfee1daa19f"))
|
||||
Reference in New Issue
Block a user