3.3 KiB
title | categories | image | description | type | comments | commentsID | ||
---|---|---|---|---|---|---|---|---|
Use Vim as a Elixir IDE |
|
https://user-images.githubusercontent.com/13142418/90253911-80669300-de74-11ea-9786-4b97a4091bc6.png | A general guide for using SpaceVim as Elixir IDE, including layer configuration, requiems installation and usage. | article | true | Use Vim as a Elixir IDE |
Blogs >> Use Vim as a 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:
- Enable language layer
- Code completion
- Code formatting
- Syntax lint
- code running
- REPL support
- Jump to test file
- Task manager
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:
[[layers]]
name = "lang#elixir"
for more info, you can read the lang#elixir layer documentation.
Code completion
The autocomplete layer is enabled by default.
Code formatting
Code formatting is provided by 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.
[[layers]]
name = "format"
Syntax lint
Syntax lint is provided by 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.
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.
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:
{
"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:
[mix-test]
command = 'mix'
args = ['test']
[mix-coveralls]
command = 'mix'
args = ['coveralls']
For more information about the task manager plugin, checkout the task documentation.