Repository: alecthomas/chroma (go)

Issue:
Extraneous colors in Gleam type highlighting
### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

When highlighting Gleam code, the type names between parenthesis and in function returns have their first letter with a different font color an background. I would expect those names to either have the same color as the type declarations without parentheses, or to not be colored.

### To Reproduce

Example in [chroma playground](https://swapoff.org/chroma/playground/#eyJsYW5ndWFnZSI6IkdsZWFtIiwic3R5bGUiOiJtb25va2FpbGlnaHQiLCJ0ZXh0IjoicHViIHR5cGUgVGFibGUgPSBTdWJqZWN0KE1lc3NhZ2UpXG5cbnB1YiB0eXBlIE1lc3NhZ2Uge1xuICBSZWdpc3RlckZlZWQoU3RyaW5nLCBQb2xsZXIpXG59XG5cbnB1YiBmbiBzdGFydCgpIC0-IFRhYmxlIHtcbiAgdG9kb1xufVxuIiwiY2xhc3NlcyI6ZmFsc2V9)

To reproduce it in the command line:

    chroma -l gleam --html <source>

Where source is:
```gleam
pub type Table = Subject(Message)

pub type Message {
  RegisterFeed(String, Poller)
}

pub fn start() -> Table {
  todo
}
```

Pull request description:
Fix Gleam lexer
I made the Gleam lexer *dumber* (that is, more acquiescent), but it fixes #1054 and still passes the tests.

Patch:
diff --git a/lexers/embedded/gleam.xml b/lexers/embedded/gleam.xml
index 6205aa1..3966322 100644
--- a/lexers/embedded/gleam.xml
+++ b/lexers/embedded/gleam.xml
@@ -33,7 +33,6 @@
       </rule>
       <rule pattern="(type)\b">
         <token type="Keyword"/>
-        <push state="typename"/>
       </rule>
       <rule pattern="(True|False)\b">
         <token type="KeywordConstant"/>
@@ -63,12 +62,11 @@
       <rule pattern="[{}()\[\],]|[#(]|\.\.|&lt;&gt;|&lt;&lt;|&gt;&gt;">
         <token type="Punctuation"/>
       </rule>
-      <rule pattern="[+\-*/%!=&lt;&gt;&amp;|.]|&lt;-">
+      <rule pattern=":|-&gt;">
         <token type="Operator"/>
       </rule>
-      <rule pattern=":|-&gt;">
+      <rule pattern="[+\-*/%!=&lt;&gt;&amp;|.]|&lt;-">
         <token type="Operator"/>
-        <push state="typename"/>
       </rule>
       <rule pattern="([a-z_][A-Za-z0-9_]*)(\()">
         <bygroups>
@@ -76,26 +74,11 @@
           <token type="Punctuation"/>
         </bygroups>
       </rule>
-      <rule pattern="([A-Z][A-Za-z0-9_]*)(\()">
-        <bygroups>
-          <token type="NameClass"/>
-          <token type="Punctuation"/>
-        </bygroups>
-      </rule>
-      <rule pattern="([a-z_]\w*[!?]?)">
-        <token type="Name"/>
-      </rule>
-    </state>
-    <state name="typename">
-      <rule pattern="\s+">
-        <token type="TextWhitespace"/>
-      </rule>
       <rule pattern="[A-Z][A-Za-z0-9_]*">
         <token type="NameClass"/>
-        <pop depth="1"/>
       </rule>
-      <rule>
-        <pop depth="1"/>
+      <rule pattern="([a-z_]\w*[!?]?)">
+        <token type="Name"/>
       </rule>
     </state>
     <state name="string">


Test patch:
diff --git a/lexers/testdata/gleam.actual b/lexers/testdata/gleam.actual
index cdcf1d3..e97dba6 100644
--- a/lexers/testdata/gleam.actual
+++ b/lexers/testdata/gleam.actual
@@ -18,3 +18,17 @@ pub fn main() {
   io.debug(reverse_list([1, 2, 3, 4, 5]))
   io.debug(reverse_list(["a", "b", "c", "d", "e"]))
 }
+
+pub fn plus_one(x: Int) -> Int {
+  x + 1
+}
+
+pub type Message {
+  RegisterFeed(String, Poller)
+}
+
+pub type Table = Subject(Message)
+
+pub fn start() -> Table {
+  todo
+}
\ No newline at end of file
diff --git a/lexers/testdata/gleam.expected b/lexers/testdata/gleam.expected
index 30776e3..9f00111 100644
--- a/lexers/testdata/gleam.expected
+++ b/lexers/testdata/gleam.expected
@@ -181,5 +181,78 @@
   {"type":"Punctuation","value":"]))"},
   {"type":"TextWhitespace","value":"\n"},
   {"type":"Punctuation","value":"}"},
-  {"type":"TextWhitespace","value":"\n"}
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Keyword","value":"pub"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Keyword","value":"fn"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameFunction","value":"plus_one"},
+  {"type":"Punctuation","value":"("},
+  {"type":"Name","value":"x"},
+  {"type":"Operator","value":":"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Int"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"-\u003e"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Int"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"{"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Name","value":"x"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"+"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"LiteralNumberInteger","value":"1"},
+  {"type":"TextWhitespace","value":"\n"},
+  {"type":"Punctuation","value":"}"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Keyword","value":"pub"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Keyword","value":"type"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Message"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"{"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"NameClass","value":"RegisterFeed"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameClass","value":"String"},
+  {"type":"Punctuation","value":","},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Poller"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":"\n"},
+  {"type":"Punctuation","value":"}"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Keyword","value":"pub"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Keyword","value":"type"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Table"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"="},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Subject"},
+  {"type":"Punctuation","value":"("},
+  {"type":"NameClass","value":"Message"},
+  {"type":"Punctuation","value":")"},
+  {"type":"TextWhitespace","value":"\n\n"},
+  {"type":"Keyword","value":"pub"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Keyword","value":"fn"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameFunction","value":"start"},
+  {"type":"Punctuation","value":"()"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Operator","value":"-\u003e"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"NameClass","value":"Table"},
+  {"type":"TextWhitespace","value":" "},
+  {"type":"Punctuation","value":"{"},
+  {"type":"TextWhitespace","value":"\n  "},
+  {"type":"Keyword","value":"todo"},
+  {"type":"TextWhitespace","value":"\n"},
+  {"type":"Punctuation","value":"}"}
 ]