[Haskell-cafe] Literate Haskell in Vim - a bug and a workaround (?)

Piotr Kalinowski pitkali at gmail.com
Fri Jun 9 08:01:54 EDT 2006


Hi,

I've been recently playing with literate haskell in latex mode in Vim.
The versions are:

Vim - 6.4.6
tex.vim - 30
lhaskell.vim - 1.01

I encountered a bug. If you put \section (or \subsection or \chapter
or other similar command), haskell syntax highlighting is lost from
this command onwards.

I tried some googling and searching this list's archives but found
nothing. After going through tex.vim and reading vim docs I found out,
that adding 'containedin tex.*Zone' to the following line:

syntax region lhsHaskellBeginEndBlock start="^\\begin{code}\s*$"
matchgroup=NONE end="\%(^\\end{code}.*$\)\@="
contains=@haskellTop, at beginCode

appears to solve the problem. Apparently the bug is caused by
texSectionZone (and other zones) syntax region which extends from
\section command until another \section command. Since
lhsHaskellBeginEndBlock region was not allowed inside texSectionZone,
it was not recognised. Adding containedin clause addresses this
problem letting vim to recognise \begin{code} as beginning of the
Haskell file part.

Such change however breaks tex lexical checks. More specifically -
texMatcher from tex.vim is unable to match braces around section
titles (chapter, subsection, etc.). I tried tampering with
lhaskell.vim for some time but found no way to fix it. (Which is not
surprising, given the fact that I am far from being vim expert. In
fact I know almost nothing about vim programming.)

Therefore the patch I attach simply turns lexical checks off setting
g:tex_no_error variable. The variable is then unset immediately after
loading tex.vim in order not to affect other buffers where it can work
correctly.

I attach the patch with those two changes. It is diff -u output. Any
comments are welcome. I would especially be happy to learn how to fix
texMatcher issue without turning it off.

Regards,
Piotr Kalinowski
-- 
Intelligence is like a river: the deeper it is, the less noise it makes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lhaskell.vim.patch
Type: text/x-patch
Size: 1293 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20060609/0a04fbd0/lhaskell.vim.bin


More information about the Haskell-Cafe mailing list