vim2hs


Ⅰ. 插件描述

vim2hs :: Vim -> Haskell

Ⅱ. 基本信息

创建日期:  2012-09-13
使用用户:  1
Github星:  5
插件作者:  Zachary Churchill

Ⅲ. 安装方法

使用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 gf with
    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

Bindings screenshot

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 the foldcolumn to 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

  1. To enable it like I have done here, try this:
let g:haskell_conceal_wide = 1

Other 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 = 0

Quasi Quoting

Haskell supports embedding arbitrary syntax that is processed at
compile-time. Vim supports embedding external syntax highlighting.

Quasi Quotes screenshot

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          = 0

HSP & 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

HSP screenshot

This is enabled by default and can be disabled thusly:

let g:haskell_hsp = 0

Heist is a simple XML/HTML
templating system. It includes a number
of pre-defined "splices" and a special syntax for "splice interpolation" in

  1. Included with vim2hs is a syntax file for Heist HTML templates
  2. automatic filetype detection for *.tpl files.

Heist screenshot

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.

Strings screenshot

To disable multi-line strings, use this:

:let g:haskell_multiline_strings = 0

HLint

HLint is provided as a compiler for Vim.

:compiler hlint
:make

As a convenience there's also a command that does the above and then resets
the compiler to its previous value.

:HLint

Either 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 = 0

Performance

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       = 0

If you need even more performance, I suggest enabling:

syntax sync minlines=256
set lazyredraw

For benchmarking, use syntime. If you notice any bottlenecks, report them on the issue tracker:

:h syntime

添加新评论