mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-04-14 15:19:12 +08:00
Add post about using vim as elixir ide (#3705)
This commit is contained in:
parent
543a9913e8
commit
6d951a395c
109
docs/_posts/2020-08-13-use-vim-as-a-elixir-ide.md
Normal file
109
docs/_posts/2020-08-13-use-vim-as-a-elixir-ide.md
Normal file
@ -0,0 +1,109 @@
|
||||
---
|
||||
title: "Use Vim as a Elixir IDE"
|
||||
categories: [tutorials, blog]
|
||||
image: https://user-images.githubusercontent.com/13142418/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"
|
||||
---
|
||||
|
||||
# [Blogs](../blog/) >> 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:
|
||||
|
||||

|
||||
|
||||
<!-- 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.
|
||||
|
||||

|
||||
|
||||
### 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:
|
||||
|
||||
```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).
|
Loading…
x
Reference in New Issue
Block a user