Prevent pret-lam from matching subwords.
[matthijs/master-project/report.git] / pret-lam.lua
index c25daefb697c3cd08c7a15115c935a62a948cf42..a87137c0dc0b2428a1484552fe7d0357781f2fcf 100644 (file)
@@ -21,6 +21,9 @@ buffers.visualizers.lam.tokens = {
     [' '] = {repr = '\\obs '},
     ['_'] = {repr = '\\_'},
     ['->'] = {repr = '\\rightarrow'},
+    -- The default * sits very high above the baseline, \ast (u+2217) looks
+    -- better.
+    ['*'] = {repr = '\\ast'},
     ['case'] = {style = 'bold'},
     ['of'] = {style = 'bold'},
     ['let'] = {style = 'bold'},
@@ -53,8 +56,10 @@ function buffers.visualizers.lam.flush_line(str,nested)
             end
         end
         if not found then
-            result[#result+1] = utf.sub(str, 1, 1)
-            str = utf.sub(str, 2)
+            -- Take a full word, or a single character. Taking a full word is
+            -- to prevent matching "in" in "bind" , for example.
+            result[#result+1] = utf.match(str, "^%a+") or utf.sub(str, 1, 1)
+            str = utf.sub(str, utf.len(result[#result]) + 1)
         end
     end
     state = finish(state, result)