Skip to content

Commit 5ad8af1

Browse files
committed
Merge branch 'neovimhaskell-master'
2 parents 8f8cff1 + 3a89f39 commit 5ad8af1

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

indent/haskell.vim

+14-14
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ function! GetHaskellIndent()
189189

190190
" operator at end of previous line
191191
if l:prevline =~ '[!#$%&*+./<>?@\\^|~-]\s*$'
192-
return indent(v:lnum - 1) + &shiftwidth
192+
return indent(v:lnum - 1) + shiftwidth()
193193
endif
194194

195195
" let foo =
196196
" >>>>>>bar
197197
if l:prevline =~ '\C\<let\>\s\+[^=]\+=\s*$'
198-
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let + &shiftwidth
198+
return match(l:prevline, '\C\<let\>') + g:haskell_indent_let + shiftwidth()
199199
endif
200200

201201
" let x = 1 in
@@ -243,7 +243,7 @@ function! GetHaskellIndent()
243243
" >>foo
244244
"
245245
if l:prevline =~ '\C\<where\>\s*$'
246-
return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', &shiftwidth)
246+
return indent(v:lnum - 1) + get(g:, 'haskell_indent_after_bare_where', shiftwidth())
247247
endif
248248

249249
" do
@@ -252,7 +252,7 @@ function! GetHaskellIndent()
252252
" foo =
253253
" >>bar
254254
if l:prevline =~ '\C\(\<do\>\|=\)\s*$'
255-
return indent(v:lnum - 1) + &shiftwidth
255+
return indent(v:lnum - 1) + shiftwidth()
256256
endif
257257

258258
" do foo
@@ -268,7 +268,7 @@ function! GetHaskellIndent()
268268
" >>bar -> quux
269269
if l:prevline =~ '\C\<case\>.\+\<of\>\s*$'
270270
if get(g:,'haskell_indent_case_alternative', 0)
271-
return indent(v:lnum - 1) + &shiftwidth
271+
return indent(v:lnum - 1) + shiftwidth()
272272
else
273273
return match(l:prevline, '\C\<case\>') + g:haskell_indent_case
274274
endif
@@ -301,7 +301,7 @@ function! GetHaskellIndent()
301301
" newtype Foo = Foo
302302
" >>deriving
303303
if l:prevline =~ '\C^\s*\<\(newtype\|data\)\>[^{]\+' && l:line =~ '\C^\s*\<deriving\>'
304-
return indent(v:lnum - 1) + &shiftwidth
304+
return indent(v:lnum - 1) + shiftwidth()
305305
endif
306306

307307
" foo :: Int
@@ -314,7 +314,7 @@ function! GetHaskellIndent()
314314
if l:line =~ '^\s*[-=]>'
315315
return match(l:prevline, '::\s')
316316
elseif match(l:prevline, '^\s\+::') > -1
317-
return match(l:prevline, '::\s') - &shiftwidth
317+
return match(l:prevline, '::\s') - shiftwidth()
318318
endif
319319
endif
320320

@@ -394,21 +394,21 @@ function! GetHaskellIndent()
394394
">>>>>=> Int
395395
if l:prevline =~ '^\s*)' && l:line =~ '^\s*=>'
396396
let l:s = match(l:prevline, ')')
397-
return l:s - (&shiftwidth + 1)
397+
return l:s - (shiftwidth() + 1)
398398
endif
399399

400400
" module Foo
401401
" >>( bar
402402
if l:prevline =~ '\C^\<module\>'
403-
return &shiftwidth
403+
return shiftwidth()
404404
endif
405405

406406
" foo
407407
" >>{
408408
if l:line =~ '^\s*{'
409409
let l:s = indent(v:lnum - 1)
410410
if l:s >= 0
411-
return l:s + &shiftwidth
411+
return l:s + shiftwidth()
412412
endif
413413
endif
414414

@@ -424,7 +424,7 @@ function! GetHaskellIndent()
424424
return match(l:prevline, 'in') - g:haskell_indent_in
425425
endif
426426

427-
return indent(v:lnum - 1) + get(g:, 'haskell_indent_before_where', &shiftwidth)
427+
return indent(v:lnum - 1) + get(g:, 'haskell_indent_before_where', shiftwidth())
428428
endif
429429

430430
" let x = 1
@@ -458,13 +458,13 @@ function! GetHaskellIndent()
458458
" >>=
459459
if l:line =~ '^\s*='
460460
if l:prevline =~ '\C^\<data\>\s\+[^=]\+\s*$'
461-
return match(l:prevline, '\C\<data\>') + &shiftwidth
461+
return match(l:prevline, '\C\<data\>') + shiftwidth()
462462
else
463463
let l:s = s:indentGuard(match(l:line, '='), l:prevline)
464464
if l:s > 0
465465
return l:s
466466
else
467-
return &shiftwidth
467+
return shiftwidth()
468468
endif
469469
endif
470470
endif
@@ -489,7 +489,7 @@ function! GetHaskellIndent()
489489
" foo
490490
" >>:: Int
491491
if l:line =~ '^\s*::\s'
492-
return indent(v:lnum - 1) + &shiftwidth
492+
return indent(v:lnum - 1) + shiftwidth()
493493
endif
494494

495495
" indent closing brace, paren or bracket

syntax/cabal.vim

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ syn match cabalDocBulletPoint "^\s\+\*"
2121
syn match cabalDocHeadline "^\s\+=.*$"
2222
syn match cabalDocCode "^\s\+>.*$"
2323
syn match cabalDocNewline "^\s\+\.\s*$"
24-
syn match cabalSection "^\c\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\)"
24+
syn match cabalSection "^\c\(executable\|library\|flag\|source-repository\|test-suite\|benchmark\|common\)"
2525
syn match cabalEntry "^\s*[A-Za-z][a-zA-Z\-]*:" contains=cabalIdentifier,cabalColon
2626

2727
syn region cabalDescription start="^\s*[dD]escription:" end="^\<" keepend

syntax/haskell.vim

+12-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ syn match haskellTypeSig
3636
\ haskellParens
3737
syn keyword haskellWhere where
3838
syn keyword haskellLet let
39-
syn match HaskellDerive "\<deriving\>\(\s\+\<\(anyclass\|instance\|newtype\|stock\)\>\)\?"
39+
syn keyword haskellDeriveKeyword deriving anyclass instance newtype stock via contained
40+
syn match haskellDerive "deriving\(\s\+instance\)\?\(\s\+anyclass\|\s\+newtype\|\s\+stock\|\s\+.\{-}\_s\+via\)\?"
41+
\ contains=
42+
\ haskellDeriveKeyword,
43+
\ haskellParens,
44+
\ haskellType
4045
syn keyword haskellDeclKeyword module class instance newtype in
4146
syn match haskellDecl "\<\(type\|data\)\>\s\+\(\<family\>\)\?"
4247
syn keyword haskellDefault default
@@ -63,8 +68,8 @@ if get(g:, 'haskell_enable_static_pointers', 0)
6368
syn keyword haskellStatic static
6469
endif
6570
syn keyword haskellConditional if then else
66-
syn match haskellNumber "\<[0-9]\+\>\|\<0[xX][0-9a-fA-F]\+\>\|\<0[oO][0-7]\+\>\|\<0[bB][10]\+\>"
67-
syn match haskellFloat "\<[0-9]\+\.[0-9]\+\([eE][-+]\=[0-9]\+\)\=\>"
71+
syn match haskellNumber "\<[0-9]\+\>\|\<[0-9_]\+\>\|\<0[xX][0-9a-fA-F_]\+\>\|\<0[oO][0-7_]\+\>\|\<0[bB][10_]\+\>"
72+
syn match haskellFloat "\<[0-9]\+\.[0-9_]\+\([eE][-+]\=[0-9_]\+\)\=\>"
6873
syn match haskellSeparator "[,;]"
6974
syn region haskellParens matchgroup=haskellDelimiter start="(" end=")" contains=TOP,haskellTypeSig,@Spell
7075
syn region haskellBrackets matchgroup=haskellDelimiter start="\[" end="]" contains=TOP,haskellTypeSig,@Spell
@@ -90,7 +95,7 @@ syn match haskellLineComment "---*\([^-!#$%&\*\+./<=>\?@\\^|~].*\)\?$"
9095
syn match haskellBacktick "`[A-Za-z_][A-Za-z0-9_\.']*#\?`"
9196
syn region haskellString start=+"+ skip=+\\\\\|\\"+ end=+"+
9297
\ contains=@Spell
93-
syn match haskellIdentifier "\%([A-Z][a-zA-Z_']*\.\)*[_a-z][a-zA-z0-9_']*" contained
98+
syn match haskellIdentifier "\%([A-Z][a-zA-Z0-9_']*\.\)*[_a-z][a-zA-z0-9_']*" contained
9499
syn match haskellChar "\<'[^'\\]'\|'\\.'\|'\\u[0-9a-fA-F]\{4}'\>"
95100
syn match haskellType "\<[A-Z][a-zA-Z0-9_']*\%(\.[A-Z][a-zA-Z0-9_']*\)*\.\@!\>"
96101
syn region haskellBlockComment start="{-" end="-}"
@@ -106,7 +111,7 @@ syn keyword haskellTodo TODO FIXME XXX contained
106111
syn match haskellShebang "\%^#!.*$"
107112
if !get(g:, 'haskell_disable_TH', 0)
108113
syn match haskellQuasiQuoted "." containedin=haskellQuasiQuote contained
109-
syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-z0-9._']*|" end="|\]"
114+
syn region haskellQuasiQuote matchgroup=haskellTH start="\[[_a-zA-Z][a-zA-Z0-9._']*|" end="|\]"
110115
syn region haskellTHBlock matchgroup=haskellTH start="\[\(d\|t\|p\)\?|" end="|]" contains=TOP
111116
syn region haskellTHDoubleBlock matchgroup=haskellTH start="\[||" end="||]" contains=TOP
112117
endif
@@ -161,13 +166,13 @@ highlight def link haskellType Type
161166
highlight def link haskellImportKeywords Include
162167
if get(g:, 'haskell_classic_highlighting', 0)
163168
highlight def link haskellDeclKeyword Keyword
164-
highlight def link HaskellDerive Keyword
169+
highlight def link haskellDeriveKeyword Keyword
165170
highlight def link haskellDecl Keyword
166171
highlight def link haskellWhere Keyword
167172
highlight def link haskellLet Keyword
168173
else
169174
highlight def link haskellDeclKeyword Structure
170-
highlight def link HaskellDerive Structure
175+
highlight def link haskellDeriveKeyword Structure
171176
highlight def link haskellDecl Structure
172177
highlight def link haskellWhere Structure
173178
highlight def link haskellLet Structure

0 commit comments

Comments
 (0)