GitHub - mhinz/vim-mix-format: Vim integration for the Elixir formatter.
source link: https://github.com/mhinz/vim-mix-format
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
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 MixFormat
to see the exact shell command used. -
The formatter is not perfect yet, so
:MixFormatDiff
will 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 window.]c
and[c
jump between the changes.If you're not used to Vim's diff mode, watch this screencast.
Options
-
Automatically format on saving.
let g:mix_format_on_save = 1
-
Set options for the formatter. See
mix help format
in 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 p
Feedback
If you like this plugin, star it! It helps me deciding which projects to spend more time on.
Recommend
-
164
Intro Basics
-
165
-
170
README.md
-
115
-
117
README.md
-
87
dotfiles - :smiling_imp: Vim, emacs, git, zsh, tmux, and other goodies.
-
45
README.md vim-tree vim-tree integrates good old tree(1) into Vim and Nvim for al...
-
14
In recent years, many language ecosystems have developed automatic code formatters to reduce the mental overhead of code readers and therefore to share code more easily. These tools work by ensuring that all code written...
-
3
A Vim plugin for formatting saved JSON file. : vim online json-formatter.vim : A Vim plugin for formatting saved JSON file. script karma Rating 3/5, Downl...
-
4
Pretty format JSON in Vim Pretty format JSON in Vim Sep 20, 2018 command! PrettyJSON %!python -m json.tool
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK