skylighting icon indicating copy to clipboard operation
skylighting copied to clipboard

Haskell signature highlighting

Open NickHu opened this issue 8 years ago • 5 comments

Currently, the syntax highlighting for Haskell only highlights the first word before ::.

When I'm writing, I often like to provide a long list of type calculations; for instance, consider below

image

I believe that it would be better to highlight f x and f . g also; in general, I think it should highlight up to the preceding parenthesis (i.e. id should not be highlighted).

Another strange thing is that if the function before the double colon is fmap, no highlighting is applied...

image

NickHu avatar Aug 02 '17 20:08 NickHu

I've verified that this matches kate's highlighting behavior, so this isn't a bug in the implementation. Perhaps the haskell.xml file could be improved, though, to give better behavior.

Note that we apply the following local patch to the stock haskell.xml (and this explains why fmap isn't highlighted as a function, as it is in kate):

diff --git a/xml/haskell.xml b/xml/haskell.xml
index 27ca018..8997722 100644
--- a/xml/haskell.xml
+++ b/xml/haskell.xml
@@ -476,9 +476,9 @@
 
     <itemData name="Keyword"          defStyleNum="dsKeyword"  spellChecking="false" />
     <itemData name="Type Prelude"     defStyleNum="dsDataType" spellChecking="false" />
-    <itemData name="Function Prelude" defStyleNum="dsFunction" spellChecking="false" />
-    <itemData name="Data Prelude"     defStyleNum="dsKeyword"  spellChecking="false" />
-    <itemData name="Class Prelude"    defStyleNum="dsKeyword"  spellChecking="false" />
+    <itemData name="Function Prelude" defStyleNum="dsNormal"   spellChecking="false" />
+    <itemData name="Data Prelude"     defStyleNum="dsDataType" spellChecking="false" />
+    <itemData name="Class Prelude"    defStyleNum="dsDataType" spellChecking="false" />
 
     <itemData name="Signature"        defStyleNum="dsOthers"  spellChecking="false" />
     <itemData name="Function"         defStyleNum="dsNormal"   spellChecking="false" />

jgm avatar Aug 02 '17 21:08 jgm

Yes, I had assumed this was a detail of the implementation rather than a bug. I started this issue to start a dialogue so that a consensus could be reached on whether or not this change is actually something that should be actioned. What is the rationale behind that patch?

I would submit a pull request myself, but I don't really know how the highlighting XML style works.

NickHu avatar Aug 03 '17 08:08 NickHu

The patch dates to https://github.com/jgm/highlighting-kate/pull/32 I'm happy to reconsider it; perhaps you should comment there to see if @mekeor can elaborate on the motivation. I think I agreed at the time that the effect was more pleasing, but it does seem a bit odd to distinguish Prelude functions from others.

There are references on the xml format at the end of the skylighting README.md, if you want to play with revisions. Note that you can manually load an xml definition with the skylighting executable; so you can iterate and test without recompiling the library.

+++ Nick Hu [Aug 03 17 08:27 ]:

Yes, I had assumed this was a detail of the implementation rather than a bug. I started this issue to start a dialogue so that a consensus could be reached on whether or not this change is actually something that should be actioned. What is the rationale behind that patch?

I would submit a pull request myself, but I don't really know how the highlighting XML style works.

— You are receiving this because you commented. Reply to this email directly, [1]view it on GitHub, or [2]mute the thread.

References

  1. https://github.com/jgm/skylighting/issues/12#issuecomment-319903513
  2. https://github.com/notifications/unsubscribe-auth/AAAL5Gyv1TaRNbIu_wyCC7z7DgEvlN8wks5sUYSCgaJpZM4OrnYg

jgm avatar Aug 03 '17 16:08 jgm

Sorry, I don't remember my motivation for that patch. It has been a long time. So I don't know why I changed the XML like that. I can't help you here.

(Anyway, it's funny that we meet here again, @NickHu, after meeting at the xmonad-contrib repository. 😃 )

ghost avatar Aug 07 '17 10:08 ghost

You can see the effect of that patch between https://imgur.com/3FK5bOo and https://imgur.com/w3fAWZP

ghost avatar Aug 07 '17 10:08 ghost