Ⅰ. 插件描述
Vim integration for the Elixir formatter.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mhinz/vim-mix-format'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mhinz/vim-mix-format'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mhinz/vim-mix-format'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mhinz/vim-mix-format
Ⅳ. 文档说明
# vim-mix-format
Elixir 1.6 introduced the formatter: mix format. This plugin makes it easy to
run the formatter asynchronously from within Vim 8 and Neovim.

Installation
Use your favorite plugin manager, e.g.
vim-plug:
Plug 'mhinz/vim-mix-format'
Commands
- To format the current file, use
:MixFormat. Use:verb MixFormatto see the
exact shell command used. - The formatter is not perfect yet, so
:MixFormatDiffwill open a diff window
that can be used for previewing the changes or picking only those that seem
reasonable.
dp pushes changes from the diff window to the source file. q closes the diff
]cand[cjump between the changes.
If you're not used to Vim's diff mode, [watch this
screencast](http://vimcasts.org/episodes/comparing-buffers-with-vimdiff).
Options
Automatically format on saving.
let g:mix_format_on_save = 1Set options for the formatter. See
mix help formatin the shell.let g:mix_format_options = '--check-equivalent'- By default this plugin opens a window containing the stacktrace on errors.
With this option enabled, there will be just a short message in the
command-line bar. The stacktrace can still be looked up via :messages.
let g:mix_format_silent_errors = 1- If you're not using Elixir 1.6 in your project, but want to use the formatter
anyway, you can specify the bin directory of an alternative Elixir installation:
let g:mix_format_elixir_bin_path = '~/repo/elixir/bin'Customization
When using :MixFormatDiff, a new diff window will be opened and an user event
is emitted. It can be used to set different settings or switch back to the
source window:
autocmd User MixFormatDiff wincmd pFeedback
If you like this plugin, star it! It helps me deciding which projects to spend
more time on.