spacevim/docs/_posts/2020-08-13-use-vim-as-a-elixir-ide.md
JIe 2bb7059579
Some checks failed
Detach Plugins / check (FlyGrep.vim) (push) Has been cancelled
Detach Plugins / check (GitHub.vim) (push) Has been cancelled
Detach Plugins / check (JavaUnit.vim) (push) Has been cancelled
Detach Plugins / check (SourceCounter.vim) (push) Has been cancelled
Detach Plugins / check (cpicker.nvim) (push) Has been cancelled
Detach Plugins / check (dein-ui.vim) (push) Has been cancelled
Detach Plugins / check (git.vim) (push) Has been cancelled
Detach Plugins / check (iedit.vim) (push) Has been cancelled
Detach Plugins / check (scrollbar.vim) (push) Has been cancelled
Detach Plugins / check (vim-chat) (push) Has been cancelled
Detach Plugins / check (vim-cheat) (push) Has been cancelled
Detach Plugins / check (vim-todo) (push) Has been cancelled
Detach Plugins / check (xmake.vim) (push) Has been cancelled
test / Linux (nvim, nightly) (push) Has been cancelled
test / Linux (nvim, v0.3.8) (push) Has been cancelled
test / Linux (nvim, v0.4.0) (push) Has been cancelled
test / Linux (nvim, v0.4.2) (push) Has been cancelled
test / Linux (nvim, v0.4.3) (push) Has been cancelled
test / Linux (nvim, v0.4.4) (push) Has been cancelled
test / Linux (nvim, v0.5.0) (push) Has been cancelled
test / Linux (nvim, v0.5.1) (push) Has been cancelled
test / Linux (nvim, v0.6.0) (push) Has been cancelled
test / Linux (nvim, v0.6.1) (push) Has been cancelled
test / Linux (nvim, v0.7.0) (push) Has been cancelled
test / Linux (nvim, v0.7.2) (push) Has been cancelled
test / Linux (nvim, v0.8.0) (push) Has been cancelled
test / Linux (nvim, v0.8.1) (push) Has been cancelled
test / Linux (nvim, v0.8.2) (push) Has been cancelled
test / Linux (nvim, v0.8.3) (push) Has been cancelled
test / Linux (nvim, v0.9.0) (push) Has been cancelled
test / Linux (nvim, v0.9.1) (push) Has been cancelled
test / Linux (true, vim, v7.4.052) (push) Has been cancelled
test / Linux (true, vim, v7.4.1689) (push) Has been cancelled
test / Linux (true, vim, v7.4.629) (push) Has been cancelled
test / Linux (true, vim, v8.0.0027) (push) Has been cancelled
test / Linux (true, vim, v8.0.0183) (push) Has been cancelled
test / Linux (vim, nightly) (push) Has been cancelled
test / Linux (vim, v8.0.0184) (push) Has been cancelled
test / Linux (vim, v8.0.1453) (push) Has been cancelled
test / Linux (vim, v8.1.2269) (push) Has been cancelled
test / Linux (vim, v8.2.2434) (push) Has been cancelled
test / Linux (vim, v8.2.3995) (push) Has been cancelled
test / Windows (nvim, nightly) (push) Has been cancelled
test / Windows (nvim, v0.3.8) (push) Has been cancelled
test / Windows (nvim, v0.4.2) (push) Has been cancelled
test / Windows (nvim, v0.4.3) (push) Has been cancelled
test / Windows (nvim, v0.4.4) (push) Has been cancelled
test / Windows (nvim, v0.5.0) (push) Has been cancelled
test / Windows (nvim, v0.5.1) (push) Has been cancelled
test / Windows (nvim, v0.6.0) (push) Has been cancelled
test / Windows (nvim, v0.6.1) (push) Has been cancelled
test / Windows (nvim, v0.7.0) (push) Has been cancelled
test / Windows (nvim, v0.7.2) (push) Has been cancelled
test / Windows (nvim, v0.8.0) (push) Has been cancelled
test / Windows (nvim, v0.8.1) (push) Has been cancelled
test / Windows (nvim, v0.8.2) (push) Has been cancelled
test / Windows (nvim, v0.8.3) (push) Has been cancelled
test / Windows (nvim, v0.9.0) (push) Has been cancelled
test / Windows (nvim, v0.9.1) (push) Has been cancelled
test / Windows (vim, nightly) (push) Has been cancelled
test / Windows (vim, v7.4.1185) (push) Has been cancelled
test / Windows (vim, v7.4.1689) (push) Has been cancelled
test / Windows (vim, v8.0.0027) (push) Has been cancelled
test / Windows (vim, v8.0.1453) (push) Has been cancelled
test / Windows (vim, v8.1.2269) (push) Has been cancelled
test / Windows (vim, v8.2.2434) (push) Has been cancelled
test / Windows (vim, v8.2.3995) (push) Has been cancelled
docker / docker (push) Has been cancelled
mirror / check (coding) (push) Has been cancelled
mirror / check (gitee) (push) Has been cancelled
mirror / check (gitlab) (push) Has been cancelled
init
2024-08-21 14:17:26 +08:00

111 lines
3.2 KiB
Markdown

---
title: "Use Vim as a Elixir IDE"
categories: [tutorials, blog]
image: https://img.spacevim.org/90253911-80669300-de74-11ea-9786-4b97a4091bc6.png
description: "A general guide for using SpaceVim as Elixir IDE, including layer configuration, requiems installation and usage."
type: article
comments: true
commentsID: "Use Vim as a Elixir IDE"
language: Elixir
---
# [Blogs](../blog/) >> Use Vim as Elixir IDE
This is a general guide for using SpaceVim as a Elixir IDE, including layer configuration and usage.
Each of the following sections will be covered:
![elixir-ide](https://img.spacevim.org/90253911-80669300-de74-11ea-9786-4b97a4091bc6.png)
<!-- vim-markdown-toc GFM -->
- [Enable language layer](#enable-language-layer)
- [Code completion](#code-completion)
- [Code formatting](#code-formatting)
- [Syntax lint](#syntax-lint)
- [code running](#code-running)
- [REPL support](#repl-support)
- [Jump to test file](#jump-to-test-file)
- [Task manager](#task-manager)
<!-- vim-markdown-toc -->
### Enable language layer
To add elixir language support in SpaceVim, you need to enable the `lang#elixir` layer. Press `SPC f v d` to open
SpaceVim configuration file, and add following configuration:
```toml
[[layers]]
name = "lang#elixir"
```
for more info, you can read the [lang#elixir](../layers/lang/elixir/) layer documentation.
### Code completion
The [autocomplete](../layers/autocomplete/) layer is enabled by default.
### Code formatting
Code formatting is provided by [format](../layers/format/) layer. The default key binding is `SPC b f`.
It will run `mix format current_file`. To enable code formatting feature for elixir, you need to load the format layer.
```toml
[[layers]]
name = "format"
```
### Syntax lint
Syntax lint is provided by [checkers](../layers/checkers/) layer. Error will be displayed in quickfix window
after saving current file. This layer is enabled by default.
### code running
The default code running key binding is `SPC l r`. It will run `elixir current_file` asynchronously.
And the stdout will be shown on a runner buffer.
![elixir-code-runner](https://img.spacevim.org/90252211-accce000-de71-11ea-8a93-3f07e9cc2b69.png)
### REPL support
Start a `elixir` inferior REPL process with `SPC l s i`. After the REPL process being started, you can
send code to inferior process. All key bindings prefix with `SPC l s`, including sending line, sending selection or even
send whole buffer.
![elixir-repl](https://img.spacevim.org/90252532-409eac00-de72-11ea-992e-8f0b678bdc51.png)
### Jump to test file
SpaceVim use vim-project to manager the files in a project,
you can add a `.projections.json` to the root of your project with following content:
```json
{
"lib/*.ex": {"alternate": "test/{}.exs"},
"test/*.exs": {"alternate": "lib/{}.ex"}
}
```
with this configuration, you can jump between the source code and test file via command `:A`
### Task manager
To manage the task of elixir project, you need to create a task configuration file: `.SpaceVim.d/task.toml`.
For example:
```toml
[mix-test]
command = 'mix'
args = ['test']
[mix-coveralls]
command = 'mix'
args = ['coveralls']
```
For more information about the task manager plugin, checkout the [task documentation](../documentation/#tasks).