spacevim/docs/_posts/2024-03-01-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

3.6 KiB
Raw Permalink Blame History

title categories image description permalink lang type language
使用 Vim 搭建 Elixir 开发环境
tutorials_cn
blog_cn
https://img.spacevim.org/90253911-80669300-de74-11ea-9786-4b97a4091bc6.png 介绍如何使用 SpaceVim 搭建 Elixir 的 Vim/Neovim 开发环境,以及 lang#elixir 模块所支持的功能特性、使用技巧 /cn/:title/ zh article Elixir

Blogs >> 使用 Vim 搭建 Elixir 开发环境

本文主要介绍了使用 SpaceVim 搭建 Elixir 语言开发环境的基本流程,以及所包含的功能。 lang#elixir 模块提供了 elixir 语言开发的基础环境,包括语法高亮、自动补全、语法检查、格式化等功能。 在阅读这篇文章之前,可以先阅读《使用 Vim 搭建基础的开发环境》, 对 SpaceVim 的基本使用有一个大致的了解。

elixir-ide

启用语言模块

lang#elixir 模块提供了elixir语言的支持默认情况下这个模块并未启用。需要在 SpaceVim 的配置文件里面增加如下内容:

[[layers]]
  name = "lang#elixir"

更多关于这一模块的功能可以查阅 lang#elixir 模块文档。

代码补全

autocomplete 模块时默认启用的。

代码格式化

代码格式化这一功能由 format 模块提供。默认的快捷键为 SPC b f。它将异步执行 mix format current_file 命令。 format 模块默认并未启用,如果需要使用这个功能,需要在配置文件中启用 format 模块。

[[layers]]
  name = "format"

语法检查

checkers 模块为 SpaceVim 提供了语法检查的功能,该模块默认已经载入。该模块默认使用 neomake 这一异步语法检查工具。

代码运行

默认运行代码的快捷键为 SPC l r,这个快捷键将异步执行命令 elixir current_file。输出内容将在下方的插件窗口展示。

elixir-code-runner

交互式编程

在编辑 elixir 文件时,可通过快捷键 SPC l s i 启动 elixir 交互窗口, 之后使用快捷键将代码发送至解释器。默认快捷键都以 SPC l s 为前缀。

elixir-repl

工程文件跳转

内置的项目管理文件提供了一个相关文件跳转的功能,通过在项目根目录添加配置文件 .projections.json 来定义,例如:

{
  "lib/*.ex": { "alternate": "test/{}.exs" },
  "test/*.exs": { "alternate": "lib/{}.ex" }
}

通过以上这一配置文件,就可以使用命令 :A 在源代码文件与测试文件之间快速切换,

任务管理

如果需要管理 elixir 项目的任务列表Tasks你需要在项目根目录新建一个任务配置文件 .SpaceVim.d/task.toml,示例内容如下:

[mix-test]
    command = 'mix'
    args = ['test']
[mix-coveralls]
    command = 'mix'
    args = ['coveralls']

如果需要了解 Task 管理插件更多的功能,可以查阅 任务管理器文档