Ⅰ. 插件描述
vim2hs :: Vim -> HaskellⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'goolord/vim2hs-he-is-going'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'goolord/vim2hs-he-is-going'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'goolord/vim2hs-he-is-going'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/goolord/vim2hs
Ⅳ. 文档说明
vim2hs ⦂ Vim → Haskell
"Vim to Haskell": A collection of vimscripts for Haskell development.
This is an updated fork of https://github.com/dag/vim2hs
I'm no longer convinced it is worth it to maintain this fork. For now I would actually reccommend https://github.com/neovimhaskell/haskell-vim or https://github.com/goolord/haskell-vim
Features
- Written from scratch for clean and organized code, though some parts are
borrowed from existing vimscripts. - Highlights Haskell code in GitHub Flavored Markdown, and Literate Haskell
documents as Markdown. - Improved syntax highlighting including Haddock markup in comments,
support for HSP and many quasi-quotes such as jmacro, shqq, regex, sql,
string interpolation...
- Liberal syntax highlighting for Cabal package descriptions, yielding less
false-positives for mistakes than other syntax files for Cabal. - Makes Vim aware of Haskell modules and imports allowing you to
gfwith
the cursor on a module to "go" to its source "file", etc. - Support for using HLint both as a compiler and a command, integrated into
the quickfix system in Vim. - Unicode conceals for various operators and syntax, such as lambda and
function composition. - Integrates with third-party plugins, but doesn't require them:
snippets for UltiSnips and patterns for Tabular. - Highly configurable, most of the above can be disabled if it gets in the
way.
Installation
You need at least Vim 7.3, Beyond that, just clone this repo and add it to
your 'runtimepath'.
Vundle & Pathogen are both popular tools for automating that.
Overview
Top-level Definitions
The syntax highlighting of top-level definitions are improved in vim2hs

This screenshot showcases a number of nice features:
- Type signatures are highlighted as a whole, even if spanning multiple
lines. - In function definitions, the name of the function is highlighted
differently from its arguments, even if the equal sign is on another line
(most or all other syntax highlighters get this wrong).
- Top-level definitions such as functions, classes and instances and data
declarations form folds, as you can see in thefoldcolumnto the left
of the line numbers. Closed folds are given a consistent foldtext
producing a nice overview of the code. Type signatures are intentionally
not included in the folds, so as to allow you to read the type of folded
definitions.
In this screenshot, "wide conceals" are enabled, which is what makes the
type colons and function arrows display as unicode. This option is
disabled by default, since it can mess up the visual alignment between
- To enable it like I have done here, try this:
let g:haskell_conceal_wide = 1Other options like this that are safer are enabled by default, and can be
disabled should you so desire:
" disable all conceals, including the simple ones like
" lambda and composition
let g:haskell_conceal = 0
" disable concealing of "enumerations": commatized lists like
" deriving clauses and LANGUAGE pragmas,
" otherwise collapsed into a single ellipsis
let g:haskell_conceal_enumerations = 0Quasi Quoting
Haskell supports embedding arbitrary syntax that is processed at
compile-time. Vim supports embedding external syntax highlighting.

These are all enabled by default but you can selectively opt out by adding
the relevant configuration overrides to your ~/.vimrc:
let g:haskell_quasi = 0
let g:haskell_interpolation = 0
let g:haskell_regex = 0
let g:haskell_jmacro = 0
let g:haskell_shqq = 0
let g:haskell_sql = 0
let g:haskell_json = 0
let g:haskell_xml = 0
let g:haskell_fold = 0HSP & Heist
Haskell Server Pages and
Haskell Source with XML
pre-processes literal XML in Haskell source code into function application
and vim2hs provides limited support for this syntax

This is enabled by default and can be disabled thusly:
let g:haskell_hsp = 0Heist is a simple XML/HTML
templating system. It includes a number
of pre-defined "splices" and a special syntax for "splice interpolation" in
- Included with vim2hs is a syntax file for Heist HTML templates
- automatic filetype detection for
*.tplfiles.

Strings
Haskell actually supports multi-line strings by escaping the newline,
some may consider this to be bad practice.
You can highlight string literals without a matching end quote as errors.

To disable multi-line strings, use this:
:let g:haskell_multiline_strings = 0HLint
HLint is provided as a compiler for Vim.
:compiler hlint
:makeAs a convenience there's also a command that does the above and then resets
the compiler to its previous value.
:HLintEither way any HLint suggestions and warnings will be put in Vim's quickfix
list and you can jump between them with :cn and :cp, although I
recommend setting up
FuzzyFinder and using its:FufQuickfix command instead.
UltiSnips
If you're using the
UltiSnips Vimscript, vim2hs provides
some useful snippets for Haskell programming. You can list all active
snippets (depending on your terminal emulator and vim configuration)
by hitting Ctrl+Tab in INPUT mode.
Tabular
If Tabular is installed, vim2hs
adds some named patterns useful for maintaining layout in Haskell code.
You can list all named patterns by tab-completing after entering the:Tabularize command. You probably want to configure some mappings or
commands for the ones you find useful.
To disable them, use this configuration:
let g:haskell_tabular = 0Performance
vim2hs can be pretty slow on big files. I am working on this, but if you
need a hotfix, you can disable syntax that is likely superfluous:
let g:haskell_conceal = 0
let g:haskell_quasi = 0
let g:haskell_interpolation = 0
let g:haskell_regex = 0
let g:haskell_jmacro = 0
let g:haskell_shqq = 0
let g:haskell_sql = 0
let g:haskell_json = 0
let g:haskell_xml = 0
let g:haskell_hsp = 0
let g:haskell_tabular = 0If you need even more performance, I suggest enabling:
syntax sync minlines=256
set lazyredrawFor benchmarking, use syntime. If you notice any bottlenecks, report them on the issue tracker:
:h syntime