From 3232ba8a4cf0209ed5564a4da168e0c0e668915b Mon Sep 17 00:00:00 2001 From: lePerdu Date: Sun, 10 Nov 2019 18:11:36 -0500 Subject: [PATCH 1/7] Use elm-format for formatcmd in Elm --- rc/filetype/elm.kak | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 2ba8d68a..0f50541c 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -25,6 +25,11 @@ hook -group elm-highlight global WinSetOption filetype=elm %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } } +hook global WinSetOption filetype=elm %{ + set-option window formatcmd 'elm-format --stdin' +} + + provide-module elm %[ # Highlighters From 166049f128d5cc4daa05a132138cc3dd0b0a94e3 Mon Sep 17 00:00:00 2001 From: lePerdu Date: Sun, 10 Nov 2019 18:12:17 -0500 Subject: [PATCH 2/7] Highlight multiline strings in Elm --- rc/filetype/elm.kak | 1 + 1 file changed, 1 insertion(+) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 0f50541c..9f44c227 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -37,6 +37,7 @@ provide-module elm %[ add-highlighter shared/elm regions add-highlighter shared/elm/code default-region group +add-highlighter shared/elm/multiline_string region '"""' '"""' fill string add-highlighter shared/elm/string region '"' (? Date: Sun, 10 Nov 2019 18:12:45 -0500 Subject: [PATCH 3/7] Properly highlight Elm operators - Highlight `=` and `|` as keywords (like `->` and `:`) - Highlight custom operators (I guess they aren't really custom as of Elm 0.19 but there are still a bunch "built in"). --- rc/filetype/elm.kak | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 9f44c227..330f3b75 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -46,9 +46,10 @@ add-highlighter shared/elm/code/ regex \b([A-Z]+[^\s]*)\b add-highlighter shared/elm/code/ regex \b([a-z]+[^\s]*)\b 0:variable add-highlighter shared/elm/code/ regex \b(^[a-z]+[^\s]*)\b 0:function add-highlighter shared/elm/code/ regex "-?\b[0-9]*\.?[0-9]+" 0:value -add-highlighter shared/elm/code/ regex \B(\+|\+\+|\*|/|//|-|=|==|&&|\|\||<\||\|>)\B 0:operator +add-highlighter shared/elm/code/ regex \B[+-<>!@#$%^&*=:/\\|]+\B 0:operator add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|where)\b 0:meta -add-highlighter shared/elm/code/ regex (\b(type|alias|if|then|else|case|of|let|in|infix|_)\b)|(\B(->|:)\B) 0:keyword +add-highlighter shared/elm/code/ regex \b(type|alias|if|then|else|case|of|let|in|infix|_)\b) 0:keyword +add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![+-<>!@#$%^&*=:/\\|]) 0:keyword # Commands # ‾‾‾‾‾‾‾‾ From 44bc51a90aa52d58b16b71a9ec4d3d5bd3717b64 Mon Sep 17 00:00:00 2001 From: lePerdu Date: Sun, 10 Nov 2019 18:27:19 -0500 Subject: [PATCH 4/7] Put `-` first in character class patterns If `-` is not first or last in a character classes, it matches a range based on the character code. This applies to special characters as well as to alphanumeric characters. --- rc/filetype/elm.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 330f3b75..b2c76a22 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -46,10 +46,10 @@ add-highlighter shared/elm/code/ regex \b([A-Z]+[^\s]*)\b add-highlighter shared/elm/code/ regex \b([a-z]+[^\s]*)\b 0:variable add-highlighter shared/elm/code/ regex \b(^[a-z]+[^\s]*)\b 0:function add-highlighter shared/elm/code/ regex "-?\b[0-9]*\.?[0-9]+" 0:value -add-highlighter shared/elm/code/ regex \B[+-<>!@#$%^&*=:/\\|]+\B 0:operator +add-highlighter shared/elm/code/ regex \B[-+<>!@#$%^&*=:/\\|]+\B 0:operator add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|where)\b 0:meta add-highlighter shared/elm/code/ regex \b(type|alias|if|then|else|case|of|let|in|infix|_)\b) 0:keyword -add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![+-<>!@#$%^&*=:/\\|]) 0:keyword +add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![-+<>!@#$%^&*=:/\\|]) 0:keyword # Commands # ‾‾‾‾‾‾‾‾ From a0d6d8a03f11b92d3b0ab8a5df177ef524f66fdb Mon Sep 17 00:00:00 2001 From: lePerdu Date: Sun, 10 Nov 2019 19:24:12 -0500 Subject: [PATCH 5/7] Remove `where` keyword and add `port` keyword --- rc/filetype/elm.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index b2c76a22..78755967 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -47,7 +47,7 @@ add-highlighter shared/elm/code/ regex \b([a-z]+[^\s]*)\b add-highlighter shared/elm/code/ regex \b(^[a-z]+[^\s]*)\b 0:function add-highlighter shared/elm/code/ regex "-?\b[0-9]*\.?[0-9]+" 0:value add-highlighter shared/elm/code/ regex \B[-+<>!@#$%^&*=:/\\|]+\B 0:operator -add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|where)\b 0:meta +add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|port)\b 0:meta add-highlighter shared/elm/code/ regex \b(type|alias|if|then|else|case|of|let|in|infix|_)\b) 0:keyword add-highlighter shared/elm/code/ regex (?!@#$%^&*=:/\\|])(->|:|=|\|)(?![-+<>!@#$%^&*=:/\\|]) 0:keyword From a805844e20c9ea040ca0cb3be42df5c4eb79b51f Mon Sep 17 00:00:00 2001 From: lePerdu Date: Sun, 10 Nov 2019 19:30:22 -0500 Subject: [PATCH 6/7] Fix type, variable, and function patterns The old ones are functionally correct (I think), but are un-necessarily complex and not don't semantically fit what they are trying to match. --- rc/filetype/elm.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 78755967..014c4592 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -42,9 +42,9 @@ add-highlighter shared/elm/string region '"' (?!@#$%^&*=:/\\|]+\B 0:operator add-highlighter shared/elm/code/ regex \b(import|exposing|as|module|port)\b 0:meta From c5fad3cab647a5a076f6d0aedb5d141ffce0d53b Mon Sep 17 00:00:00 2001 From: lePerdu Date: Mon, 11 Nov 2019 08:14:18 -0500 Subject: [PATCH 7/7] Don't set formatcmd in the syntax file --- rc/filetype/elm.kak | 4 ---- 1 file changed, 4 deletions(-) diff --git a/rc/filetype/elm.kak b/rc/filetype/elm.kak index 014c4592..07d2d8d3 100644 --- a/rc/filetype/elm.kak +++ b/rc/filetype/elm.kak @@ -25,10 +25,6 @@ hook -group elm-highlight global WinSetOption filetype=elm %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/elm } } -hook global WinSetOption filetype=elm %{ - set-option window formatcmd 'elm-format --stdin' -} - provide-module elm %[