GitHub - elixir-editors/emacs-elixir: Emacs major mode for Elixir
source link: https://github.com/elixir-editors/emacs-elixir
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Elixir Mode
Provides font-locking, indentation and navigation support for the Elixir programming language.
Installation
Via package.el
package.el
is the built-in package manager in Emacs.
elixir-mode
is available on the two major community maintained repositories -
MELPA STABLE and MELPA.
You can install elixir-mode
with the following command:
M-x package-install [RET] elixir-mode [RET]
or by adding this bit of Emacs Lisp code to your Emacs initialization file
(.emacs
or init.el
):
(unless (package-installed-p 'elixir-mode)
(package-install 'elixir-mode))
If the installation doesn't work try refreshing the package list:
M-x package-refresh-contents [RET]
Keep in mind that MELPA packages are built automatically from
the master
branch, meaning bugs might creep in there from time to
time. Never-the-less, installing from MELPA is the recommended way of
obtaining Elixir-Mode
, as the master
branch is normally quite stable and
"stable" (tagged) builds are released somewhat infrequently.
With the most recent builds of Emacs, you can pin Elixir-Mode
to always
use MELPA Stable by adding this to your Emacs initialization:
Manual
You can install Elixir-Mode
manually by placing Elixir-Mode
on your load-path
and
require
ing it. Many people favour the folder ~/.emacs.d/vendor
.
(add-to-list 'load-path "~/.emacs.d/vendor")
(require 'elixir-mode)
Usage
Interactive Commands
Command (For the M-x prompt.) |
Description |
---|---|
elixir-mode |
Switches to elixir-mode. |
elixir-mode-open-github |
Open the GitHub page for Elixir. |
elixir-mode-open-elixir-home |
Go to Elixir README in the browser. |
elixir-mode-open-docs-master |
Open the Elixir documentation for the master. |
elixir-mode-open-docs-stable |
Open the Elixir documentation for the latest stable release. |
elixir-mode-show-version |
Print version info for elixir-mode. |
Configuration
Any file that matches the glob *.ex[s]
or *.elixir
is
automatically opened in elixir-mode, but you can change this
functionality easily.
;; Highlights *.elixir2 as well
(add-to-list 'auto-mode-alist '("\\.elixir2\\'" . elixir-mode))
Keymapping
Keymaps can be added to the elixir-mode-map
variable.
Pairing
Smartparens has direct support for Elixir.
Alternatively, if you want to use ruby-end-mode
, you can add the following to your elixir-mode-hook
:
(add-to-list 'elixir-mode-hook
(defun auto-activate-ruby-end-mode-for-elixir-mode ()
(set (make-variable-buffer-local 'ruby-end-expand-keywords-before-re)
"\\(?:^\\|\\s-+\\)\\(?:do\\)")
(set (make-variable-buffer-local 'ruby-end-check-statement-modifiers) nil)
(ruby-end-mode +1)))
Notes
This package is tested only with a single version of OTP and 3 versions of Elixir. Please, always report versions (Emacs, Elixir and Erlang/OTP) when raising issues.
Elixir Tooling Integration
If you looking for elixir tooling integration for Emacs, check: alchemist.el
You can use web-mode.el to edit elixir templates (eex files).
mix.el provides a minor mode for integration with Mix, a build tool that ships with Elixir.
Elixir Format
M-x elixir-format
Add elixir-mode hook to run elixir format on file save
;; Create a buffer-local hook to run elixir-format on save, only when we enable elixir-mode.
(add-hook 'elixir-mode-hook
(lambda () (add-hook 'before-save-hook 'elixir-format nil t)))
To use a .formatter.exs
you can either set elixir-format-arguments
globally to a path like this:
(setq elixir-format-arguments (list "--dot-formatter" "/path/to/.formatter.exs"))
or you set elixir-format-arguments
in a hook like this:
(add-hook 'elixir-format-hook (lambda ()
(if (projectile-project-p)
(setq elixir-format-arguments
(list "--dot-formatter"
(concat (locate-dominating-file buffer-file-name ".formatter.exs") ".formatter.exs")))
(setq elixir-format-arguments nil))))
In this example we use Projectile to determine if we are in a project and then set elixir-format-arguments
accordingly.
Please note that this code snippet may cause unhappiness if there is no .formatter.exs
file available.
History
This mode is based on the Emacs mode by secondplanet.
Contributing
Please read CONTRIBUTING.md for guidelines on how to contribute to this project.
License
Copyright © 2011-2017 Samuel Tonini, Matt DeBoard, Andreas Fuchs, secondplanet and contributors.
Distributed under the GNU General Public License, version 3
Recommend
-
190
vue-mode Emacs major mode for vue.js based on mmm-mode. Preview Install Emacs users may install the package from MELPA. vue-mode should then be activated on all files with a .vue
-
100
I've taken up maintaining hy-mode - a major mode for lispy python. I narrate working through specific problems in...
-
149
Emacs support for Stan 2021-01-30 Version 10.2.1 bugfix for #64 2020-08-30 Version 10.2.0 update for Stan version 2.24 Packages an...
-
157
Haskell Mode for Emacs This is an Emacs mode for editing, developing and debugging Haskell programs. Home page. I just want to thank everybody invol...
-
101
elm-mode Elm mode for Emacs. Features Syntax highlighting. Intelligent indentation. Integration with elm-make Integration with elm-repl Integration with
-
169
An Emacs major mode for Hy, a lisp embedded in python. Provides autocompletion, documentation lookup, and all features required to make developing in Hy enjoyable and product...
-
91
Emacs mode for GNU APL Author contact information Elias Mårtenson Email: [email protected] Installing gnu-apl-mode To install, add the f...
-
5
Files Permalink Latest commit message Commit time
-
10
Emacs major-mode to work with Beancount ledger files This package provides beancount-mode an Emacs major-mode implementing syntax...
-
8
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK