Ⅰ. 插件描述
Vim plugin for the Elm programming languageⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'lambdatoast/elm-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'lambdatoast/elm-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'lambdatoast/elm-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/lambdatoast/elm.vim
Ⅳ. 文档说明
# elm.vim
Vim plugin for the Elm programming language.
Installation
Just like any other plugin, clone this repository into the ~/.vim/bundle directory
cd ~/.vim/bundle && \
git clone https://github.com/lambdatoast/elm.vim.git
If you are unfamiliar with this process, please refer to the Pathogen project.
System Requirements
Nothing other than vim is needed for the syntax highlighting.
For the special commands and aliases (for compilation, etc), the plugin expects the following programs to be available:
elm-make: The Elm build tool.elm-repl: The Elm REPL. The plugin sends it bits of code for evaluation.
Usage
These are the available commands. To get the most out of them,
you should create mappings according to your needs.
Compilation
:ElmMakeCurrentFilecompiles the current file.:ElmMakeMaincompiles an assumedMain.elmfile.:ElmMakeFile <filename>compilesfilename.
Evaluation
:ElmEvalLineevaluates the current line and puts the result as a
comment in a new line below it.:ElmEvalSelectionevaluates a visual mode selection.
REPL
:ElmReplswitches toelm-repl, when closing the REPL you'll get back to vim.
Example mappings
I use the following mappings in my .vimrc at the moment:
nnoremap <leader>el :ElmEvalLine<CR>
vnoremap <leader>es :<C-u>ElmEvalSelection<CR>
nnoremap <leader>em :ElmMakeCurrentFile<CR>
Example autocommands
Vim autocommands can make your life a lot easier.
These are just some examples of what I use sometimes:
Compiling the current file on write:
:au BufWritePost *.elm ElmMakeCurrentFile
Usually more useful: Compiling a specific file, e.g. "Main.elm", on file write to any file in the project:
:au BufWritePost *.elm ElmMakeFile("Main.elm")
Remember you can clear all these afterwards, with e.g. :au! BufWritePost *.elm
TODO
- Integration with Elm docs.