carymrobbins / intellij-haskforce

Haskell plugin for IntelliJ IDEA
http://carymrobbins.github.io/intellij-haskforce/
Apache License 2.0
485 stars 41 forks source link

Syntax Highlighting #338

Open RakNoel opened 6 years ago

RakNoel commented 6 years ago

Will detect normal parameters but not patterns. Ex.

--None of theese will get a parameter highlight quickSort [] = [] quickSort (x:xs) = quickSort [y | y <- xs, y < x] ++ [x] ++ quickSort [y | y <- xs, y >= x] otherFunc (x, y) = x otherFunc' [x] = x

-- Only theese two will lastFunc xs y = y

--Also, maybe add possibility to highlight parameter varialbes different than ordinary variables?

carymrobbins commented 6 years ago

It also depends on your color scheme and configuration. See Preferences > Editor > Colors & Fonts > Haskell for configuration options. you can in fact currently highlight parameters differently than variables.

If you want to be able to configure beyond what is currently available, you may be able to contribute an extension to the syntax highlighting lexer. However, it sounds like what you want is to be able to highlight patterns differently; if so, that may require changes to the HaskellAnnotator to inspect the parse tree. However, the parser is not in a great state currently and I'm looking to have it rewritten soon. As such, you'd probably want to wait until that happens.

RakNoel commented 6 years ago

Aaaaah aaha... i see... Well I have already changed the syntax color, thats when i noticed that if you use a pattern as a parameter it does not highlight it :P I might be able to add a contribution to the lexer yes, although i have not found out where it is and how to do it yet :/

carymrobbins commented 6 years ago

I can add some docs around contributing to the lexers and parsers, then I'll post back here.

ShrykeWindgrace commented 6 years ago

I think the syntax highlighting problem that I found should also be mentioned here.

Consider this MWE:

module Test where

data Data = Positive Integer | Negative String

myFun :: Integer -> Data
myFun x
 | x >= 0 = Positive x
 | otherwise = Negative . show $ x

With default color scheme the constructors Positive and Negative will be highlighted differently (in lines 7 and 8, respectively): image

If I understand correctly, bold black non-italicized font (for Negative) means that the lexer failed to annotate this constructor

carymrobbins commented 6 years ago

@RakNoel, @ShrykeWindgrace - I have a PR out (#344) for introducing the lexer/parser docs; feel free to take a a look and let me know what you think.

Here's the rendered markdown - parsing.md

carymrobbins commented 6 years ago

I've went ahead and merged that parsing doc into master, so you can see it there moving forward.

RakNoel commented 6 years ago

Im sorry, quite busy with a obligatory task at uni for my haskell lectures right now 😅 But I will absolutely take a look at it sometime next week^^