OK, so this VIM thing -- how do I make it actually work?

I've given up on getting a decent text editor for editing Haskell
(specifically literate Haskell -- plain Haskell works fine in GEDIT).
Instead I fire up VIM and get ... a total mess. At first I think maybe
I've screwed up a whole bunch of settings or something, so I nuke
everything in my home directory that begins with .vim and then, for
added measure, head over to /usr/share and nuke the entire ./vim
directory tree. I then reinstall vim (from the Ubuntu Edgy archives) to
get a brand new set of config files unsullied by my hands.
I still get a dog's breakfast.
A screen shot of what I'm seeing with a representative example of a .lhs
file to show what I mean can be found at
http://img357.imageshack.us/img357/5798/gvimexamplezv4.png. (I've pared
it down to the minimum I could find that shows the behaviour clearly.)
The problems I'm seeing are the ugly white-on-red for underlines, the
lack of any kind of differentiation for keywords/operators/etc. vs.
identifiers (although some punctuation is recognized, specifically curly
braces), comments not being noted, etc. Basically it looks like the
Haskell is simply not being recognized at all (and, if the @saBinds@
thing is what I think it is, it looks like some latex isn't being
recognized fully either).
Can anybody vim-centric please take a look at this and give me a few
educated guesses as to what is happening here? For good measure, here's
the beginning of the lhaskell.vim file that comes with my vim
distribution (7.0 in the Ubuntu archives). If it's desired I can attach
the whole file. (It isn't actually all that large.)
" Vim syntax file
" Language: Haskell with literate comments, Bird style,
" TeX style and plain text surrounding
" \begin{code} \end{code} blocks
" Maintainer: Haskell Cafe mailinglist

On Tue, Jun 05, 2007 at 04:58:40PM +0800, Michael T. Richter wrote:
I've given up on getting a decent text editor for editing Haskell (specifically literate Haskell -- plain Haskell works fine in GEDIT). Instead I fire up VIM and get ... a total mess. At first I think maybe I've screwed up a whole bunch of settings or something, so I nuke everything in my home directory that begins with .vim and then, for added measure, head over to /usr/share and nuke the entire ./vim directory tree. I then reinstall vim (from the Ubuntu Edgy archives) to get a brand new set of config files unsullied by my hands.
I still get a dog's breakfast.
A screen shot of what I'm seeing with a representative example of a .lhs file to show what I mean can be found at http://img357.imageshack.us/img357/5798/gvimexamplezv4.png. (I've pared it down to the minimum I could find that shows the behaviour clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Can anybody vim-centric please take a look at this and give me a few educated guesses as to what is happening here? For good measure, here's the beginning of the lhaskell.vim file that comes with my vim distribution (7.0 in the Ubuntu archives). If it's desired I can attach the whole file. (It isn't actually all that large.) It seems to me like VIM thinks your file is a (La)TeX file. Can you check that your filetype variable is set to lhaskell? (Type :set filetype) It should be if your file has extension .lhs. If it isn't, try setting it manually (:set filetype=lhaskell)

To back him up, it seems that the lhaskell.vim syntax highlighter is broken
with Vim 7.1. Here, it is definitely using lhaskell.vim, but doesn't seem to
be parsing the code in between \begin{code} and \end{code} as Haskell.
I can't work out why though, it seems that the addition of \@= to the end
pattern of the code region is causing it to not be recognised, but removing
it causes other problems.
Adding the keepend option makes it work nicely for the first block, but fail
to highlight later blocks.
On 05/06/07, Ilya Tsindlekht
On Tue, Jun 05, 2007 at 04:58:40PM +0800, Michael T. Richter wrote:
I've given up on getting a decent text editor for editing Haskell (specifically literate Haskell -- plain Haskell works fine in GEDIT). Instead I fire up VIM and get ... a total mess. At first I think maybe I've screwed up a whole bunch of settings or something, so I nuke everything in my home directory that begins with .vim and then, for added measure, head over to /usr/share and nuke the entire ./vim directory tree. I then reinstall vim (from the Ubuntu Edgy archives) to get a brand new set of config files unsullied by my hands.
I still get a dog's breakfast.
A screen shot of what I'm seeing with a representative example of a .lhs file to show what I mean can be found at http://img357.imageshack.us/img357/5798/gvimexamplezv4.png. (I've pared it down to the minimum I could find that shows the behaviour clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Can anybody vim-centric please take a look at this and give me a few educated guesses as to what is happening here? For good measure, here's the beginning of the lhaskell.vim file that comes with my vim distribution (7.0 in the Ubuntu archives). If it's desired I can attach the whole file. (It isn't actually all that large.) It seems to me like VIM thinks your file is a (La)TeX file. Can you check that your filetype variable is set to lhaskell? (Type :set filetype) It should be if your file has extension .lhs. If it isn't, try setting it manually (:set filetype=lhaskell)
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Tue, Jun 05, 2007 at 10:41:44AM +0100, Rodrigo Queiro wrote:
To back him up, it seems that the lhaskell.vim syntax highlighter is broken with Vim 7.1. Here, it is definitely using lhaskell.vim, but doesn't seem to be parsing the code in between \begin{code} and \end{code} as Haskell.
Works fine for me on Debian. The dpkg describes vim as: ii vim 1:7.1-000+1 Vi IMproved - enhanced vi editor

On Tue, 2007-05-06 at 12:30 +0300, Ilya Tsindlekht wrote:
It seems to me like VIM thinks your file is a (La)TeX file. Can you check that your filetype variable is set to lhaskell? (Type :set filetype) It should be if your file has extension .lhs. If it isn't, try setting it manually (:set filetype=lhaskell)
Damn! I deleted the wrong image when I set that up.
The original image I was going to use had a thing at the bottom with all
of :set's changed variables displayed. Filetype was definitely set to
lhaskell.
--
Michael T. Richter

Hi Michael,
I can also confirm this occurs on my Vim 7.0 (I'm also running Edgy Eft).
Notably it (the red highlight on _ and loss of syntax highlighting) only
seems to occur when there is a \section (or sub) command within the .lhs (I
am also using lhs2tex). Hadn't noticed this before as I tend not to place
sectioning commands in the .lhs and use a main .tex containing sequences
like:
\subsection{Module foo}
\include{foo}
Not sure if this is present in the Feisty Fawn binaries, I guess someone
should file a bug report? :)
Dave,
On 05/06/07, Michael T. Richter
I've given up on getting a decent text editor for editing Haskell (specifically literate Haskell -- plain Haskell works fine in GEDIT). Instead I fire up VIM and get ... a total mess. At first I think maybe I've screwed up a whole bunch of settings or something, so I nuke everything in my home directory that begins with .vim and then, for added measure, head over to /usr/share and nuke the entire ./vim directory tree. I then reinstall vim (from the Ubuntu Edgy archives) to get a brand new set of config files unsullied by my hands.
I still get a dog's breakfast.
A screen shot of what I'm seeing with a representative example of a .lhs file to show what I mean can be found at http://img357.imageshack.us/img357/5798/gvimexamplezv4.png. (I've pared it down to the minimum I could find that shows the behaviour clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although *some* punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Can anybody vim-centric please take a look at this and give me a few educated guesses as to what is happening here? For good measure, here's the beginning of the lhaskell.vim file that comes with my vim distribution ( 7.0 in the Ubuntu archives). If it's desired I can attach the whole file. (It isn't actually all that large.)
" Vim syntax file " Language: Haskell with literate comments, Bird style, " TeX style and plain text surrounding " \begin{code} \end{code} blocks " Maintainer: Haskell Cafe mailinglist
" Original Author: Arthur van Leeuwen " Last Change: 2004 Aug 31 " Version: 1.01 " " Thanks to Ian Lynagh for thoughtful comments on initial versions and " for the inspiration for writing this in the first place. " " This style guesses as to the type of markup used in a literate haskell " file and will highlight (La)TeX markup if it finds any " This behaviour can be overridden, both glabally and locally using " the lhs_markup variable or b:lhs_markup variable respectively. " " lhs_markup must be set to either tex or none to indicate that " you always want (La)TeX highlighting or no highlighting " must not be set to let the highlighting be guessed " b:lhs_markup must be set to eiterh tex or none to indicate that " you want (La)TeX highlighting or no highlighting for " this particular buffer " must not be set to let the highlighting be guessed " " " 2004 February 18: New version, based on Ian Lynagh's TeX guessing " lhaskell.vim, cweb.vim, tex.vim, sh.vim and fortran.vim " 2004 February 20: Cleaned up the guessing and overriding a bit " 2004 February 23: Cleaned up syntax highlighting for \begin{code} and " \end{code}, added some clarification to the attributions " -- *Michael T. Richter*
(*GoogleTalk:* ttmrichter@gmail.com) *It's OK to figure out murder mysteries, but you shouldn't need to figure out code. You should be able to read it. (Steve McConnell)* _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for
Hi. Sorry for this stupid question but have you tried :set nohlsearch? Or /searchsomethingwhichdoesntexist<cr> ? You can also put your cursor an those underlines and use :echo synIDattr(synID(line("."), col("."), 1), "name") To get some more infromation about which syntax group is currently used there. If you get the same result on the _ and on the character to the right I don't think it's a bug but just the hlsearch feature Marc

clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for You can also put your cursor an those underlines and use
:echo synIDattr(synID(line("."), col("."), 1), "name")
looks like a highlighting bug alright. reduced example: ------------------------ H.lhs: % \section{one} \begin{code} data D_e = D String deriving Show \end{code} % \section{two} data D_e = D String deriving Show ------------------------ as it is, the first code line is haskell-highlighted, the "_" is part of a "ConId"; the second code line is tex-highlighted, the "_" becomes a "texOnlyMath", and is highlighted as a syntax error (red). if i uncomment the "\section{one}", haskell-highlighting disappears, everything is now part of a "texSectionZone", and highlighted as such, including tex syntax error highlights. if i now register code-sections as "texZone" (the zone "tex.vim" uses for "verbatim"), with haskell contents, both code lines are haskell-highlighted, so the "texSectionZone" has been interrupted.. :syn region texZone start="\\begin{code}" end="\\end{code}" contains=@haskellTop if i now uncomment the "\section{two}", a new "texSectionZone" is started there (might need a resync), and both code lines are highlighted correctly (the first as haskell, the second as -buggy- tex). "tex.vim" has several zones with no real end marker ("\section", "\chapter", ..), and it seems that "tex.vim" and "lhaskell.vim" do not interact properly. since this list is given as the maintainer for "lhaskell.vim": any literate haskellers out here who'd like to try fixing that?-) claus

the following sequence seems to help (tested on ghc/compiler/stranal/StrictAnal.lhs):
:syn sync fromstart
:syn region texZone matchgroup=hsLineComment start="\\begin{code}" end="\\end{code}"
contains=@haskellTop keepend matchgroup=NONE
i'll leave it to those who are actually using literate haskell to
check this and to have it included in lhaskell.vim if it is helpful.
claus
----- Original Message -----
From: "Claus Reinke"
clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for You can also put your cursor an those underlines and use
:echo synIDattr(synID(line("."), col("."), 1), "name")
looks like a highlighting bug alright. reduced example:
------------------------ H.lhs:
% \section{one}
\begin{code} data D_e = D String deriving Show \end{code}
% \section{two}
data D_e = D String deriving Show
------------------------
as it is, the first code line is haskell-highlighted, the "_" is part of a "ConId"; the second code line is tex-highlighted, the "_" becomes a "texOnlyMath", and is highlighted as a syntax error (red).
if i uncomment the "\section{one}", haskell-highlighting disappears, everything is now part of a "texSectionZone", and highlighted as such, including tex syntax error highlights. if i now register code-sections as "texZone" (the zone "tex.vim" uses for "verbatim"), with haskell contents, both code lines are haskell-highlighted, so the "texSectionZone" has been interrupted..
:syn region texZone start="\\begin{code}" end="\\end{code}" contains=@haskellTop
if i now uncomment the "\section{two}", a new "texSectionZone" is started there (might need a resync), and both code lines are highlighted correctly (the first as haskell, the second as -buggy- tex).
"tex.vim" has several zones with no real end marker ("\section", "\chapter", ..), and it seems that "tex.vim" and "lhaskell.vim" do not interact properly. since this list is given as the maintainer for "lhaskell.vim": any literate haskellers out here who'd like to try fixing that?-)
claus
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Dougal Stanton
On 05/06/07, Claus Reinke
wrote: (tested on ghc/compiler/stranal/StrictAnal.lhs):
Since when did GHC become NSFW?! :-O
/ducking and running...
Says more about you than anything else... ***************************************************************** Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. *****************************************************************

"Michael T. Richter"
The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Same here. I've just played around and found that the following helps: :let b:lhs_markup="none" :e Kind regards, Georg

On Tue, 2007-05-06 at 13:05 +0200, Georg Neis wrote:
"Michael T. Richter"
wrote: The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Same here. I've just played around and found that the following helps: :let b:lhs_markup="none" :e
That did it, Georg. Thanks. Now to figure out how to make that happen
all the time (and how to make vim automatically do syntax highlighting
instead of having to manually turn it on each time I run it), then I'm
back on track to regressing about 20 years of editor use. :(
--
Michael T. Richter

On Tue, 2007-05-06 at 13:05 +0200, Georg Neis wrote:
"Michael T. Richter"
wrote: The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Same here. I've just played around and found that the following helps: :let b:lhs_markup="none" :e
Oops. I spoke too soon. It works ... for about a third of the file.
It then loses its mind in the middle of a do-block (in a sizable chunk
of code) and doesn't regain it until the next code begin/end pairing
ends.
So, I guess I'm back to my original question: where can I find a decent
editor that can do syntax highlighting out of the box for literate
Haskell? (Or, alternatively, where can I find a syntax-highlighting
editor I can expand the syntax handling of on my own?) VIM is broken
out of the box and if I'm going to mess around with syntax highlighting
files, I'd at least like to do it in an editor I'm likely to be
comfortable in.
--
Michael T. Richter

Michael, Michael T. Richter wrote:
So, I guess I'm back to my original question: where can I find a decent editor that can do syntax highlighting out of the box for literate Haskell? (Or, alternatively, where can I find a syntax-highlighting editor I can expand the syntax handling of on my own?) VIM is broken out of the box and if I'm going to mess around with syntax highlighting files, I'd at least like to do it in an editor I'm likely to be comfortable in.
I can't recall whether you were asking about linux or running on Windows under cygwin. On linux (fedora-5 + gnome) I've settled on using the "kate" editor within a gnome/fedora-5 setup. It provides syntax highlighting that seems to work fine with .hs and .lhs files. If I remember, this worked "out of the box" (installed via yum). There is a link to its home page (http://kate-editor.org/kate) from the Haskell wiki. Just a suggestion ... as with all editors, it probably has some features you like, some you loathe ..! David. -- Dr. David Duke Email: djd@comp.leeds.ac.uk School of Computing Web: www.comp.leeds.ac.uk/djd/ University of Leeds Tel: +44 113 343 6800 Leeds, LS2 9JT, U.K. Fax: +44 113 343 5468

On 05/06/07, Michael T. Richter
Oops. I spoke too soon. It works ... for about a third of the file. It then loses its mind in the middle of a do-block (in a sizable chunk of code) and doesn't regain it until the next code begin/end pairing ends.
There is a fix for this (:syn sync fromstart is the usual incantation that helps) but (as a Vim user) I take your point that Vim's highlighting is not as you want it out of the box, and that matters. So, I guess I'm back to my original question: where can I find a decent
editor that can do syntax highlighting out of the box for literate Haskell? (Or, alternatively, where can I find a syntax-highlighting editor I can expand the syntax handling of on my own?) VIM is broken out of the box and if I'm going to mess around with syntax highlighting files, I'd at least like to do it in an editor I'm likely to be comfortable in.
You need to take into account the fact that highlighting literate Haskell is hard, if you want it done completely right, because there are two entirely distinct sets of syntax (Haskell and LaTeX) being interspersed (and from the look of one of your examples, you use CPP syntax in places as well). That is never going to be easy to handle. If you were happy with the LaTeX being left unhighlighted, it wouldn't be too hard to handle. Equally, if you want the LaTeX highlighting with the Haskell unhighlighted, that's easy enough as well. It's the combination that's hard. So, you should probably: 1. Accept that you're going to have very few, if any, good options 2. Think about your priorities - if you have to give something up, what would hurt you least? (FWIW, if you're happy for the LaTeX to be left unhighlighted, setting lhs_markup="none" in Vim might be enough for you). Beyond that, I can't offer any suggestions - I use Vim and am happy with it, but I know it's limited when dealing with mixed-type files (HTML + CSS + JavaScript is another common case). Hope this helps, Paul.

Perhaps you could just highlight the small subset of LaTeX that is common in .lhs files? This seems like it would be satisfactory in most cases. On 05/06/07, Paul Moore
On 05/06/07, Michael T. Richter
wrote: Oops. I spoke too soon. It works ... for about a third of the file. It then loses its mind in the middle of a do-block (in a sizable chunk of code) and doesn't regain it until the next code begin/end pairing ends.
There is a fix for this (:syn sync fromstart is the usual incantation that helps) but (as a Vim user) I take your point that Vim's highlighting is not as you want it out of the box, and that matters.
So, I guess I'm back to my original question: where can I find a decent
editor that can do syntax highlighting out of the box for literate Haskell? (Or, alternatively, where can I find a syntax-highlighting editor I can expand the syntax handling of on my own?) VIM is broken out of the box and if I'm going to mess around with syntax highlighting files, I'd at least like to do it in an editor I'm likely to be comfortable in.
You need to take into account the fact that highlighting literate Haskell is hard, if you want it done completely right, because there are two entirely distinct sets of syntax (Haskell and LaTeX) being interspersed (and from the look of one of your examples, you use CPP syntax in places as well). That is never going to be easy to handle. If you were happy with the LaTeX being left unhighlighted, it wouldn't be too hard to handle. Equally, if you want the LaTeX highlighting with the Haskell unhighlighted, that's easy enough as well. It's the combination that's hard.
So, you should probably:
1. Accept that you're going to have very few, if any, good options 2. Think about your priorities - if you have to give something up, what would hurt you least? (FWIW, if you're happy for the LaTeX to be left unhighlighted, setting lhs_markup="none" in Vim might be enough for you).
Beyond that, I can't offer any suggestions - I use Vim and am happy with it, but I know it's limited when dealing with mixed-type files (HTML + CSS + JavaScript is another common case).
Hope this helps, Paul.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 5-jun-2007, at 10:58, Michael T. Richter wrote:
I've given up on getting a decent text editor for editing Haskell (specifically literate Haskell -- plain Haskell works fine in GEDIT). Instead I fire up VIM and get ... a total mess. At first I think maybe I've screwed up a whole bunch of settings or something, so I nuke everything in my home directory that begins with .vim and then, for added measure, head over to /usr/share and nuke the entire ./vim directory tree. I then reinstall vim (from the Ubuntu Edgy archives) to get a brand new set of config files unsullied by my hands.
I still get a dog's breakfast.
A screen shot of what I'm seeing with a representative example of a .lhs file to show what I mean can be found at http:// img357.imageshack.us/img357/5798/gvimexamplezv4.png. (I've pared it down to the minimum I could find that shows the behaviour clearly.) The problems I'm seeing are the ugly white-on-red for underlines, the lack of any kind of differentiation for keywords/ operators/etc. vs. identifiers (although some punctuation is recognized, specifically curly braces), comments not being noted, etc. Basically it looks like the Haskell is simply not being recognized at all (and, if the @saBinds@ thing is what I think it is, it looks like some latex isn't being recognized fully either).
Can anybody vim-centric please take a look at this and give me a few educated guesses as to what is happening here?
Yes, I can. What you see happening is that the syntax highlighter doesn't get completely switched from TeX mode to Haskell mode on the change marked by \begin{code} (and back again on \end{code}). Therefore, lone underscores (which are usually in error in TeX outside of mathematics) are marked as errors. This should be fixed. I'll look into it. The reason I've never run into it is simple: I tend not to use underscores in my Haskell code. :) With regards, Arthur van Leeuwen. -- /\ / | arthurvl@cs.uu.nl | Work like you don't need the money /__\ / | A friend is someone with whom | Love like you have never been hurt / \/__ | you can dare to be yourself | Dance like there's nobody watching
participants (12)
-
Arthur van Leeuwen
-
Bayley, Alistair
-
Claus Reinke
-
Dave Tapley
-
David Duke
-
Dougal Stanton
-
Georg Neis
-
Ilya Tsindlekht
-
Marc Weber
-
Michael T. Richter
-
Paul Moore
-
Rodrigo Queiro