From def031aead986271c29b215b1f5f5e964c5237e6 Mon Sep 17 00:00:00 2001 From: sheaf Date: Thu, 14 Jun 2018 05:50:52 +0200 Subject: [PATCH 1/2] Detect qualified types and functions I don't know how robust these changes are, but they're producing the result I want in my current projects. With this change, setting "meta.import" tokens to have a certain color makes the qualifiers match the import statements, which seems logical to me. It should support qualified names in infix expressions, e.g. `Module.foo`, `Module.Submodule.bar`. Sorry if I forgot some cases. --- syntaxes/haskell.tmLanguage | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/syntaxes/haskell.tmLanguage b/syntaxes/haskell.tmLanguage index 68e3249..a33a8ed 100644 --- a/syntaxes/haskell.tmLanguage +++ b/syntaxes/haskell.tmLanguage @@ -29,7 +29,15 @@ comment In case this regex seems unusual for an infix operator, note that Haskell allows any ordinary function application (elem 4 [1..10]) to be rewritten as an infix expression (4 `elem` [1..10]). match - (`)([\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*\.)*[\p{Ll}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(`) + (`)(([\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}'\.]*)\.)?[\p{Ll}_][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(`) + captures + + 3 + + name + meta.import.qualifier.haskell + + name keyword.operator.function.infix.haskell @@ -473,6 +481,10 @@ include #data_constructor + + include + #qualifier + include #comments @@ -739,11 +751,18 @@ data_constructor + + match + \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(?!\.)\b + name + constant.other.haskell + + qualifier match - \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*\b + \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(?=\.)\b name - constant.other.haskell + meta.import.qualifier.haskell type_signature @@ -826,10 +845,16 @@ match - \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']* + \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(?!\.)\b name storage.type.haskell + + match + \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(?=\.) + name + meta.import.qualifier.haskell + include #comments From 00be792f53bc2c1865752ef0b51444ab5e7a2b79 Mon Sep 17 00:00:00 2001 From: Justus Adam Date: Thu, 14 Jun 2018 17:04:33 +0200 Subject: [PATCH 2/2] Changed name for qualifier scope Based on https://www.sublimetext.com/docs/3/scope_naming.html --- syntaxes/haskell.tmLanguage | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntaxes/haskell.tmLanguage b/syntaxes/haskell.tmLanguage index a33a8ed..26cb8eb 100644 --- a/syntaxes/haskell.tmLanguage +++ b/syntaxes/haskell.tmLanguage @@ -35,7 +35,7 @@ 3 name - meta.import.qualifier.haskell + entity.name.namespace name @@ -730,7 +730,7 @@ match (?<conid>[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(\.\g<conid>)?) name - support.other.module.haskell + entity.name.namespace pragma @@ -853,7 +853,7 @@ match \b[\p{Lu}\p{Lt}][\p{Ll}_\p{Lu}\p{Lt}\p{Nd}']*(?=\.) name - meta.import.qualifier.haskell + entity.name.namespace include