| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
A TextMate / Sublime Text Bundle for the Elixir programming language.
It provides syntax highlighting, snippets, and commands to run tests, compile, and format code. Contributions and extensions are welcome!
Note: For a package that provides tighter and more up-to-date integration with Sublime Text 4, see ElixirSyntax.
If you are using TextMate 2 you can install from Preferences → Bundles. To install manually type the following commands in your shell:
mkdir -p ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles cd ~/Library/Application\ Support/TextMate/Pristine\ Copy/Bundles git clone git://github.com/elixir-editors/elixir-tmbundle Elixir.tmbundle
If you are using Sublime Text 3, type the following commands in your shell:
cd ~/.config/sublime-text-3/Packages # If you are on Linux cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages # If you are on OS X cd %HOMEPATH%\AppData\Roaming\Sublime^ Text^ 3\Packages # If you are on Windows Vista or above cd %HOMEPATH%\Application^ Data\Sublime^ Text^ 3\Packages # If you are on Windows XP git clone git://github.com/elixir-editors/elixir-tmbundle Elixir
You can now use Elixir's color syntax in files. In some cases, you should restart Sublime Text to make changes work.
Type the following commands to setup the bundle for TextMate 1:
mkdir -p ~/Library/Application\ Support/TextMate/Bundles cd !$ git clone git://github.com/elixir-editors/elixir-tmbundle Elixir.tmbundle cd Elixir.tmbundle git checkout tm1 osascript -e 'tell app "TextMate" to reload bundles'
If you are using Sublime Text 2, type the following commands in your shell:
cd ~/.config/sublime-text-2/Packages # If you are on Linux cd ~/Library/Application\ Support/Sublime\ Text\ 2/Packages # If you are on OS X cd %HOMEPATH%\AppData\Roaming\Sublime^ Text^ 2\Packages # If you are on Windows Vista or above cd %HOMEPATH%\Application^ Data\Sublime^ Text^ 2\Packages # If you are on Windows XP git clone git://github.com/elixir-editors/elixir-tmbundle Elixir cd Elixir git checkout tm1
Elixir v1.6 includes a code formatter. This package includes super+shift+c as a keybinding to automatically save and format the current file you are working on. If the file has invalid syntax, an alert will appear.
You can also add your own keybindings as follows:
{ "keys": ["super+e"], "command": "mix_format_file" }
You can also set up the package to automatically format the file on save. To do this, go to Preferences -> Package Settings -> Elixir -> Settings and add "mix_format_on_save": true.
In TextMate, the commands run Mix in the project of the current file (the closest folder with a mix.exs), with the Elixir version set for the project by mise when it is installed, and otherwise with the elixir and mix found on the PATH set in Preferences → Variables.
| Command | Key | |
|---|---|---|
| Run | ⌘R | Runs the tests of a test file, or of the test of a file in lib. Runs a script with mix run in a project, and with elixir outside of one. |
| Run Test at Caret | ⇧⌘R | Runs the test or describe block at the caret. |
| Run All Tests, Run Failed Tests, Run Stale Tests | ⌃\ | Runs mix test, mix test --failed, or mix test --stale. |
| Compile | ⌘B | Compiles the project and marks its warnings and errors in the gutter. Click a mark to read its message, and press F3 to jump to the next mark. |
| Format Document | ⌃⇧H | Formats the document like mix format, with the settings and plugins in the project’s .formatter.exs (such as the HEEx formatter). |
| Documentation for Word | ⌃H | Shows the documentation of the module, function, type, or callback at the caret (or of the selection, such as Enum.map/2), with its specs and a link to its source. Code that names other modules and functions links to their documentation. |
| Go to Definition | ⌃⌘J | Opens where the module, function, HEEx component, or module attribute at the caret is defined, in the project, its dependencies, Elixir, or Erlang/OTP. |
| Go to Test or Implementation | ⌥⌘↓ | Switches between lib/my_app/user.ex and test/my_app/user_test.exs, and offers to create a missing test. |
| Open IEx in Terminal | Runs iex -S mix in the project in a new Terminal window. |
Documentation and definitions follow the aliases and imports in scope, including those that use brings, such as Phoenix’s use MyAppWeb, :live_view or a test’s use MyAppWeb.ConnCase. They come from the project’s compiled code, as mix help does, while the project’s own files are searched as they are now. In a callback implementation such as a LiveView’s mount/3, the documentation is the callback’s.
Output appears in a window, in color, and its file references, such as test/my_app/user_test.exs:12 or those in stacktraces of dependencies and Elixir itself, open in TextMate when clicked.
Files are formatted when saved, if their project has a .formatter.exs. These variables, set in Preferences → Variables or in a project’s .tm_properties, change what happens:
TextMate (from the kaffeinated-dev fork, 2.0.23+kaffeinated.2) runs Expert, the Elixir language server, for the Elixir files of a Mix project: it gets the files as they are edited, and its errors and warnings appear as marks in the gutter without saving. Click a mark to read it, and press F3 to go to the next one. Files in deps and in umbrella applications belong to the project around them.
With the language server, completion (⎋) suggests what Expert does first, such as the functions of Enum after Enum.ma. The Language Server bundle has the commands that ask Expert (and the language servers of other languages): Complete (⌥⎋), Documentation Tooltip (⌃⌥H), Go to Definition (⌃⌘J, where this bundle’s own Go to Definition comes first), Find References (⇧⌃⌘F), Go to Symbol in Project (⌥⌘T), Quick Fix (⌥↩), and Rename Symbol (⌃⌘E, which Expert doesn’t do yet).
Install Expert with mise use -g expert, or put it on the PATH set in Preferences → Variables. The first time Expert opens a project with a new Elixir version, it builds its engine, which takes about a minute. Set TM_ELIXIR_LANGUAGE_SERVER to the command of another language server, or TM_DISABLE_LANGUAGE_SERVER = true (in Preferences → Variables or a project’s .tm_properties) to turn it off.
Snippets expand in Elixir code and in {expressions} of templates, not in strings, comments, or template text. Type the trigger and press ⇥.
defmod names the module after the file: lib/my_app/accounts/user.ex becomes MyApp.Accounts.User, lib/my_app_web/live/user_live/index.ex becomes MyAppWeb.UserLive.Index.
Grammar changes are covered by scope tests in test/syntax. Each file starts with a # SYNTAX TEST "source.elixir" header, and lines with ^ markers assert the scopes of the source line above them (see vscode-tmgrammar-test). Run them with:
npm install npm test
test/editing checks indentation, folding, and the symbol list of the files next to it. It computes them from the preferences the way TextMate does, including how it picks a preference for a scope, so every line of those files must be indented as it is, and the folds and symbols must match the .folds and .symbols snapshots. After an intended change, rewrite the snapshots with node test/editing/test.js --update and review the diff.
npm run test:commands runs the commands the way TextMate does in a new Mix project, and tests the Elixir files in Support/lib/textmate that format their output, format documents, and set the gutter marks.
npm run test:snippets expands every snippet with its default text, as TextMate does, and checks with Elixir that the code parses and is already formatted.
The tests use the HTML grammar from textmate/html.tmbundle, pinned in test/fetch-grammars to the revision that TextMate installs.
| Back | FazBrowse Home | New Git URL |