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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

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

Piotr Kalinowski

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}.*$\)\@="

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

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.

Piotr Kalinowski
Intelligence is like a river: the deeper it is, the less noise it makes

Haskell-Cafe mailing list
[hidden email]

lhaskell.vim.patch (1K) Download Attachment