hvesalai / emacs-scala-mode

The definitive scala-mode for emacs
http://ensime.org
GNU General Public License v3.0
361 stars 68 forks source link

Fix code highlighting #79

Open 4lex1v opened 10 years ago

4lex1v commented 10 years ago

I've just started using emacs, so couldn't find myself where and how to fix it, but it's quite disturbing to write function types like:

val trans: String => String => String
case class Test(f: Any => String => String)

And if i declare type like type <+>[A, B] in addition to the previous incorrect highlighting, <+> also has incorrect color (i expected in to be similar to =>)

Where i have the the first type highlighted with one color (like all other types) and others with a different color like std names.

Also in things like type \//, the hole line is treated like a comment, although it is a valid name.

Is it possible to fix this at all with regexps or it more semantical parsing?

hvesalai commented 10 years ago

All pull request on fixing this are welcome. However, you should also check out ensime.

4lex1v commented 9 years ago

I have another issue with highlighting, i.e object name in this case:

object ModuleName { ... }

Is highlighted as a constant, but it should be a type like class or trait. In fontlock i've found this two lines:

    ;; object
    (,(concat "\\<object[ \t]+\\("
              scala-syntax:id-re
              "\\)")
     1 font-lock-constant-face)

    ;; class, trait, object
    (,(concat "\\<\\(class\\|trait\\)[ \t]+\\("
              scala-syntax:id-re
              "\\)")
     2 font-lock-type-face)

So not sure what's the right highlighting?

hvesalai commented 9 years ago

objects are highlighted in different face since they are not types (classes, types and traits are).

Consider the following code

class F {}
val F: F = new F();

Here there are two Fs. The other (class F) is a type and the other (val F) is a value the type of which is F.

Now consider object F. Here also F is a value (like with val F), the type of which is actually F.type