vim2hs ⦂ Vim → Haskell"Vim to Haskell": A collection of vimscripts for Haskell development.
gf with
the cursor on a module to "go" to its source "file", etc.You need at least Vim 7.3, and for the HPaste command Python 2, not too
ancient. Beyond that, just clone this repo and add it to your
'runtimepath'. Vundle is great for
automating that, Pathogen is also
popular.
Here are some other Vimscripts that complement vim2hs nicely:
The syntax highlighting of top-level definitions are improved in vim2hs:

This screenshot showcases a number of nice features:
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 lines. 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
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
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 - I have yet to figure out how to highlight the body of XML elements differently while still highlighting the attributes as Haskell.

This is enabled by default and can be disabled thusly:
let g:haskell_hsp = 0
Heist is a simple XML/HTML
templating system; simple enough that you could simply use the xml or
html filetype in Vim for these templates. However, it includes a number
of pre-defined "splices" and a special syntax for "splice interpolation" in
attributes. Included with vim2hs is a syntax file for Heist HTML templates
and automatic filetype detection for *.tpl files.

Haskell actually supports multi-line strings by escaping the newline, but I don't think it's a widely used feature and I think quasi quoting is better for such purposes. Thus, by default, I have opted to keep string literals from crossing lines so half your source file doesn't highlight as a string while you're entering one. Instead, string literals without a matching end quote highlight as errors.

There is a configuration option for this. To enable multi-line strings, use this:
:let g:haskell_multiline_strings = 1
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.
To pastebin the contents of the current buffer do this:
:HPaste
The newly created paste URL will be put in the + register, meaning your
normal desktop clipboard.
Alternatively, you can select a range of lines with Vim's VISUAL modes and type the same as above, which should result in this:
:'<,'>HPaste
Which of course will paste the selected lines only.
If you get tired of entering your author name every time you can configure it globally like so:
let g:hpaste_author = 'donri'
If you're using the excellent
UltiSnips Vimscript, vim2hs provides
some useful snippets for Haskell programming. You can list all active
snippets by hitting Ctrl+Tab in INPUT mode.
Another useful Vimscript is
Tabular. If it's 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
Vim Script
90.8%
Haskell
7.3%
Python
1.9%
vim2hs ⦂ Vim → Haskell"Vim to Haskell": A collection of vimscripts for Haskell development.
gf with
the cursor on a module to "go" to its source "file", etc.You need at least Vim 7.3, and for the HPaste command Python 2, not too
ancient. Beyond that, just clone this repo and add it to your
'runtimepath'. Vundle is great for
automating that, Pathogen is also
popular.
Here are some other Vimscripts that complement vim2hs nicely:
The syntax highlighting of top-level definitions are improved in vim2hs:

This screenshot showcases a number of nice features:
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 lines. 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
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
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 - I have yet to figure out how to highlight the body of XML elements differently while still highlighting the attributes as Haskell.

This is enabled by default and can be disabled thusly:
let g:haskell_hsp = 0
Heist is a simple XML/HTML
templating system; simple enough that you could simply use the xml or
html filetype in Vim for these templates. However, it includes a number
of pre-defined "splices" and a special syntax for "splice interpolation" in
attributes. Included with vim2hs is a syntax file for Heist HTML templates
and automatic filetype detection for *.tpl files.

Haskell actually supports multi-line strings by escaping the newline, but I don't think it's a widely used feature and I think quasi quoting is better for such purposes. Thus, by default, I have opted to keep string literals from crossing lines so half your source file doesn't highlight as a string while you're entering one. Instead, string literals without a matching end quote highlight as errors.

There is a configuration option for this. To enable multi-line strings, use this:
:let g:haskell_multiline_strings = 1
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.
To pastebin the contents of the current buffer do this:
:HPaste
The newly created paste URL will be put in the + register, meaning your
normal desktop clipboard.
Alternatively, you can select a range of lines with Vim's VISUAL modes and type the same as above, which should result in this:
:'<,'>HPaste
Which of course will paste the selected lines only.
If you get tired of entering your author name every time you can configure it globally like so:
let g:hpaste_author = 'donri'
If you're using the excellent
UltiSnips Vimscript, vim2hs provides
some useful snippets for Haskell programming. You can list all active
snippets by hitting Ctrl+Tab in INPUT mode.
Another useful Vimscript is
Tabular. If it's 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
Vim Script
90.8%
Haskell
7.3%
Python
1.9%