Skip to content

Commit 7a3ab95

Browse files
committed
double colon inlined fixes
1 parent ccaef63 commit 7a3ab95

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

src/purescript.coffee

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ purescriptGrammar =
8787
,
8888
include: '#type_synonym_declaration'
8989
,
90-
# data and newtype
9190
include: '#data_type_declaration'
9291
,
9392
include: '#typeclass_declaration'
@@ -115,6 +114,8 @@ purescriptGrammar =
115114
include: '#data_ctor'
116115
,
117116
include: '#infix_op'
117+
,
118+
include: '#double_colon_inlined_signature'
118119
,
119120
include: '#constants_numeric_decimal'
120121
,
@@ -136,8 +137,6 @@ purescriptGrammar =
136137
include: '#double_colon_orphan'
137138
,
138139
include: '#comments'
139-
,
140-
include: '#double_colon_inlined_signature'
141140
,
142141
name: 'keyword.other.arrow'
143142
match: /\<-|-\>/
@@ -550,8 +549,44 @@ purescriptGrammar =
550549
# ]
551550

552551
double_colon_inlined_signature:
552+
patterns: [
553+
patterns: [
554+
match: '(SomeType)\s*({doubleColon})(.*)'
555+
captures:
556+
1: name: 'meta.type-signature'
557+
2: name: 'keyword.other.double-colon'
558+
3: {name: 'meta.type-signature', patterns: [include: '#type_signature']}
559+
560+
]
561+
,
562+
patterns: [
563+
match: '({doubleColon})(.*)(<-)'
564+
captures:
565+
1: name: 'keyword.other.double-colon'
566+
2: {name: 'meta.type-signature', patterns: [ include: '#type_signature']}
567+
3: name: 'keyword.other.double-colon'
568+
569+
]
570+
,
571+
patterns: [
572+
match: '({doubleColon})(.*)'
573+
captures:
574+
1: name: 'keyword.other.double-colon'
575+
2: {
576+
name: 'meta.type-signature'
577+
patterns: [
578+
include: "#record_types"
579+
include: '#type_signature'
580+
]
581+
}
582+
583+
]
584+
]
585+
586+
_double_colon_inlined_signature:
553587
patterns: [
554588
# Note recursive regex matching nested parens
589+
# match: '\\((?<paren>(?:[^()]|\\(\\g<paren>\\))*)(::|∷)(?<paren2>(?:[^()]|\\(\\g<paren2>\\))*)\\)'
555590
match: [
556591
# '\\(',
557592
# '(?<paren>(?:[^()]|\\(\\g<paren>\\))*)',
@@ -836,8 +871,10 @@ purescriptGrammar =
836871
]
837872
type_signature:
838873
patterns: [
839-
# include: '#row_types'
840-
# ,
874+
include: "#record_types"
875+
,
876+
include: '#row_types'
877+
,
841878
name: 'meta.class-constraints'
842879
match: concat /\(/,
843880
list('classConstraints',/{classConstraint}/,/,/),

test/Main.purs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
-- start
2+
3+
24
{- Test file to visually assess syntax highlighting. -}
35
module Main.App where
46
module Main.App
@@ -39,6 +41,8 @@ foreign import data R :: { prop :: String }
3941
-- line comments with no space between first char
4042
--| some
4143

44+
45+
4246
-- comments with operators after
4347
--# some
4448
--! some
@@ -362,7 +366,7 @@ infixFun = 1 `add` 2
362366

363367

364368
-- function declaration, do, where
365-
toStr :: forall a. Functor a => a -> Effect Unit --comment
369+
toStr :: forall a. Functor a => { a :: a } -> Effect Unit --comment
366370
toStr x = do
367371
log $ show num
368372
log $ show $ 1 `add` 2
@@ -373,6 +377,16 @@ toStr x = do
373377
str = "Str"
374378

375379

380+
-- double_colon_inlined_signature
381+
gotConfig :: AVar { a :: Unit } <- AVar.empty
382+
383+
384+
SomeType :: ( a :: Int )
385+
386+
387+
AVar :: Type Type
388+
389+
376390
addIf true = singleton
377391
addIf false = const []
378392

@@ -437,6 +451,7 @@ multiString = """
437451
438452
"""
439453

454+
440455
multiStringOneLine = """ "WOW" text """
441456

442457

0 commit comments

Comments
 (0)