From f3f21a93f479d1ef4f6df8c4105ca189a40b62cb Mon Sep 17 00:00:00 2001 From: DanielSchuette Date: Mon, 20 Sep 2021 15:07:00 +0200 Subject: [PATCH] move haskell-vim around --- vim-config/haskell-vim/.gitignore | 1 + vim-config/haskell-vim/LICENSE | 10 + vim-config/haskell-vim/README.md | 142 +++++ .../haskell-vim/after/ftplugin/cabal.vim | 3 + .../haskell-vim/after/ftplugin/haskell.vim | 2 + vim-config/haskell-vim/doc/haskell-vim.txt | 159 ++++++ vim-config/haskell-vim/ftdetect/haskell.vim | 3 + vim-config/haskell-vim/indent/cabal.vim | 31 ++ vim-config/haskell-vim/indent/haskell.vim | 509 ++++++++++++++++++ vim-config/haskell-vim/syntax/cabal.vim | 51 ++ vim-config/haskell-vim/syntax/haskell.vim | 213 ++++++++ vim-config/haskell-vim/tests/indent/run.sh | 14 + .../tests/indent/test001/expected.hs | 5 + .../haskell-vim/tests/indent/test001/test.hs | 5 + .../haskell-vim/tests/indent/test001/test.vim | 3 + .../tests/indent/test002/expected.hs | 2 + .../haskell-vim/tests/indent/test002/test.hs | 2 + .../haskell-vim/tests/indent/test002/test.vim | 3 + .../tests/indent/test003/expected.hs | 4 + .../haskell-vim/tests/indent/test003/test.hs | 4 + .../haskell-vim/tests/indent/test003/test.vim | 3 + .../tests/indent/test004/expected.hs | 4 + .../haskell-vim/tests/indent/test004/test.hs | 3 + .../haskell-vim/tests/indent/test004/test.vim | 3 + .../tests/indent/test005/expected.hs | 2 + .../haskell-vim/tests/indent/test005/test.hs | 2 + .../haskell-vim/tests/indent/test005/test.vim | 3 + .../tests/indent/test006/expected.hs | 2 + .../haskell-vim/tests/indent/test006/test.hs | 1 + .../haskell-vim/tests/indent/test006/test.vim | 3 + .../tests/indent/test007/expected.hs | 5 + .../haskell-vim/tests/indent/test007/test.hs | 5 + .../haskell-vim/tests/indent/test007/test.vim | 3 + .../tests/indent/test008/expected.hs | 6 + .../haskell-vim/tests/indent/test008/test.hs | 6 + .../haskell-vim/tests/indent/test008/test.vim | 3 + .../tests/indent/test009/expected.hs | 2 + .../haskell-vim/tests/indent/test009/test.hs | 1 + .../haskell-vim/tests/indent/test009/test.vim | 3 + .../tests/indent/test010/expected.hs | 2 + .../haskell-vim/tests/indent/test010/test.hs | 1 + .../haskell-vim/tests/indent/test010/test.vim | 3 + .../tests/indent/test011/expected.hs | 3 + .../haskell-vim/tests/indent/test011/test.hs | 3 + .../haskell-vim/tests/indent/test011/test.vim | 3 + .../tests/indent/test012/expected.hs | 3 + .../haskell-vim/tests/indent/test012/test.hs | 3 + .../haskell-vim/tests/indent/test012/test.vim | 3 + .../tests/indent/test013/expected.hs | 2 + .../haskell-vim/tests/indent/test013/test.hs | 2 + .../haskell-vim/tests/indent/test013/test.vim | 3 + .../tests/indent/test014/expected.hs | 5 + .../haskell-vim/tests/indent/test014/test.hs | 1 + .../haskell-vim/tests/indent/test014/test.vim | 3 + .../tests/indent/test015/expected.hs | 3 + .../haskell-vim/tests/indent/test015/test.hs | 3 + .../haskell-vim/tests/indent/test015/test.vim | 6 + .../tests/indent/test016/expected.hs | 6 + .../haskell-vim/tests/indent/test016/test.hs | 5 + .../haskell-vim/tests/indent/test016/test.vim | 3 + .../tests/indent/test017/expected.hs | 2 + .../haskell-vim/tests/indent/test017/test.hs | 1 + .../haskell-vim/tests/indent/test017/test.vim | 3 + .../tests/indent/test018/expected.hs | 4 + .../haskell-vim/tests/indent/test018/test.hs | 4 + .../haskell-vim/tests/indent/test018/test.vim | 3 + .../tests/indent/test019/expected.hs | 8 + .../haskell-vim/tests/indent/test019/test.hs | 3 + .../haskell-vim/tests/indent/test019/test.vim | 3 + vim-config/plugins/haskell-vim | 1 - 70 files changed, 1323 insertions(+), 1 deletion(-) create mode 100644 vim-config/haskell-vim/.gitignore create mode 100644 vim-config/haskell-vim/LICENSE create mode 100644 vim-config/haskell-vim/README.md create mode 100644 vim-config/haskell-vim/after/ftplugin/cabal.vim create mode 100644 vim-config/haskell-vim/after/ftplugin/haskell.vim create mode 100644 vim-config/haskell-vim/doc/haskell-vim.txt create mode 100644 vim-config/haskell-vim/ftdetect/haskell.vim create mode 100644 vim-config/haskell-vim/indent/cabal.vim create mode 100644 vim-config/haskell-vim/indent/haskell.vim create mode 100644 vim-config/haskell-vim/syntax/cabal.vim create mode 100644 vim-config/haskell-vim/syntax/haskell.vim create mode 100644 vim-config/haskell-vim/tests/indent/run.sh create mode 100644 vim-config/haskell-vim/tests/indent/test001/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test001/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test001/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test002/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test002/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test002/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test003/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test003/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test003/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test004/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test004/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test004/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test005/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test005/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test005/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test006/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test006/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test006/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test007/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test007/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test007/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test008/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test008/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test008/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test009/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test009/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test009/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test010/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test010/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test010/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test011/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test011/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test011/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test012/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test012/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test012/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test013/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test013/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test013/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test014/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test014/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test014/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test015/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test015/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test015/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test016/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test016/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test016/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test017/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test017/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test017/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test018/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test018/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test018/test.vim create mode 100644 vim-config/haskell-vim/tests/indent/test019/expected.hs create mode 100644 vim-config/haskell-vim/tests/indent/test019/test.hs create mode 100644 vim-config/haskell-vim/tests/indent/test019/test.vim delete mode 160000 vim-config/plugins/haskell-vim diff --git a/vim-config/haskell-vim/.gitignore b/vim-config/haskell-vim/.gitignore new file mode 100644 index 00000000..6e92f57d --- /dev/null +++ b/vim-config/haskell-vim/.gitignore @@ -0,0 +1 @@ +tags diff --git a/vim-config/haskell-vim/LICENSE b/vim-config/haskell-vim/LICENSE new file mode 100644 index 00000000..a8a6d87f --- /dev/null +++ b/vim-config/haskell-vim/LICENSE @@ -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. diff --git a/vim-config/haskell-vim/README.md b/vim-config/haskell-vim/README.md new file mode 100644 index 00000000..ed0db836 --- /dev/null +++ b/vim-config/haskell-vim/README.md @@ -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 diff --git a/vim-config/haskell-vim/after/ftplugin/cabal.vim b/vim-config/haskell-vim/after/ftplugin/cabal.vim new file mode 100644 index 00000000..856e4c2c --- /dev/null +++ b/vim-config/haskell-vim/after/ftplugin/cabal.vim @@ -0,0 +1,3 @@ +setlocal comments=s1fl:{-,mb:-,ex:-},:-- +setlocal iskeyword+=-,.,* +setlocal commentstring=--\ %s diff --git a/vim-config/haskell-vim/after/ftplugin/haskell.vim b/vim-config/haskell-vim/after/ftplugin/haskell.vim new file mode 100644 index 00000000..2bb2240e --- /dev/null +++ b/vim-config/haskell-vim/after/ftplugin/haskell.vim @@ -0,0 +1,2 @@ +setlocal comments=s1fl:{-,mb:\ \ ,ex:-},:-- +setlocal iskeyword+=' diff --git a/vim-config/haskell-vim/doc/haskell-vim.txt b/vim-config/haskell-vim/doc/haskell-vim.txt new file mode 100644 index 00000000..21031933 --- /dev/null +++ b/vim-config/haskell-vim/doc/haskell-vim.txt @@ -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 +< diff --git a/vim-config/haskell-vim/ftdetect/haskell.vim b/vim-config/haskell-vim/ftdetect/haskell.vim new file mode 100644 index 00000000..0abe50e3 --- /dev/null +++ b/vim-config/haskell-vim/ftdetect/haskell.vim @@ -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 diff --git a/vim-config/haskell-vim/indent/cabal.vim b/vim-config/haskell-vim/indent/cabal.vim new file mode 100644 index 00000000..2dfd844d --- /dev/null +++ b/vim-config/haskell-vim/indent/cabal.vim @@ -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, + +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 diff --git a/vim-config/haskell-vim/indent/haskell.vim b/vim-config/haskell-vim/indent/haskell.vim new file mode 100644 index 00000000..90b61520 --- /dev/null +++ b/vim-config/haskell-vim/indent/haskell.vim @@ -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\\s\+[^=]\+=\s*$' + return match(l:prevline, '\C\') + g:haskell_indent_let + shiftwidth() + endif + + " let x = 1 in + " >>>>x + if l:prevline =~ '\C\.\{-}\\s*$' && l:line !~ '\C^\s*\' + return match(l:prevline, '\C\') + 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\\s\+.\+$' + if l:line =~ '\C^\s*\' + let l:s = match(l:prevline, '\C\') + 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\') + 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\' + let l:s = match(l:prevline, '\C\.*\&.*\zs\') + if l:s > 0 + return l:s + endif + + let l:s = match(l:prevline, '\C\') + if l:s > 0 + return l:s + g:haskell_indent_if + endif + endif + + " where + " >>foo + " + if l:prevline =~ '\C\\s*$' + return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', shiftwidth()) + endif + + " do + " >>foo + " + " foo = + " >>bar + if l:prevline =~ '\C\(\\|=\)\s*$' + return indent(v:lnum - 1) + shiftwidth() + endif + + " do foo + " >>>bar + if l:prevline =~ '\C\\s\+\S\+.*$' + let l:s = match(l:prevline, '\C\') + 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\.\+\\s*$' + if get(g:,'haskell_indent_case_alternative', 0) + return indent(v:lnum - 1) + shiftwidth() + else + return match(l:prevline, '\C\') + g:haskell_indent_case + endif + endif + + "" where foo + "" >>>>>>bar + "" + "" where foo :: Int + "" >>>>>>>>>>-> Int + "" + "" where foo x + "" >>>>>>>>| + if l:prevline =~ '\C\\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\') + 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\') + 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*\' + 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*\') > -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*\' + 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^\' + 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*\' + 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*\' + 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\') + 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^\\s\+[^=]\+\s*$' + return match(l:prevline, '\C\') + 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*\.\+=.\+$' + 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 diff --git a/vim-config/haskell-vim/syntax/cabal.vim b/vim-config/haskell-vim/syntax/cabal.vim new file mode 100644 index 00000000..512386fd --- /dev/null +++ b/vim-config/haskell-vim/syntax/cabal.vim @@ -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\|common\)" +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" diff --git a/vim-config/haskell-vim/syntax/haskell.vim b/vim-config/haskell-vim/syntax/haskell.vim new file mode 100644 index 00000000..15e9d265 --- /dev/null +++ b/vim-config/haskell-vim/syntax/haskell.vim @@ -0,0 +1,213 @@ +" 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 keyword haskellDeriveKeyword deriving anyclass instance newtype stock via contained +syn match haskellDerive "deriving\(\s\+instance\)\?\(\s\+anyclass\|\s\+newtype\|\s\+stock\|\s\+.\{-}\_s\+via\)\?" + \ contains= + \ haskellDeriveKeyword, + \ haskellParens, + \ haskellType +syn keyword haskellDeclKeyword module class instance newtype in +syn match haskellDecl "\<\(type\|data\)\>\s\+\(\\)\?" +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="\" end="\_s\+::\s" keepend + \ contains= + \ haskellString, + \ haskellOperators, + \ haskellForeignKeywords, + \ haskellIdentifier +syn match haskellImport "^\s*\\s\+\(\\s\+\)\?\(\\s\+\)\?.\+\(\s\+\\s\+.\+\)\?\(\s\+\\)\?" + \ 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-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 haskellDeriveKeyword 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 haskellDeriveKeyword 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" diff --git a/vim-config/haskell-vim/tests/indent/run.sh b/vim-config/haskell-vim/tests/indent/run.sh new file mode 100644 index 00000000..728649f4 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/run.sh @@ -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 diff --git a/vim-config/haskell-vim/tests/indent/test001/expected.hs b/vim-config/haskell-vim/tests/indent/test001/expected.hs new file mode 100644 index 00000000..c2fc910e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test001/expected.hs @@ -0,0 +1,5 @@ +data Foo = Foo + { foo :: Int +-- comment + , bar :: Int + } diff --git a/vim-config/haskell-vim/tests/indent/test001/test.hs b/vim-config/haskell-vim/tests/indent/test001/test.hs new file mode 100644 index 00000000..eb6ee68c --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test001/test.hs @@ -0,0 +1,5 @@ +data Foo = Foo + { foo :: Int +-- comment +, bar :: Int + } diff --git a/vim-config/haskell-vim/tests/indent/test001/test.vim b/vim-config/haskell-vim/tests/indent/test001/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test001/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test002/expected.hs b/vim-config/haskell-vim/tests/indent/test002/expected.hs new file mode 100644 index 00000000..3b7be9d8 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test002/expected.hs @@ -0,0 +1,2 @@ +-- | This is a function. +fun -- this shouldn't be indented diff --git a/vim-config/haskell-vim/tests/indent/test002/test.hs b/vim-config/haskell-vim/tests/indent/test002/test.hs new file mode 100644 index 00000000..3b7be9d8 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test002/test.hs @@ -0,0 +1,2 @@ +-- | This is a function. +fun -- this shouldn't be indented diff --git a/vim-config/haskell-vim/tests/indent/test002/test.vim b/vim-config/haskell-vim/tests/indent/test002/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test002/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test003/expected.hs b/vim-config/haskell-vim/tests/indent/test003/expected.hs new file mode 100644 index 00000000..deea8fa2 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test003/expected.hs @@ -0,0 +1,4 @@ +data Test = Test + { x :: {-# UNPACK #-} !Int + , y :: {-# UNPACK #-} !Int + } diff --git a/vim-config/haskell-vim/tests/indent/test003/test.hs b/vim-config/haskell-vim/tests/indent/test003/test.hs new file mode 100644 index 00000000..6f1db154 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test003/test.hs @@ -0,0 +1,4 @@ +data Test = Test + { x :: {-# UNPACK #-} !Int + , y :: Int + } diff --git a/vim-config/haskell-vim/tests/indent/test003/test.vim b/vim-config/haskell-vim/tests/indent/test003/test.vim new file mode 100644 index 00000000..e0566558 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test003/test.vim @@ -0,0 +1,3 @@ +2jfIi{-# UNPACK #-} ! +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test004/expected.hs b/vim-config/haskell-vim/tests/indent/test004/expected.hs new file mode 100644 index 00000000..1b5fabfe --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test004/expected.hs @@ -0,0 +1,4 @@ +foo = + { field = bar "(" + , quux = "" + } diff --git a/vim-config/haskell-vim/tests/indent/test004/test.hs b/vim-config/haskell-vim/tests/indent/test004/test.hs new file mode 100644 index 00000000..bdae581a --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test004/test.hs @@ -0,0 +1,3 @@ +foo = + { field = bar "(" + } diff --git a/vim-config/haskell-vim/tests/indent/test004/test.vim b/vim-config/haskell-vim/tests/indent/test004/test.vim new file mode 100644 index 00000000..2ef65bfd --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test004/test.vim @@ -0,0 +1,3 @@ +jo, quux = "" +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test005/expected.hs b/vim-config/haskell-vim/tests/indent/test005/expected.hs new file mode 100644 index 00000000..98d9e3af --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test005/expected.hs @@ -0,0 +1,2 @@ +[ (NS spotify spotify (className =? "Spotify") doFullFloat ) +, ] diff --git a/vim-config/haskell-vim/tests/indent/test005/test.hs b/vim-config/haskell-vim/tests/indent/test005/test.hs new file mode 100644 index 00000000..0e2aa8de --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test005/test.hs @@ -0,0 +1,2 @@ +[ (NS spotify spotify (className =? "Spotify") doFullFloat ) +,] diff --git a/vim-config/haskell-vim/tests/indent/test005/test.vim b/vim-config/haskell-vim/tests/indent/test005/test.vim new file mode 100644 index 00000000..f4ebe8ee --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test005/test.vim @@ -0,0 +1,3 @@ +ja  +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test006/expected.hs b/vim-config/haskell-vim/tests/indent/test006/expected.hs new file mode 100644 index 00000000..020020a0 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test006/expected.hs @@ -0,0 +1,2 @@ +foo = doSomething 123 -- Do something important. +bar diff --git a/vim-config/haskell-vim/tests/indent/test006/test.hs b/vim-config/haskell-vim/tests/indent/test006/test.hs new file mode 100644 index 00000000..4dd04bab --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test006/test.hs @@ -0,0 +1 @@ +foo = doSomething 123 -- Do something important. diff --git a/vim-config/haskell-vim/tests/indent/test006/test.vim b/vim-config/haskell-vim/tests/indent/test006/test.vim new file mode 100644 index 00000000..87d5a0f3 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test006/test.vim @@ -0,0 +1,3 @@ +obar +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test007/expected.hs b/vim-config/haskell-vim/tests/indent/test007/expected.hs new file mode 100644 index 00000000..0f15635b --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test007/expected.hs @@ -0,0 +1,5 @@ +data Customer = Customer + { customerID :: CustomerID + , customerName :: String + , customerAddress :: Address + } deriving (Show) diff --git a/vim-config/haskell-vim/tests/indent/test007/test.hs b/vim-config/haskell-vim/tests/indent/test007/test.hs new file mode 100644 index 00000000..f8b72f79 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test007/test.hs @@ -0,0 +1,5 @@ +data Customer = Customer +{ customerID :: CustomerID +, customerName :: String +, customerAddress :: Address +} deriving (Show) diff --git a/vim-config/haskell-vim/tests/indent/test007/test.vim b/vim-config/haskell-vim/tests/indent/test007/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test007/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test008/expected.hs b/vim-config/haskell-vim/tests/indent/test008/expected.hs new file mode 100644 index 00000000..9f3cfbda --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test008/expected.hs @@ -0,0 +1,6 @@ +data Foo + = Foo + { foo :: Int + , bar :: Char + , baz :: Int + } deriving (Eq, Ord) diff --git a/vim-config/haskell-vim/tests/indent/test008/test.hs b/vim-config/haskell-vim/tests/indent/test008/test.hs new file mode 100644 index 00000000..48d4facd --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test008/test.hs @@ -0,0 +1,6 @@ +data Foo + = Foo + { foo :: Int + , bar :: Char + , baz :: Int + } deriving (Eq, Ord) diff --git a/vim-config/haskell-vim/tests/indent/test008/test.vim b/vim-config/haskell-vim/tests/indent/test008/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test008/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test009/expected.hs b/vim-config/haskell-vim/tests/indent/test009/expected.hs new file mode 100644 index 00000000..a6ce1e6c --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test009/expected.hs @@ -0,0 +1,2 @@ +let x = + 123 diff --git a/vim-config/haskell-vim/tests/indent/test009/test.hs b/vim-config/haskell-vim/tests/indent/test009/test.hs new file mode 100644 index 00000000..e5de207c --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test009/test.hs @@ -0,0 +1 @@ +let x = diff --git a/vim-config/haskell-vim/tests/indent/test009/test.vim b/vim-config/haskell-vim/tests/indent/test009/test.vim new file mode 100644 index 00000000..5ac89f26 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test009/test.vim @@ -0,0 +1,3 @@ +o123 +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test010/expected.hs b/vim-config/haskell-vim/tests/indent/test010/expected.hs new file mode 100644 index 00000000..fa6a1ebd --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test010/expected.hs @@ -0,0 +1,2 @@ +SomeRecord { name = ")" + , diff --git a/vim-config/haskell-vim/tests/indent/test010/test.hs b/vim-config/haskell-vim/tests/indent/test010/test.hs new file mode 100644 index 00000000..130406e8 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test010/test.hs @@ -0,0 +1 @@ +SomeRecord { name = ")" diff --git a/vim-config/haskell-vim/tests/indent/test010/test.vim b/vim-config/haskell-vim/tests/indent/test010/test.vim new file mode 100644 index 00000000..d7687992 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test010/test.vim @@ -0,0 +1,3 @@ +o,  +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test011/expected.hs b/vim-config/haskell-vim/tests/indent/test011/expected.hs new file mode 100644 index 00000000..5239d7e5 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test011/expected.hs @@ -0,0 +1,3 @@ +add1 x = x + y + where + y = 1 diff --git a/vim-config/haskell-vim/tests/indent/test011/test.hs b/vim-config/haskell-vim/tests/indent/test011/test.hs new file mode 100644 index 00000000..c6562aa0 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test011/test.hs @@ -0,0 +1,3 @@ +add1 x = x + y +where + y = 1 diff --git a/vim-config/haskell-vim/tests/indent/test011/test.vim b/vim-config/haskell-vim/tests/indent/test011/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test011/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test012/expected.hs b/vim-config/haskell-vim/tests/indent/test012/expected.hs new file mode 100644 index 00000000..09ccaa19 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test012/expected.hs @@ -0,0 +1,3 @@ +add2 x = let y = 1 + z = 1 + in = x + y + z diff --git a/vim-config/haskell-vim/tests/indent/test012/test.hs b/vim-config/haskell-vim/tests/indent/test012/test.hs new file mode 100644 index 00000000..73bc7921 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test012/test.hs @@ -0,0 +1,3 @@ +add2 x = let y = 1 + z = 1 + in = x + y + z diff --git a/vim-config/haskell-vim/tests/indent/test012/test.vim b/vim-config/haskell-vim/tests/indent/test012/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test012/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test013/expected.hs b/vim-config/haskell-vim/tests/indent/test013/expected.hs new file mode 100644 index 00000000..f0d5693e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test013/expected.hs @@ -0,0 +1,2 @@ +-- +type F k = [k] diff --git a/vim-config/haskell-vim/tests/indent/test013/test.hs b/vim-config/haskell-vim/tests/indent/test013/test.hs new file mode 100644 index 00000000..f0d5693e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test013/test.hs @@ -0,0 +1,2 @@ +-- +type F k = [k] diff --git a/vim-config/haskell-vim/tests/indent/test013/test.vim b/vim-config/haskell-vim/tests/indent/test013/test.vim new file mode 100644 index 00000000..a441a761 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test013/test.vim @@ -0,0 +1,3 @@ +=G +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test014/expected.hs b/vim-config/haskell-vim/tests/indent/test014/expected.hs new file mode 100644 index 00000000..3cb1882d --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test014/expected.hs @@ -0,0 +1,5 @@ +foo :: Monad m + => Functor m + => MonadIO m + -> Int +foo x = x diff --git a/vim-config/haskell-vim/tests/indent/test014/test.hs b/vim-config/haskell-vim/tests/indent/test014/test.hs new file mode 100644 index 00000000..f0e9a16b --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test014/test.hs @@ -0,0 +1 @@ +foo :: Monad m diff --git a/vim-config/haskell-vim/tests/indent/test014/test.vim b/vim-config/haskell-vim/tests/indent/test014/test.vim new file mode 100644 index 00000000..7f71525c --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test014/test.vim @@ -0,0 +1,3 @@ +o=> Functor m => MonadIO m -> Int foo x = x +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test015/expected.hs b/vim-config/haskell-vim/tests/indent/test015/expected.hs new file mode 100644 index 00000000..97f95ad4 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test015/expected.hs @@ -0,0 +1,3 @@ +f x = y + where + y = 2 * x diff --git a/vim-config/haskell-vim/tests/indent/test015/test.hs b/vim-config/haskell-vim/tests/indent/test015/test.hs new file mode 100644 index 00000000..f2c288ec --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test015/test.hs @@ -0,0 +1,3 @@ +f x = y +where +y = 2 * x diff --git a/vim-config/haskell-vim/tests/indent/test015/test.vim b/vim-config/haskell-vim/tests/indent/test015/test.vim new file mode 100644 index 00000000..83486f0f --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test015/test.vim @@ -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! diff --git a/vim-config/haskell-vim/tests/indent/test016/expected.hs b/vim-config/haskell-vim/tests/indent/test016/expected.hs new file mode 100644 index 00000000..fb91cfd6 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test016/expected.hs @@ -0,0 +1,6 @@ + where + foo :: Monad m + => Functor m + => MonadIO m + -> Int + foo x = x diff --git a/vim-config/haskell-vim/tests/indent/test016/test.hs b/vim-config/haskell-vim/tests/indent/test016/test.hs new file mode 100644 index 00000000..783fb83e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test016/test.hs @@ -0,0 +1,5 @@ + where + foo :: Monad m + => Functor m + => MonadIO m + -> Int diff --git a/vim-config/haskell-vim/tests/indent/test016/test.vim b/vim-config/haskell-vim/tests/indent/test016/test.vim new file mode 100644 index 00000000..c5d28a81 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test016/test.vim @@ -0,0 +1,3 @@ +Gofoo x = x +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test017/expected.hs b/vim-config/haskell-vim/tests/indent/test017/expected.hs new file mode 100644 index 00000000..96e5bce3 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test017/expected.hs @@ -0,0 +1,2 @@ +where countUntilClosed (x:xs) + | x diff --git a/vim-config/haskell-vim/tests/indent/test017/test.hs b/vim-config/haskell-vim/tests/indent/test017/test.hs new file mode 100644 index 00000000..665a9c49 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test017/test.hs @@ -0,0 +1 @@ +where countUntilClosed (x:xs) diff --git a/vim-config/haskell-vim/tests/indent/test017/test.vim b/vim-config/haskell-vim/tests/indent/test017/test.vim new file mode 100644 index 00000000..731f6e13 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test017/test.vim @@ -0,0 +1,3 @@ +o| x +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test018/expected.hs b/vim-config/haskell-vim/tests/indent/test018/expected.hs new file mode 100644 index 00000000..82456c3e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test018/expected.hs @@ -0,0 +1,4 @@ + let foo = 1 + bar = baz + quux + in diff --git a/vim-config/haskell-vim/tests/indent/test018/test.hs b/vim-config/haskell-vim/tests/indent/test018/test.hs new file mode 100644 index 00000000..82456c3e --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test018/test.hs @@ -0,0 +1,4 @@ + let foo = 1 + bar = baz + quux + in diff --git a/vim-config/haskell-vim/tests/indent/test018/test.vim b/vim-config/haskell-vim/tests/indent/test018/test.vim new file mode 100644 index 00000000..55b29be3 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test018/test.vim @@ -0,0 +1,3 @@ +G== +:saveas! result.hs +:q! diff --git a/vim-config/haskell-vim/tests/indent/test019/expected.hs b/vim-config/haskell-vim/tests/indent/test019/expected.hs new file mode 100644 index 00000000..eb2b9e8d --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test019/expected.hs @@ -0,0 +1,8 @@ + foo x + | x == x = True + + | + + , + + = diff --git a/vim-config/haskell-vim/tests/indent/test019/test.hs b/vim-config/haskell-vim/tests/indent/test019/test.hs new file mode 100644 index 00000000..553b20fd --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test019/test.hs @@ -0,0 +1,3 @@ + foo x + | x == x = True + diff --git a/vim-config/haskell-vim/tests/indent/test019/test.vim b/vim-config/haskell-vim/tests/indent/test019/test.vim new file mode 100644 index 00000000..c75971c9 --- /dev/null +++ b/vim-config/haskell-vim/tests/indent/test019/test.vim @@ -0,0 +1,3 @@ +Go| o ,o =  +:saveas! result.hs +:q! diff --git a/vim-config/plugins/haskell-vim b/vim-config/plugins/haskell-vim deleted file mode 160000 index b1ac4680..00000000 --- a/vim-config/plugins/haskell-vim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b1ac46807835423c4a4dd063df6d5b613d89c731