annotate runtime/syntax/lhaskell.vim @ 5804:2cbac5608217 v7.4.246

updated for version 7.4.246 Problem: Configure message for detecting smack are out of sequence. Solution: Put the messages in the right place. (Kazunobu Kuriyama)
author Bram Moolenaar <bram@vim.org>
date Sat, 05 Apr 2014 12:02:25 +0200
parents b9e314fe473f
children 43efa4f5a8ea
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>
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 2034
diff changeset
7 " Last Change: 2010 Apr 11
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
8 " Version: 1.04
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
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
32 " 2008 July 1: Removed % from guess list, as it totally breaks plain
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
33 " text markup guessing
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
34 " 2009 April 29: Fixed highlighting breakage in TeX mode,
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
35 " thanks to Kalman Noel
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 "
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 syntax clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 " First off, see if we can inherit a user preference for lhs_markup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if !exists("b:lhs_markup")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 if exists("lhs_markup")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 if lhs_markup =~ '\<\%(tex\|none\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 let b:lhs_markup = matchstr(lhs_markup,'\<\%(tex\|none\)\>')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 echohl WarningMsg | echo "Unknown value of lhs_markup" | echohl None
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if b:lhs_markup !~ '\<\%(tex\|none\)\>'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let b:lhs_markup = "unknown"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " Remember where the cursor is, and go to upperleft
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 let s:oldline=line(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 let s:oldcolumn=col(".")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 call cursor(1,1)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 " If no user preference, scan buffer for our guess of the markup to
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 " highlight. We only differentiate between TeX and plain markup, where
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 " plain is not highlighted. The heuristic for finding TeX markup is if
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 " one of the following occurs anywhere in the file:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 " - \documentclass
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 " - \begin{env} (for env != code)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " - \part, \chapter, \section, \subsection, \subsubsection, etc
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if b:lhs_markup == "unknown"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
78 if search('\\documentclass\|\\begin{\(code}\)\@!\|\\\(sub\)*section\|\\chapter|\\part','W') != 0
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 let b:lhs_markup = "tex"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 let b:lhs_markup = "plain"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
85 " 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
86 if b:lhs_markup == "tex"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 source <sfile>:p:h/tex.vim
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
89 set isk+=_
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 runtime! syntax/tex.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 unlet b:current_syntax
22
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
93 " Tex.vim removes "_" from 'iskeyword', but we need it for Haskell.
cc049b00ee70 updated for version 7.0014
vimboss
parents: 7
diff changeset
94 setlocal isk+=_
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
96 syntax cluster lhsTeXContainer contains=tex.*Zone,texAbstract
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
97 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
98 syntax cluster lhsTeXContainer contains=.*
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 " Literate Haskell is Haskell in between text, so at least read Haskell
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 syntax include @haskellTop <sfile>:p:h/haskell.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 syntax include @haskellTop syntax/haskell.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1668
diff changeset
109 syntax region lhsHaskellBirdTrack start="^>" end="\%(^[^>]\)\@=" contains=@haskellTop,lhsBirdTrack containedin=@lhsTeXContainer
2152
b9e314fe473f Updated runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 2034
diff changeset
110 syntax region lhsHaskellBeginEndBlock start="^\\begin{code}\s*$" matchgroup=NONE end="\%(^\\end{code}.*$\)\@=" contains=@haskellTop,beginCodeBegin containedin=@lhsTeXContainer
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 syntax match lhsBirdTrack "^>" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 syntax match beginCodeBegin "^\\begin" nextgroup=beginCodeCode contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 syntax region beginCodeCode matchgroup=texDelimiter start="{" end="}"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 " 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
120 if version >= 508 || !exists("did_tex_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 let did_tex_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 HiLink lhsBirdTrack Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 HiLink beginCodeBegin texCmdName
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 HiLink beginCodeCode texSection
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 " Restore cursor to original position, as it may have been disturbed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 " by the searches in our guessing code
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 call cursor (s:oldline, s:oldcolumn)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 unlet s:oldline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 unlet s:oldcolumn
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 let b:current_syntax = "lhaskell"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 " vim: ts=8