annotate runtime/syntax/lhaskell.vim @ 1956:5d2f6d04c82f v7.2.253

updated for version 7.2-253
author vimboss
date Fri, 11 Sep 2009 12:19:51 +0000
parents 0b796e045c42
children 7bc41231fbc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: Haskell with literate comments, Bird style,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " TeX style and plain text surrounding
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " \begin{code} \end{code} blocks
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Maintainer: Haskell Cafe mailinglist <haskell-cafe@haskell.org>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 " Original Author: Arthur van Leeuwen <arthurvl@cs.uu.nl>
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
7 " Last Change: 2008 Jul 01
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
8 " Version: 1.02
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 " Thanks to Ian Lynagh for thoughtful comments on initial versions and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 " for the inspiration for writing this in the first place.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 " This style guesses as to the type of markup used in a literate haskell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 " file and will highlight (La)TeX markup if it finds any
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " This behaviour can be overridden, both glabally and locally using
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " the lhs_markup variable or b:lhs_markup variable respectively.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 " lhs_markup must be set to either tex or none to indicate that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " you always want (La)TeX highlighting or no highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " must not be set to let the highlighting be guessed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " b:lhs_markup must be set to eiterh tex or none to indicate that
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 " you want (La)TeX highlighting or no highlighting for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 " this particular buffer
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 " must not be set to let the highlighting be guessed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 " 2004 February 18: New version, based on Ian Lynagh's TeX guessing
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " lhaskell.vim, cweb.vim, tex.vim, sh.vim and fortran.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " 2004 February 20: Cleaned up the guessing and overriding a bit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 " 2004 February 23: Cleaned up syntax highlighting for \begin{code} and
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 " \end{code}, added some clarification to the attributions
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
32 " 2008 July 1: Removed % from guess list, as it totally breaks plain
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
33 " text markup guessing
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 " First off, see if we can inherit a user preference for lhs_markup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 if !exists("b:lhs_markup")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if exists("lhs_markup")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if lhs_markup =~ '\<\%(tex\|none\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 let b:lhs_markup = matchstr(lhs_markup,'\<\%(tex\|none\)\>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 echohl WarningMsg | echo "Unknown value of lhs_markup" | echohl None
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 if b:lhs_markup !~ '\<\%(tex\|none\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " Remember where the cursor is, and go to upperleft
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let s:oldline=line(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let s:oldcolumn=col(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 call cursor(1,1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 " If no user preference, scan buffer for our guess of the markup to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " highlight. We only differentiate between TeX and plain markup, where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " plain is not highlighted. The heuristic for finding TeX markup is if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " one of the following occurs anywhere in the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " - \documentclass
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " - \begin{env} (for env != code)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " - \part, \chapter, \section, \subsection, \subsubsection, etc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 if b:lhs_markup == "unknown"
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
76 if search('\\documentclass\|\\begin{\(code}\)\@!\|\\\(sub \)*section\|\\chapter|\\part','W') != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 let b:lhs_markup = "tex"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 let b:lhs_markup = "plain"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 22
diff changeset
83 " If user wants us to highlight TeX syntax or guess thinks it's TeX, read it.
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 if b:lhs_markup == "tex"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 source <sfile>:p:h/tex.vim
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
87 set isk+=_
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 runtime! syntax/tex.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 unlet b:current_syntax
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
91 " Tex.vim removes "_" from 'iskeyword', but we need it for Haskell.
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
92 setlocal isk+=_
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 " Literate Haskell is Haskell in between text, so at least read Haskell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 syntax include @haskellTop <sfile>:p:h/haskell.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 syntax include @haskellTop syntax/haskell.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 syntax region lhsHaskellBirdTrack start="^>" end="\%(^[^>]\)\@=" contains=@haskellTop,lhsBirdTrack
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 syntax region lhsHaskellBeginEndBlock start="^\\begin{code}\s*$" matchgroup=NONE end="\%(^\\end{code}.*$\)\@=" contains=@haskellTop,@beginCode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 syntax match lhsBirdTrack "^>" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 syntax match beginCodeBegin "^\\begin" nextgroup=beginCodeCode contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 syntax region beginCodeCode matchgroup=texDelimiter start="{" end="}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 syntax cluster beginCode contains=beginCodeBegin,beginCodeCode
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 if version >= 508 || !exists("did_tex_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 let did_tex_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 HiLink lhsBirdTrack Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 HiLink beginCodeBegin texCmdName
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 HiLink beginCodeCode texSection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 " Restore cursor to original position, as it may have been disturbed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 " by the searches in our guessing code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 call cursor (s:oldline, s:oldcolumn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 unlet s:oldline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 unlet s:oldcolumn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 let b:current_syntax = "lhaskell"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 " vim: ts=8