on master help sign in
vim: added rewrite construct
3bed740raichoo
contribs/tool-support/vim/indent/idris.vim+11−1
@@ -3,7 +3,7 @@
3" Based on haskell indentation by motemen <motemen@gmail.com>
3" Based on haskell indentation by motemen <motemen@gmail.com>
4"
4"
5" author: raichoo (raichoo@googlemail.com)
5" author: raichoo (raichoo@googlemail.com)
6−" date: Nov 2 2012
6+" date: Mar 19 2013
7"
7"
8" Modify g:idris_indent_if and g:idris_indent_case to
8" Modify g:idris_indent_if and g:idris_indent_case to
9" change indentation for `if'(default 3) and `case'(default 5).
9" change indentation for `if'(default 3) and `case'(default 5).
@@ -36,6 +36,12 @@ if !exists('g:idris_indent_let')
36 let g:idris_indent_let = 4
36 let g:idris_indent_let = 4
37endif
37endif
38
38
39+if !exists('g:idris_indent_rewrite')
40+ " rewrite prf in expr
41+ " >>>>x
42+ let g:idris_indent_rewrite = 8
43+endif
44+
39if !exists('g:idris_indent_where')
45if !exists('g:idris_indent_where')
40 " where f : Nat -> Nat
46 " where f : Nat -> Nat
41 " >>>>>>f x = x
47 " >>>>>>f x = x
@@ -71,6 +77,10 @@ function! GetIdrisIndent()
71 return match(prevline, 'let') + g:idris_indent_let
77 return match(prevline, 'let') + g:idris_indent_let
72 endif
78 endif
73
79
80+ if prevline =~ '\<rewrite\>\s\+.\+\<in\>\s*$'
81+ return match(prevline, 'rewrite') + g:idris_indent_rewrite
82+ endif
83+
74 if prevline !~ '\<else\>'
84 if prevline !~ '\<else\>'
75 let s = match(prevline, '\<if\>.*\&.*\zs\<then\>')
85 let s = match(prevline, '\<if\>.*\&.*\zs\<then\>')
76 if s > 0
86 if s > 0
contribs/tool-support/vim/syntax/idris.vim+2−2
@@ -4,7 +4,7 @@
4" highlighter to support idris.
4" highlighter to support idris.
5"
5"
6" author: raichoo (raichoo@googlemail.com)
6" author: raichoo (raichoo@googlemail.com)
7−" date: Mar 12 2013
7+" date: Mar 19 2013
8
8
9syn match idrisModule "\<\(module\|namespace\)\>"
9syn match idrisModule "\<\(module\|namespace\)\>"
10syn match idrisImport "\<import\>"
10syn match idrisImport "\<import\>"
@@ -12,7 +12,7 @@ syn match idrisStructure "\<\(class\|\(co\)\?data\|instance\|where\|record\|dsl\
12syn match idrisVisibility "\<\(public\|abstract\|private\)\>"
12syn match idrisVisibility "\<\(public\|abstract\|private\)\>"
13syn match idrisBlock "\<\(parameters\|mutual\|postulate\|using\)\>"
13syn match idrisBlock "\<\(parameters\|mutual\|postulate\|using\)\>"
14syn match idrisAnnotation "\<\(total\|partial\|auto\|impossible\|static\|implicit\)\>"
14syn match idrisAnnotation "\<\(total\|partial\|auto\|impossible\|static\|implicit\)\>"
15−syn match idrisStatement "\<\(do\|case\|of\|let\|in\|with\)\>"
15+syn match idrisStatement "\<\(do\|case\|of\|rewrite\|let\|in\|with\)\>"
16syn match idrisSyntax "\(pattern \+\|term \+\)\?syntax"
16syn match idrisSyntax "\(pattern \+\|term \+\)\?syntax"
17syn match idrisConditional "\<\(if\|then\|else\)\>"
17syn match idrisConditional "\<\(if\|then\|else\)\>"
18syn match idrisTactic contained "\<\(intros\?\|rewrite\|exact\|refine\|trivial\|let\|focus\|try\|compute\|solve\|attack\|reflect\)\>"
18syn match idrisTactic contained "\<\(intros\?\|rewrite\|exact\|refine\|trivial\|let\|focus\|try\|compute\|solve\|attack\|reflect\)\>"