Update dotfiles

This commit is contained in:
viktorbarzin 2018-10-01 19:00:02 +03:00
parent 560e62cbba
commit 9fc835348e
68 changed files with 1317 additions and 0 deletions

View file

@ -0,0 +1,10 @@
Copyright (c) 2014, raichoo
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -0,0 +1,142 @@
Syntax Highlighting and Indentation for Haskell and Cabal
=========================================================
I was unhappy with the Haskell scripts that are
shipped with vim, therefore I decided to make my
own based on [idris-vim][].
I hope you find this useful.
![Screenshot](http://raichoo.github.io/images/haskell-vim.png)
## Features
* Covers a broader spectrum of keywords
* Highlighting for new features like type families, pattern synonyms, arrow syntax, recursive do, role annotations, QuasiQuotation
* More contextual highlighting (e.g. highlight 'as' or 'family' only in appropriate places)
* Smarter indentation
* Better Cabal support
## Installation
I recommend using [Pathogen][] for installation. Simply clone
this repo into your `~/.vim/bundle` directory and you are ready to go.
cd ~/.vim/bundle
git clone https://github.com/neovimhaskell/haskell-vim.git
Be sure that the following lines are in your
`.vimrc`
syntax on
filetype plugin indent on
### Manual Installation
Copy content into your `~/.vim` directory.
## Configuration
### Features
To enable the features you would like to use, just add the according line to your
`.vimrc`.
```viml
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
```
### Highlighting
`haskell-vim` has an opinionated highlighting. If you do not like that you can switch to
a more traditional mode by setting `g:haskell_classic_highlighting` to `1`.
Disabling Template Haskell and Quasiquoting syntax is possible by setting
`g:haskell_disable_TH` to `1`.
### Indentation
To configure indentation in `haskell-vim` you can use the following variables to change indentation depth, just add the according line to your `.vimrc`.
If you dislike how indentation works you can disable it by setting `g:haskell_indent_disable` to
`1`.
Additionally you can use the
[vim-hindent](https://github.com/alx741/vim-hindent) plugin to achieve automatic
indentation using *hindent*.
#### Haskell
* `let g:haskell_indent_if = 3`
if bool
>>>then ...
>>>else ...
* `let g:haskell_indent_case = 2`
case xs of
>>[] -> ...
>>(y:ys) -> ...
* `let g:haskell_indent_let = 4`
let x = 0 in
>>>>x
* `let g:haskell_indent_where = 6`
where f :: Int -> Int
>>>>>>f x = x
* `let g:haskell_indent_before_where = 2`
foo
>>where
* `let g:haskell_indent_after_bare_where = 2`
where
>>foo
* `let g:haskell_indent_do = 3`
do x <- a
>>>y <- b
* `let g:haskell_indent_in = 1`
let x = 1
>in x
* `let g:haskell_indent_guard = 2`
f x y
>>|
`haskell-vim` also supports an alterative style for `case` indentation.
* `let g:haskell_indent_case_alternative = 1`
f xs ys = case xs of
>>[] -> ...
>>(y:ys) -> ...
#### Cabal
* `let g:cabal_indent_section = 2` (limited to max. 4 spaces)
executable name
>>main-is: Main.hs
[Pathogen]: https://github.com/tpope/vim-pathogen
[idris-vim]: https://github.com/idris-hackers/idris-vim

View file

@ -0,0 +1,3 @@
setlocal comments=s1fl:{-,mb:-,ex:-},:--
setlocal iskeyword+=-,.,*
setlocal commentstring=--\ %s

View file

@ -0,0 +1,2 @@
setlocal comments=s1fl:{-,mb:\ \ ,ex:-},:--
setlocal iskeyword+='

View file

@ -0,0 +1,159 @@
*haskell-vim.txt* Last Change 2016 March 14
===============================================================================
===============================================================================
===============================================================================
CONTENTS *haskell-vim-contents*
1. Features |haskell-vim-features|
2. Configuration |haskell-vim-configuration|
3. Highlighting |haskell-vim-indentation|
===============================================================================
FEATURES *haskell-vim-features*
* Covers a broader spectrum of keywords
* Highlighting for new features like type families, pattern synonyms,
arrow syntax, recursive do, role annotations, QuasiQuotation
* More contextual highlighting
(e.g. highlight "as" or "family" only in appropriate places)
* Smarter indentation
* Better Cabal support
===============================================================================
CONFIGURATION *haskell-vim-configuration*
To enable the features you would like to use, just add the according line to
your `.vimrc`.
===============================================================================
HIGHLIGHTING *haskell-vim-highlighting*
`haskell-vim` can highlight additional keywords. This is enabled by setting
the according variable to 1 in the `.vimrc`.
* |haskell-vim-enable-quantification|
* |haskell-vim-enable-recursivedo|
* |haskell-vim-enable-arrowsyntax|
* |haskell-vim-enable-pattern-synonyms|
* |haskell-vim-enable-typeroles|
* |haskell-vim-enable-static-pointers|
* |haskell-vim-classic-highlighting|
* |haskell-vim-disable-TH|
*haskell-vim-enable-quantification*
`g:haskell_enable_quantification` Enables highlighting of `forall`.
*haskell-vim-enable-recursivedo*
`g:haskell_enable_recursivedo` Enables highlighting of `mdo` and `rec`.
*haskell-vim-enable-arrowsyntax*
`g:haskell_enable_arrowsyntax` Enables highlighting of `proc`.
*haskell-vim-enable-pattern-synonyms*
`g:haskell_enable_pattern_synonyms` Enables highlighting of the `pattern` keyword.
*haskell-vim-enable-typeroles*
`g:haskell_enable_typeroles` Enables highlighting of the `role` keyword, as
well as `phantom`, `norminal` and
`representational`.
*haskell-vim-enable-static-pointers*
`g:haskell_enable_static_pointers` Enables highlighting of the `static` keyword.
*haskell-vim-classic-highlighting*
`haskell-vim` has an opinionated highlighting. If you do not like that you can
switch to a more traditional mode by setting `g:haskell_classic_highlighting`
to 1.
*haskell-vim-disable-TH*
Disabling Template Haskell and Quasiquoting syntax is possible by setting
`g:haskell_disable_TH` to `1`.
===============================================================================
INDENTATION *haskell-vim-indentation*
To configure indentation in `haskell-vim` you can use the following variables to
change indentation depth, just add the according line to your `.vimrc`.
You can disable the indentation by setting `g:haskell_indent_disable` to `1`.
Haskell~
* |haskell-vim-indent-if|
* |haskell-vim-indent-case|
* |haskell-vim-indent-let|
* |haskell-vim-indent-where|
* |haskell-vim-indent-before-where|
* |haskell-vim-indent-after-bare-where|
* |haskell-vim-indent-do|
* |haskell-vim-indent-in|
* |haskell-vim-indent-guard|
*haskell-vim-indent-if*
* let g:haskell_indent_if = 3 >
if bool
>>>then ...
>>>else ...
<
*haskell-vim-indent-case*
* let g:haskell_indent_case = 2 >
case xs of
>>[] -> ...
>>(y:ys) -> ...
<
*haskell-vim-indent-let*
* let g:haskell_indent_let = 4 >
let x = 0 in
>>>>x
<
*haskell-vim-indent-where*
* let g:haskell_indent_where = 6 >
where f :: Int -> Int
>>>>>>f x = x
<
*haskell-vim-indent-before-where*
* let g:haskell_indent_before_where = 2 >
foo
>>where
<
*haskell-vim-indent-after-bare-where*
* let g:haskell_indent_after_bare_where = 2 >
where
>>foo
<
*haskell-vim-indent-do*
* let g:haskell_indent_do = 3 >
do x <- a
>>>y <- b
<
*haskell-vim-indent-in*
* let g:haskell_indent_in = 1 >
let x = 1
>in x
<
*haskell-vim-indent-guard*
* let g:haskell_indent_guard = 2 >
f x y
>>|
<
Cabal~
* |cabal-vim-indent-section|
*cabal-vim-indent-section*
* let g:cabal_indent_section = 2 (limited to max. 4 spaces) >
executable name
>>main-is: Main.hs
<

View file

@ -0,0 +1,3 @@
au BufRead,BufNewFile *.hsc set filetype=haskell
au BufRead,BufNewFile *.bpk set filetype=haskell
au BufRead,BufNewFile *.hsig set filetype=haskell

View file

@ -0,0 +1,31 @@
" indentation for cabal
"
" author: raichoo (raichoo@googlemail.com)
"
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
if !exists('g:cabal_indent_section')
"executable name
">>main-is: Main.hs
">>hs-source-dirs: src
let g:cabal_indent_section = 2
elseif exists('g:cabal_indent_section') && g:cabal_indent_section > 4
let g:cabal_indent_section = 4
endif
setlocal indentexpr=GetCabalIndent()
setlocal indentkeys=!^F,o,O,<CR>
function! GetCabalIndent()
let l:prevline = getline(v:lnum - 1)
if l:prevline =~ '\C^\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\)'
return g:cabal_indent_section
else
return match(l:prevline, '\S')
endif
endfunction

View file

@ -0,0 +1,509 @@
" indentation for haskell
"
" author: raichoo (raichoo@googlemail.com)
"
" Modify g:haskell_indent_if and g:haskell_indent_case to
" change indentation for `if'(default 3) and `case'(default 5).
" Example (in .vimrc):
" > let g:haskell_indent_if = 2
if exists('b:did_indent')
finish
endif
if get(g:, 'haskell_indent_disable', 0)
finish
endif
let b:did_indent = 1
if !exists('g:haskell_indent_if')
" if x
" >>>then ...
" >>>else ...
let g:haskell_indent_if = 3
endif
if !exists('g:haskell_indent_case')
" case xs of
" >>[] -> ...
" >>(y:ys) -> ...
let g:haskell_indent_case = 2
endif
if !exists('g:haskell_indent_let')
" let x = 0 in
" >>>>x
"
" let x = 0
" y = 1
let g:haskell_indent_let = 4
endif
if !exists('g:haskell_indent_where')
" where f :: Int -> Int
" >>>>>>f x = x
let g:haskell_indent_where = 6
endif
if !exists('g:haskell_indent_do')
" do x <- a
" >>>y <- b
let g:haskell_indent_do = 3
endif
if !exists('g:haskell_indent_in')
" let x = 1
" >in x
let g:haskell_indent_in = 1
endif
if !exists('g:haskell_indent_guard')
" f x y
" >>|
let g:haskell_indent_guard = 2
endif
setlocal indentexpr=GetHaskellIndent()
setlocal indentkeys=!^F,o,O,0{,0},0(,0),0[,0],0,,0=where,0=let,0=deriving,0=in\ ,0=::\ ,0=\-\>\ ,0=\=\>\ ,0=\|\ ,=\=\
function! s:isInBlock(hlstack)
return index(a:hlstack, 'haskellDelimiter') > -1 || index(a:hlstack, 'haskellParens') > -1 || index(a:hlstack, 'haskellBrackets') > -1 || index(a:hlstack, 'haskellBlock') > -1 || index(a:hlstack, 'haskellBlockComment') > -1 || index(a:hlstack, 'haskellPragma') > -1
endfunction
function! s:stripComment(line)
if a:line =~ '^\s*--\(-*\s\+\|$\)'
return ''
else
let l:stripped = split(a:line, '-- ')
if len(l:stripped) > 1
return substitute(l:stripped[0], '\s*$', '', '')
else
return a:line
endif
endif
endfunction
function! s:isSYN(grp, line, col)
return index(s:getHLStack(a:line, a:col), a:grp) != -1
endfunction
function! s:getNesting(hlstack)
return filter(a:hlstack, 'v:val == "haskellBlock" || v:val == "haskellBrackets" || v:val == "haskellParens" || v:val == "haskellBlockComment" || v:val == "haskellPragma" ')
endfunction
function! s:getHLStack(line, col)
return map(synstack(a:line, a:col), 'synIDattr(v:val, "name")')
endfunction
" indent matching character
function! s:indentMatching(char)
normal! 0
call search(a:char, 'cW')
normal! %
return col('.') - 1
endfunction
" backtrack to find guard clause
function! s:indentGuard(pos, prevline)
let l:l = a:prevline
let l:c = v:lnum - 1
let l:s = indent(l:c)
while l:c >= 1
if l:s == 0 && strlen(l:l) > 0
" top-level start, stop looking
return g:haskell_indent_guard
elseif l:l =~ '^\s\+[|,=]\s\+'
" guard block found
return match(l:l, '[|,=]')
else
if l:s > 0 && l:s <= a:pos
" found less deeper indentation (not starting with `,` or `=`)
" stop looking
return l:s + g:haskell_indent_guard
endif
endif
let l:c -= 1
let l:l = getline(l:c)
let l:s = indent(l:c)
endwhile
return -1
endfunction
function! GetHaskellIndent()
let l:hlstack = s:getHLStack(line('.'), col('.'))
" do not indent in strings and quasiquotes
if index(l:hlstack, 'haskellQuasiQuote') > -1 || index(l:hlstack, 'haskellBlockComment') > -1
return -1
endif
let l:prevline = s:stripComment(getline(v:lnum - 1))
let l:line = getline(v:lnum)
" indent multiline strings
if index(l:hlstack, 'haskellString') > -1
if l:line =~ '^\s*\\'
return match(l:prevline, '["\\]')
else
return - 1
endif
endif
" reset
if l:prevline =~ '^\s*$' && l:line !~ '^\s*\S'
return 0
endif
" { foo :: Int
" >>,
"
" |
" ...
" >>,
if l:line =~ '^\s*,'
if s:isInBlock(s:getHLStack(line('.'), col('.')))
normal! 0
call search(',', 'cW')
let l:n = s:getNesting(s:getHLStack(line('.'), col('.')))
call search('[([{]', 'bW')
let l:cl = line('.')
let l:cc = col('.')
while l:n != s:getNesting(s:getHLStack(l:cl, l:cc)) || s:isSYN('haskellString', l:cl, l:cc) || s:isSYN('haskellChar', l:cl, l:cc)
call search('[([{]', 'bW')
let l:cl = line('.')
let l:cc = col('.')
endwhile
return l:cc - 1
else
let l:s = s:indentGuard(match(l:line, ','), l:prevline)
if l:s > -1
return l:s
end
endif
endif
" operator at end of previous line
if l:prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
return indent(v:lnum - 1) + &shiftwidth
endif
" let foo =
" >>>>>>bar
if l:prevline =~ '\C\<let\>\s\+[^=]\+=\s*$'
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let + &shiftwidth
endif
" let x = 1 in
" >>>>x
if l:prevline =~ '\C\<let\>.\{-}\<in\>\s*$' && l:line !~ '\C^\s*\<in\>'
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let
endif
" let x = 1
" let y = 2
"
" let x = 1
" >>>>y = 2
"
" let x = 1
" y 2
if l:prevline =~ '\C\<let\>\s\+.\+$'
if l:line =~ '\C^\s*\<let\>'
let l:s = match(l:prevline, '\C\<let\>')
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
return l:s
endif
elseif l:line =~ '\s=\s'
let l:s = match(l:prevline, '\C\<let\>')
if s:isSYN('haskellLet', v:lnum - 1, l:s + 1)
return l:s + g:haskell_indent_let
endif
endif
endif
" if handling
if l:prevline !~ '\C\<else\>'
let l:s = match(l:prevline, '\C\<if\>.*\&.*\zs\<then\>')
if l:s > 0
return l:s
endif
let l:s = match(l:prevline, '\C\<if\>')
if l:s > 0
return l:s + g:haskell_indent_if
endif
endif
" where
" >>foo
"
if l:prevline =~ '\C\<where\>\s*$'
return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', &shiftwidth)
endif
" do
" >>foo
"
" foo =
" >>bar
if l:prevline =~ '\C\(\<do\>\|=\)\s*$'
return indent(v:lnum - 1) + &shiftwidth
endif
" do foo
" >>>bar
if l:prevline =~ '\C\<do\>\s\+\S\+.*$'
let l:s = match(l:prevline, '\C\<do\>')
if s:isSYN('haskellKeyword', v:lnum - 1, l:s + 1)
return l:s + g:haskell_indent_do
endif
endif
" case foo of
" >>bar -> quux
if l:prevline =~ '\C\<case\>.\+\<of\>\s*$'
if get(g:,'haskell_indent_case_alternative', 0)
return indent(v:lnum - 1) + &shiftwidth
else
return match(l:prevline, '\C\<case\>') + g:haskell_indent_case
endif
endif
"" where foo
"" >>>>>>bar
""
"" where foo :: Int
"" >>>>>>>>>>-> Int
""
"" where foo x
"" >>>>>>>>|
if l:prevline =~ '\C\<where\>\s\+\S\+.*$'
if l:line =~ '^\s*[=-]>\s' && l:prevline =~ ' :: '
return match(l:prevline, ':: ')
elseif l:line =~ '^\s*|\s'
let l:s = match(l:prevline, '\C\<where\>')
if s:isSYN('haskellWhere', v:lnum - 1, l:s + 1)
return l:s + g:haskell_indent_where + g:haskell_indent_guard
endif
else
let l:s = match(l:prevline, '\C\<where\>')
if s:isSYN('haskellWhere', v:lnum - 1, l:s + 1)
return l:s + g:haskell_indent_where
endif
endif
endif
" newtype Foo = Foo
" >>deriving
if l:prevline =~ '\C^\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\<deriving\>'
return indent(v:lnum - 1) + &shiftwidth
endif
" foo :: Int
" >>>>-> Int
"
" foo
" :: Int
" foo
if l:prevline =~ '\s::\s'
if l:line =~ '^\s*[-=]>'
return match(l:prevline, '::\s')
elseif match(l:prevline, '^\s\+::') > -1
return match(l:prevline, '::\s') - &shiftwidth
endif
endif
" foo :: Int
" -> Int
" >>>>-> Int
"
" foo :: Monad m
" => Functor f
" >>>>=> Int
"
" foo :: Int
" -> Int
" foo x
"
" foo
" :: Int
" -> Int
" foo x
if l:prevline =~ '^\s*[-=]>'
if l:line =~ '^\s*[-=]>'
return match(l:prevline, '[-=]')
else
if s:isInBlock(l:hlstack)
return match(l:prevline, '[^-=]')
else
let l:m = matchstr(l:line, '^\s*\zs\<\S\+\>\ze')
let l:l = l:prevline
let l:c = v:lnum - 1
while l:c >= 1
" fun decl
if l:l =~ ('^\s*' . l:m . '\(\s*::\|\n\s\+::\)')
let l:s = match(l:l, l:m)
if match(l:l, '\C^\s*\<default\>') > -1
return l:s - 8
else
return l:s
endif
" empty line, stop looking
elseif l:l =~ '^$'
return 0
endif
let l:c -= 1
let l:l = getline(l:c)
endwhile
return 0
endif
endif
endif
" | otherwise = ...
" foo
"
" | foo
" >>, bar
"
" | foo
" >>= bar
"
" | Foo
" >>deriving
if l:prevline =~ '^\s\+|' && !s:isInBlock(l:hlstack)
if l:line =~ '\s*[,=]'
return match(l:prevline, '|')
elseif l:line =~ '\C^\s*\<deriving\>'
return match(l:prevline, '|')
elseif l:line !~ '^\s*|'
return match(l:prevline, '|') - g:haskell_indent_guard
endif
endif
" foo :: ( Monad m
" , Functor f
" )
">>>>>=> Int
if l:prevline =~ '^\s*)' && l:line =~ '^\s*=>'
let l:s = match(l:prevline, ')')
return l:s - (&shiftwidth + 1)
endif
" module Foo
" >>( bar
if l:prevline =~ '\C^\<module\>'
return &shiftwidth
endif
" foo
" >>{
if l:line =~ '^\s*{'
let l:s = indent(v:lnum - 1)
if l:s >= 0
return l:s + &shiftwidth
endif
endif
" in foo
" where bar
"
" or
"
" foo
" >>where
if l:line =~ '\C^\s*\<where\>'
if match(l:prevline, '\C^\s\+in\s\+') == 0
return match(l:prevline, 'in') - g:haskell_indent_in
endif
return indent(v:lnum - 1) + get(g:, 'haskell_indent_before_where', &shiftwidth)
endif
" let x = 1
" y = 2
" >in x + 1
if l:line =~ '\C^\s*\<in\>'
let l:s = 0
let l:c = v:lnum - 1
while l:s <= 0 && l:c >= 1
let l:l = getline(l:c)
let l:s = match(l:l, '\C\<let\>')
if l:s >= 1 && s:isSYN('haskellLet', l:c, l:s + 1)
break
elseif l:l =~ '^\S'
return -1
endif
let l:c -= 1
endwhile
return l:s + g:haskell_indent_in
endif
" data Foo
" >>= Bar
"
" |
" ...
" >>=
"
" foo
" >>=
if l:line =~ '^\s*='
if l:prevline =~ '\C^\<data\>\s\+[^=]\+\s*$'
return match(l:prevline, '\C\<data\>') + &shiftwidth
else
let l:s = s:indentGuard(match(l:line, '='), l:prevline)
if l:s > 0
return l:s
else
return &shiftwidth
endif
endif
endif
" |
" ...
" >>|
"
" data Foo = Bar
" >>>>>>>>>|
if l:line =~ '^\s*|\s'
if l:prevline =~ '\C^\s*\<data\>.\+=.\+$'
return match(l:prevline, '=')
else
let l:s = s:indentGuard(match(l:line, '|'), l:prevline)
if l:s > -1
return l:s
endif
endif
endif
" foo
" >>:: Int
if l:line =~ '^\s*::\s'
return indent(v:lnum - 1) + &shiftwidth
endif
" indent closing brace, paren or bracket
if l:line =~ '^\s*}'
return s:indentMatching('}')
endif
if l:line =~ '^\s*)'
return s:indentMatching(')')
endif
if l:line =~ '^\s*]'
return s:indentMatching(']')
endif
return -1
endfunction

View file

@ -0,0 +1,51 @@
" syntax highlighting for cabal
"
" author: raichoo (raichoo@googlemail.com)
if version < 600
syn clear
elseif exists("b:current_syntax")
finish
endif
syn match cabalLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$" contains=@Spell
syn match cabalIdentifier "[A-Za-z\-]*" contained
syn match cabalOperator "[<=>&|!]"
syn match cabalColon ":" contained
syn match cabalNumber "\<[0-9][0-9\.*]*\>"
syn match cabalDelimiter "[,()]"
syn keyword cabalBool True False
syn keyword cabalConditional if else
syn match cabalCompilerFlag "\s\+-[^ -][^ ]*"
syn match cabalDocBulletPoint "^\s\+\*"
syn match cabalDocHeadline "^\s\+=.*$"
syn match cabalDocCode "^\s\+>.*$"
syn match cabalDocNewline "^\s\+\.\s*$"
syn match cabalSection "^\c\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\)"
syn match cabalEntry "^\s*[A-Za-z][a-zA-Z\-]*:" contains=cabalIdentifier,cabalColon
syn region cabalDescription start="^\s*[dD]escription:" end="^\<" keepend
\ contains=
\ cabalEntry,
\ cabalLineComment,
\ cabalDocBulletPoint,
\ cabalDocHeadline,
\ cabalDocNewline,
\ cabalDocCode
highlight def link cabalIdentifier Identifier
highlight def link cabalLineComment Comment
highlight def link cabalOperator Operator
highlight def link cabalColon Operator
highlight def link cabalNumber Number
highlight def link cabalSection Structure
highlight def link cabalDelimiter Delimiter
highlight def link cabalBool Boolean
highlight def link cabalCompilerFlag Macro
highlight def link cabalConditional Conditional
highlight def link cabalDocBulletPoint Structure
highlight def link cabalDocHeadline Include
highlight def link cabalDocNewline Operator
highlight def link cabalDocCode Macro
let b:current_syntax = "cabal"

View file

@ -0,0 +1,208 @@
" syntax highlighting for haskell
"
" Heavily modified version of the haskell syntax
" highlighter to support haskell.
"
" author: raichoo (raichoo@googlemail.com)
if version < 600
syn clear
elseif exists("b:current_syntax")
finish
endif
if get(g:, 'haskell_backpack', 0)
syn keyword haskellBackpackStructure unit signature
syn keyword haskellBackpackDependency dependency
endif
syn spell notoplevel
syn match haskellRecordField contained containedin=haskellBlock
\ "[_a-z][a-zA-Z0-9_']*\(,\s*[_a-z][a-zA-Z0-9_']*\)*\_s\+::\_s"
\ contains=
\ haskellIdentifier,
\ haskellOperators,
\ haskellSeparator,
\ haskellParens
syn match haskellTypeSig
\ "^\s*\(where\s\+\|let\s\+\|default\s\+\)\?[_a-z][a-zA-Z0-9_']*#\?\(,\s*[_a-z][a-zA-Z0-9_']*#\?\)*\_s\+::\_s"
\ contains=
\ haskellWhere,
\ haskellLet,
\ haskellDefault,
\ haskellIdentifier,
\ haskellOperators,
\ haskellSeparator,
\ haskellParens
syn keyword haskellWhere where
syn keyword haskellLet let
syn match HaskellDerive "\<deriving\>\(\s\+\<\(anyclass\|instance\|newtype\|stock\)\>\)\?"
syn keyword haskellDeclKeyword module class instance newtype in
syn match haskellDecl "\<\(type\|data\)\>\s\+\(\<family\>\)\?"
syn keyword haskellDefault default
syn keyword haskellImportKeywords import qualified safe as hiding contained
syn keyword haskellForeignKeywords foreign export import ccall safe unsafe interruptible capi prim contained
syn region haskellForeignImport start="\<foreign\>" end="\_s\+::\s" keepend
\ contains=
\ haskellString,
\ haskellOperators,
\ haskellForeignKeywords,
\ haskellIdentifier
syn match haskellImport "^\s*\<import\>\s\+\(\<safe\>\s\+\)\?\(\<qualified\>\s\+\)\?.\+\(\s\+\<as\>\s\+.\+\)\?\(\s\+\<hiding\>\)\?"
\ contains=
\ haskellParens,
\ haskellOperators,
\ haskellImportKeywords,
\ haskellType,
\ haskellLineComment,
\ haskellBlockComment,
\ haskellString,
\ haskellPragma
syn keyword haskellKeyword do case of
if get(g:, 'haskell_enable_static_pointers', 0)
syn keyword haskellStatic static
endif
syn keyword haskellConditional if then else
syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>\|\<0[bB][10]\+\>"
syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
syn match haskellSeparator "[,;]"
syn region haskellParens matchgroup=haskellDelimiter start="(" end=")" contains=TOP,haskellTypeSig,@Spell
syn region haskellBrackets matchgroup=haskellDelimiter start="\[" end="]" contains=TOP,haskellTypeSig,@Spell
syn region haskellBlock matchgroup=haskellDelimiter start="{" end="}" contains=TOP,@Spell
syn keyword haskellInfix infix infixl infixr
syn keyword haskellBottom undefined error
syn match haskellOperators "[-!#$%&\*\+/<=>\?@\\^|~:.]\+\|\<_\>"
syn match haskellQuote "\<'\+" contained
syn match haskellQuotedType "[A-Z][a-zA-Z0-9_']*\>" contained
syn region haskellQuoted start="\<'\+" end="\>"
\ contains=
\ haskellType,
\ haskellQuote,
\ haskellQuotedType,
\ haskellSeparator,
\ haskellParens,
\ haskellOperators,
\ haskellIdentifier
syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
\ contains=
\ haskellTodo,
\ @Spell
syn match haskellBacktick "`[A-Za-z_][A-Za-z0-9_\.']*#\?`"
syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+
\ contains=@Spell
syn match haskellIdentifier "[_a-z][a-zA-z0-9_']*" contained
syn match haskellChar "\<'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'\>"
syn match haskellType "\<[A-Z][a-zA-Z0-9_']*\>"
syn region haskellBlockComment start="{-" end="-}"
\ contains=
\ haskellBlockComment,
\ haskellTodo,
\ @Spell
syn region haskellPragma start="{-#" end="#-}"
syn region haskellLiquid start="{-@" end="@-}"
syn match haskellPreProc "^#.*$"
syn keyword haskellTodo TODO FIXME contained
" Treat a shebang line at the start of the file as a comment
syn match haskellShebang "\%^#!.*$"
if !get(g:, 'haskell_disable_TH', 0)
syn match haskellQuasiQuoted "." containedin=haskellQuasiQuote contained
syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-z0-9._']*|" end="|\]"
syn region haskellTHBlock matchgroup=haskellTH start="\[\(d\|t\|p\)\?|" end="|]" contains=TOP
syn region haskellTHDoubleBlock matchgroup=haskellTH start="\[||" end="||]" contains=TOP
endif
if get(g:, 'haskell_enable_typeroles', 0)
syn keyword haskellTypeRoles phantom representational nominal contained
syn region haskellTypeRoleBlock matchgroup=haskellTypeRoles start="type\s\+role" end="$" keepend
\ contains=
\ haskellType,
\ haskellTypeRoles
endif
if get(g:, 'haskell_enable_quantification', 0)
syn keyword haskellForall forall
endif
if get(g:, 'haskell_enable_recursivedo', 0)
syn keyword haskellRecursiveDo mdo rec
endif
if get(g:, 'haskell_enable_arrowsyntax', 0)
syn keyword haskellArrowSyntax proc
endif
if get(g:, 'haskell_enable_pattern_synonyms', 0)
syn keyword haskellPatternKeyword pattern
endif
highlight def link haskellBottom Macro
highlight def link haskellTH Boolean
highlight def link haskellIdentifier Identifier
highlight def link haskellForeignKeywords Structure
highlight def link haskellKeyword Keyword
highlight def link haskellDefault Keyword
highlight def link haskellConditional Conditional
highlight def link haskellNumber Number
highlight def link haskellFloat Float
highlight def link haskellSeparator Delimiter
highlight def link haskellDelimiter Delimiter
highlight def link haskellInfix Keyword
highlight def link haskellOperators Operator
highlight def link haskellQuote Operator
highlight def link haskellShebang Comment
highlight def link haskellLineComment Comment
highlight def link haskellBlockComment Comment
highlight def link haskellPragma SpecialComment
highlight def link haskellLiquid SpecialComment
highlight def link haskellString String
highlight def link haskellChar String
highlight def link haskellBacktick Operator
highlight def link haskellQuasiQuoted String
highlight def link haskellTodo Todo
highlight def link haskellPreProc PreProc
highlight def link haskellAssocType Type
highlight def link haskellQuotedType Type
highlight def link haskellType Type
highlight def link haskellImportKeywords Include
if get(g:, 'haskell_classic_highlighting', 0)
highlight def link haskellDeclKeyword Keyword
highlight def link HaskellDerive Keyword
highlight def link haskellDecl Keyword
highlight def link haskellWhere Keyword
highlight def link haskellLet Keyword
else
highlight def link haskellDeclKeyword Structure
highlight def link HaskellDerive Structure
highlight def link haskellDecl Structure
highlight def link haskellWhere Structure
highlight def link haskellLet Structure
endif
if get(g:, 'haskell_enable_quantification', 0)
highlight def link haskellForall Operator
endif
if get(g:, 'haskell_enable_recursivedo', 0)
highlight def link haskellRecursiveDo Keyword
endif
if get(g:, 'haskell_enable_arrowsyntax', 0)
highlight def link haskellArrowSyntax Keyword
endif
if get(g:, 'haskell_enable_static_pointers', 0)
highlight def link haskellStatic Keyword
endif
if get(g:, 'haskell_classic_highlighting', 0)
if get(g:, 'haskell_enable_pattern_synonyms', 0)
highlight def link haskellPatternKeyword Keyword
endif
if get(g:, 'haskell_enable_typeroles', 0)
highlight def link haskellTypeRoles Keyword
endif
else
if get(g:, 'haskell_enable_pattern_synonyms', 0)
highlight def link haskellPatternKeyword Structure
endif
if get(g:, 'haskell_enable_typeroles', 0)
highlight def link haskellTypeRoles Structure
endif
endif
if get(g:, 'haskell_backpack', 0)
highlight def link haskellBackpackStructure Structure
highlight def link haskellBackpackDependency Include
endif
let b:current_syntax = "haskell"

View file

@ -0,0 +1,14 @@
#!/bin/sh
for i in test???; do
cd $i
nvim --headless -s test.vim test.hs 2> /dev/null
diff expected.hs result.hs
if [ $? -eq 0 ]; then
echo "$(basename $PWD) succeded"
rm result.hs
else
echo "$(basename $PWD) failed"
fi
cd ..
done

View file

@ -0,0 +1,5 @@
data Foo = Foo
{ foo :: Int
-- comment
, bar :: Int
}

View file

@ -0,0 +1,5 @@
data Foo = Foo
{ foo :: Int
-- comment
, bar :: Int
}

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
-- | This is a function.
fun -- this shouldn't be indented

View file

@ -0,0 +1,2 @@
-- | This is a function.
fun -- this shouldn't be indented

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,4 @@
data Test = Test
{ x :: {-# UNPACK #-} !Int
, y :: {-# UNPACK #-} !Int
}

View file

@ -0,0 +1,4 @@
data Test = Test
{ x :: {-# UNPACK #-} !Int
, y :: Int
}

View file

@ -0,0 +1,3 @@
2jfIi{-# UNPACK #-} !
:saveas! result.hs
:q!

View file

@ -0,0 +1,4 @@
foo =
{ field = bar "("
, quux = ""
}

View file

@ -0,0 +1,3 @@
foo =
{ field = bar "("
}

View file

@ -0,0 +1,3 @@
jo, quux = ""
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
[ (NS spotify spotify (className =? "Spotify") doFullFloat )
, ]

View file

@ -0,0 +1,2 @@
[ (NS spotify spotify (className =? "Spotify") doFullFloat )
,]

View file

@ -0,0 +1,3 @@
ja 
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
foo = doSomething 123 -- Do something important.
bar

View file

@ -0,0 +1 @@
foo = doSomething 123 -- Do something important.

View file

@ -0,0 +1,3 @@
obar
:saveas! result.hs
:q!

View file

@ -0,0 +1,5 @@
data Customer = Customer
{ customerID :: CustomerID
, customerName :: String
, customerAddress :: Address
} deriving (Show)

View file

@ -0,0 +1,5 @@
data Customer = Customer
{ customerID :: CustomerID
, customerName :: String
, customerAddress :: Address
} deriving (Show)

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,6 @@
data Foo
= Foo
{ foo :: Int
, bar :: Char
, baz :: Int
} deriving (Eq, Ord)

View file

@ -0,0 +1,6 @@
data Foo
= Foo
{ foo :: Int
, bar :: Char
, baz :: Int
} deriving (Eq, Ord)

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
let x =
123

View file

@ -0,0 +1 @@
let x =

View file

@ -0,0 +1,3 @@
o123
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
SomeRecord { name = ")"
,

View file

@ -0,0 +1 @@
SomeRecord { name = ")"

View file

@ -0,0 +1,3 @@
o, 
:saveas! result.hs
:q!

View file

@ -0,0 +1,3 @@
add1 x = x + y
where
y = 1

View file

@ -0,0 +1,3 @@
add1 x = x + y
where
y = 1

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,3 @@
add2 x = let y = 1
z = 1
in = x + y + z

View file

@ -0,0 +1,3 @@
add2 x = let y = 1
z = 1
in = x + y + z

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
--
type F k = [k]

View file

@ -0,0 +1,2 @@
--
type F k = [k]

View file

@ -0,0 +1,3 @@
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,5 @@
foo :: Monad m
=> Functor m
=> MonadIO m
-> Int
foo x = x

View file

@ -0,0 +1 @@
foo :: Monad m

View file

@ -0,0 +1,3 @@
o=> Functor m => MonadIO m -> Int foo x = x
:saveas! result.hs
:q!

View file

@ -0,0 +1,3 @@
f x = y
where
y = 2 * x

View file

@ -0,0 +1,3 @@
f x = y
where
y = 2 * x

View file

@ -0,0 +1,6 @@
:set sw=4
:let g:haskell_indent_before_where=2
:let g:haskell_indent_after_bare_where=2
=G
:saveas! result.hs
:q!

View file

@ -0,0 +1,6 @@
where
foo :: Monad m
=> Functor m
=> MonadIO m
-> Int
foo x = x

View file

@ -0,0 +1,5 @@
where
foo :: Monad m
=> Functor m
=> MonadIO m
-> Int

View file

@ -0,0 +1,3 @@
Gofoo x = x
:saveas! result.hs
:q!

View file

@ -0,0 +1,2 @@
where countUntilClosed (x:xs)
| x

View file

@ -0,0 +1 @@
where countUntilClosed (x:xs)

View file

@ -0,0 +1,3 @@
o| x
:saveas! result.hs
:q!

View file

@ -0,0 +1,4 @@
let foo = 1
bar = baz
quux
in

View file

@ -0,0 +1,4 @@
let foo = 1
bar = baz
quux
in

View file

@ -0,0 +1,3 @@
G==
:saveas! result.hs
:q!

View file

@ -0,0 +1,8 @@
foo x
| x == x = True
|
,
=

View file

@ -0,0 +1,3 @@
foo x
| x == x = True

View file

@ -0,0 +1,3 @@
Go| o ,o = 
:saveas! result.hs
:q!