Ⅰ. 插件描述
Vim plugin to infer and insert Haskell module nameⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'feuerbach/vim-hs-module-name'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'feuerbach/vim-hs-module-name'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'feuerbach/vim-hs-module-name'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/feuerbach/vim-hs-module-name
Ⅳ. 文档说明
# hs-module-name Vim plugin
This vim plugin can automatically figure out and insert the name of a Haskell
module based on the filename.
Installation
This plugin is pathogen-compatible. If you use pathogen, just clone
or copy this repo under ~/.vim/bundle.
Otherwise, use something like
cp -r vim-hs-module-name/* ~/.vim/
Usage
Automatic insertion
When you create a new .hs file, the header
module Foo.Bar where
is automatically inserted, where Foo.Bar is the module name inferred from the
file name.
Set the g:hs_module_no_auto variable to disable this.
Manual insertion
When you are in a buffer with the haskell filetype, press M to insert the
module header as described above.
To use a different key sequence instead of M, set the g:hs_module_mapping
variable to the desired key sequence.
Set the g:hs_module_no_mappings variable to disable this.
Command
If you want to set up other bindings or hooks, use the:InsertHaskellModuleName command.
How the inference works
The components of the module name are assumed to be the largest
prefix of the file path components where all the components start with
capital letters.
E.g. for the file
/home/User/project/src/Foo/Bar.hs
the module name is inferred to be Foo.Bar. This works pretty well in
practice.