<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>lhaskell.vim</title>
<style type="text/css">
.enscript-comment { font-style: italic; color: rgb(178,34,34); }
.enscript-function-name { font-weight: bold; color: rgb(0,0,255); }
.enscript-variable-name { font-weight: bold; color: rgb(184,134,11); }
.enscript-keyword { font-weight: bold; color: rgb(160,32,240); }
.enscript-reference { font-weight: bold; color: rgb(95,158,160); }
.enscript-string { font-weight: bold; color: rgb(188,143,143); }
.enscript-builtin { font-weight: bold; color: rgb(218,112,214); }
.enscript-type { font-weight: bold; color: rgb(34,139,34); }
.enscript-highlight { text-decoration: underline; color: 0; }
</style>
</head>
<body id="top">
<h1 style="margin:8px;" id="f1">lhaskell.vim&nbsp;&nbsp;&nbsp;<span style="font-weight: normal; font-size: 0.5em;">[<a href="lhaskell.vim">plain text</a>]</span></h1>
<hr/>
<div></div>
<pre>
&quot; Vim syntax file
&quot; Language:		Haskell with literate comments, Bird style,
&quot;			TeX style and plain text surrounding
&quot;			\begin{code} \end{code} blocks
&quot; Maintainer:		Haskell Cafe mailinglist &lt;<a href="mailto:haskell-cafe@haskell.org">haskell-cafe@haskell.org</a>&gt;
&quot; Original Author:	Arthur van Leeuwen &lt;<a href="mailto:arthurvl@cs.uu.nl">arthurvl@cs.uu.nl</a>&gt;
&quot; Last Change:		2010 Apr 11
&quot; Version:		1.04
&quot;
&quot; Thanks to Ian Lynagh for thoughtful comments on initial versions and
&quot; for the inspiration for writing this in the first place.
&quot;
&quot; This style guesses as to the type of markup used in a literate haskell
&quot; file and will highlight (La)TeX markup if it finds any
&quot; This behaviour can be overridden, both glabally and locally using
&quot; the lhs_markup variable or b:lhs_markup variable respectively.
&quot;
&quot; lhs_markup	    must be set to either  tex	or  none  to indicate that
&quot;		    you always want (La)TeX highlighting or no highlighting
&quot;		    must not be set to let the highlighting be guessed
&quot; b:lhs_markup	    must be set to eiterh  tex	or  none  to indicate that
&quot;		    you want (La)TeX highlighting or no highlighting for
&quot;		    this particular buffer
&quot;		    must not be set to let the highlighting be guessed
&quot;
&quot;
&quot; 2004 February 18: New version, based on Ian Lynagh's TeX guessing
&quot;		    lhaskell.vim, cweb.vim, tex.vim, sh.vim and fortran.vim
&quot; 2004 February 20: Cleaned up the guessing and overriding a bit
&quot; 2004 February 23: Cleaned up syntax highlighting for \begin{code} and
&quot;		    \end{code}, added some clarification to the attributions
&quot; 2008 July 1:      Removed % from guess list, as it totally breaks plain
&quot;                   text markup guessing
&quot; 2009 April 29:    Fixed highlighting breakage in TeX mode, 
&quot;                   thanks to Kalman Noel
&quot;


&quot; quit when a syntax file was already loaded
if exists(&quot;b:current_syntax&quot;)
  finish
endif

&quot; First off, see if we can inherit a user preference for lhs_markup
if !exists(&quot;b:lhs_markup&quot;)
    if exists(&quot;lhs_markup&quot;)
	if lhs_markup =~ '\&lt;\%(tex\|none\)\&gt;'
	    let b:lhs_markup = matchstr(lhs_markup,'\&lt;\%(tex\|none\)\&gt;')
	else
	    echohl WarningMsg | echo &quot;Unknown value of lhs_markup&quot; | echohl None
	    let b:lhs_markup = &quot;unknown&quot;
	endif
    else
	let b:lhs_markup = &quot;unknown&quot;
    endif
else
    if b:lhs_markup !~ '\&lt;\%(tex\|none\)\&gt;'
	let b:lhs_markup = &quot;unknown&quot;
    endif
endif

&quot; Remember where the cursor is, and go to upperleft
let s:oldline=line(&quot;.&quot;)
let s:oldcolumn=col(&quot;.&quot;)
call cursor(1,1)

&quot; If no user preference, scan buffer for our guess of the markup to
&quot; highlight. We only differentiate between TeX and plain markup, where
&quot; plain is not highlighted. The heuristic for finding TeX markup is if
&quot; one of the following occurs anywhere in the file:
&quot;   - \documentclass
&quot;   - \begin{env}       (for env != code)
&quot;   - \part, \chapter, \section, \subsection, \subsubsection, etc
if b:lhs_markup == &quot;unknown&quot;
    if search('\\documentclass\|\\begin{\(code}\)\@!\|\\\(sub\)*section\|\\chapter|\\part','W') != 0
	let b:lhs_markup = &quot;tex&quot;
    else
	let b:lhs_markup = &quot;plain&quot;
    endif
endif

&quot; If user wants us to highlight TeX syntax or guess thinks it's TeX, read it.
if b:lhs_markup == &quot;tex&quot;
    runtime! syntax/tex.vim
    unlet b:current_syntax
    &quot; Tex.vim removes &quot;_&quot; from 'iskeyword', but we need it for Haskell.
    setlocal isk+=_
    syntax cluster lhsTeXContainer contains=tex.*Zone,texAbstract
else
    syntax cluster lhsTeXContainer contains=.*
endif

&quot; Literate Haskell is Haskell in between text, so at least read Haskell
&quot; highlighting
syntax include @haskellTop syntax/haskell.vim

syntax region lhsHaskellBirdTrack start=&quot;^&gt;&quot; end=&quot;\%(^[^&gt;]\)\@=&quot; contains=@haskellTop,lhsBirdTrack containedin=@lhsTeXContainer
syntax region lhsHaskellBeginEndBlock start=&quot;^\\begin{code}\s*$&quot; matchgroup=NONE end=&quot;\%(^\\end{code}.*$\)\@=&quot; contains=@haskellTop,beginCodeBegin containedin=@lhsTeXContainer

syntax match lhsBirdTrack &quot;^&gt;&quot; contained

syntax match beginCodeBegin &quot;^\\begin&quot; nextgroup=beginCodeCode contained
syntax region beginCodeCode  matchgroup=texDelimiter start=&quot;{&quot; end=&quot;}&quot;

&quot; Define the default highlighting.
&quot; Only when an item doesn't have highlighting yet

hi def link lhsBirdTrack Comment

hi def link beginCodeBegin	      texCmdName
hi def link beginCodeCode	      texSection


&quot; Restore cursor to original position, as it may have been disturbed
&quot; by the searches in our guessing code
call cursor (s:oldline, s:oldcolumn)

unlet s:oldline
unlet s:oldcolumn

let b:current_syntax = &quot;lhaskell&quot;

&quot; vim: ts=8
</pre>
<hr />
</body></html>