From ca68f73a3686de6f6c7f7bf9f74ec944480809be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Wed, 16 Mar 2022 21:53:33 -0500 Subject: [PATCH 01/14] Much better support for CSS, tested using varied examples from spec --- rc/filetype/css.kak | 155 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 135 insertions(+), 20 deletions(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 7f6f78663..568c14f59 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -15,6 +15,7 @@ hook global WinSetOption filetype=css %[ require-module css hook window ModeChange pop:insert:.* -group css-trim-indent css-trim-indent + hook window InsertChar \n -group css-insert css-insert-on-new-line hook window InsertChar \n -group css-indent css-indent-on-new-line hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' @@ -32,28 +33,94 @@ provide-module css %[ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ - add-highlighter shared/css regions -add-highlighter shared/css/selector default-region group -add-highlighter shared/css/declaration region [{] [}] regions -add-highlighter shared/css/comment region /[*] [*]/ fill comment +add-highlighter shared/css/code default-region group +add-highlighter shared/css/attr_selector region \[ \] regions +add-highlighter shared/css/double_string region '"' (? below + # includes elements that cannot be styled, which is fine. + # + # https://developer.mozilla.org/en-US/docs/Web/HTML/Element + # + # // selector might change on site updates + # var els; document.querySelectorAll('tr td:first-child a[href^="/en-US/docs/Web/HTML/Element/"]').forEach((el) => {els += el.childNodes[0].innerText + " ";}); console.log(els); + # + html_tags='html body address article aside footer header h1 h2 h3 h4 h5 h6 main nav section blockquote dd div dl dt figcaption figure hr li ol p pre ul a abbr b bdi bdo br cite code data dfn em i kbd mark q rp rt ruby s samp small span strong sub sup time u var wbr area audio img map track video embed iframe object param picture portal source canvas noscript script del ins caption col colgroup table tbody td tfoot th thead tr button datalist fieldset form input label legend meter optgroup option output progress select textarea details dialog menu summary slot template acronym applet basefont bgsound big blink center content dir font frame frameset hgroup image keygen marquee menuitem nobr noembed noframes plaintext rb rtc shadow spacer strike tt xmp' -# https://developer.mozilla.org/en-US/docs/Web/CSS/length -add-highlighter shared/css/declaration/base/ regex (#[0-9A-Fa-f]+)|((\d*\.)?\d+(ch|cm|em|ex|mm|pc|pt|px|rem|vh|vmax|vmin|vw)) 0:value + # Units + # ‾‾‾‾‾ + # generated from the URL & below + # includes #rgb, #rrggbb, #rrggbbaa as color values {3,8} + # + # https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Values_and_Units + # + # // selector might change on site updates + # var units; document.querySelectorAll('tr td:first-child').forEach((el) => {els += el.childNodes[0].innerText + " ";}); console.log(units) + # + units='% cap ch cm deg dpcm dpi dppx em ex grad Hz ic in kHz lh mm ms pc pt px Q rad rem rlh s turn vb vh vi vmax vmin vw x' -add-highlighter shared/css/declaration/base/ regex ([A-Za-z][A-Za-z0-9_-]*)\h*: 1:keyword -add-highlighter shared/css/declaration/base/ regex :(before|after) 0:attribute -add-highlighter shared/css/declaration/base/ regex !important 0:keyword + logical_ops='and not only from to' + keywords='!important auto inherit initial unset none' + media_types='all print screen speech' -# element#id element.class -# universal selector -add-highlighter shared/css/selector/ regex [A-Za-z][A-Za-z0-9_-]* 0:keyword -add-highlighter shared/css/selector/ regex [*]|[#.][A-Za-z][A-Za-z0-9_-]* 0:variable + # easing_re='linear|ease(-(in-out|in|out))?|step-(start|end)' + + # combinators='+ > ~ ||' + # attribute_op='= ~= |= ^= $= *=' + + join() { eval set -- $1; IFS="|"; echo "$*"; } + + # Selectors + # ‾‾‾‾‾‾‾‾‾ + # universal: *, ns|*, *|*, |* + # class/id: .class, #id + # type: element + # attr: [attr=val] + + # order below matters + printf %s " + # html tag selectors + add-highlighter shared/css/code/ regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#]) 1:keyword + + #functional notation + add-highlighter shared/css/code/ regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword + + # logical operators, and other keywords + add-highlighter shared/css/code/ regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:keyword 1:+i + + # media types + add-highlighter shared/css/code/ regex \b($(join "${media_types}"))\b 1:+i + + # pseudo (after functional notation as they may contain paranthesis) + add-highlighter shared/css/code/ regex (:{1,2})([a-z-]+) 2:attribute 2:+a + + # at-rules + add-highlighter shared/css/code/ regex @[a-z-]+ 0:function + + # css property + add-highlighter shared/css/code/ regex ([A-Za-z][A-Za-z0-9_-]*)\h*:\h 1:operator 1:+a + + # universal, class, id selectors + add-highlighter shared/css/code/ regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 1:type + add-highlighter shared/css/code/ regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 1:type 1:+i + + # hex values + add-highlighter shared/css/code/ regex (#[0-9A-Fa-f]{3,8})\b 0:value 0:+a + add-highlighter shared/css/code/ regex \b(\d*\.)?\d+($(join "${units}"))?\b 0:value 0:+a + " +} + +# Attribute Selectors +add-highlighter shared/css/attr_selector/base default-region group +add-highlighter shared/css/attr_selector/base/ regex ([a-zA-Z0-9-]+) 1:attribute +add-highlighter shared/css/attr_selector/base/ regex \h(i|s) 1:type +add-highlighter shared/css/attr_selector/double_string region '"' (? K ] + execute-keys + try %< + # if previous line is part of a comment, do nothing + execute-keys -draft /\* ^\h*[^/*\h] + > catch %< + # else if previous line closed a paren (possibly followed by words and a comment), + # copy indent of the opening paren line + execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + > catch %< + # else indent new lines with the same level as the previous one + execute-keys -draft K + > # filter previous line - try %[ execute-keys -draft k : css-trim-indent ] + try %< execute-keys -draft k ^\h+$ Hd > # indent after lines ending with with { try %[ execute-keys -draft k \{$ j ] # deindent closing brace when after cursor @@ -76,6 +153,44 @@ define-command -hidden css-indent-on-new-line %[ ] ] +define-command -hidden css-insert-on-new-line %[ + evaluate-commands -draft -itersel %< + execute-keys + try %[ + # if the previous line isn't within a comment scope, break + execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + + # find comment opening, validate it was not closed, and check its using star prefixes + execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z + + try %[ + # if the previous line is opening the comment, insert star preceeded by space + execute-keys -draft k^\h*/\* + execute-keys -draft i* + ] catch %[ + try %[ + # if the next line is a comment line insert a star + execute-keys -draft j^\h+\* + execute-keys -draft i* + ] catch %[ + try %[ + # if the previous line is an empty comment line, close the comment scope + execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + ] catch %[ + # if the previous line is a non-empty comment line, add a star + execute-keys -draft i* + ] + ] + ] + + # trim trailing whitespace on the previous line + try %[ execute-keys -draft s\h+$ d ] + # align the new star with the previous one + execute-keys K1s^[^*]*(\*)& + ] + > +] + define-command -hidden css-indent-on-closing-curly-brace %[ evaluate-commands -draft -itersel %[ # align to opening curly brace when alone on a line From f2c11c01231cdbcd428b60d67af950a039a7fe03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Wed, 16 Mar 2022 21:54:05 -0500 Subject: [PATCH 02/14] Improved support for commenting, mainly pulled from c-family.kak --- rc/filetype/javascript.kak | 113 +++++++++++++++++++++++++++++++++---- 1 file changed, 102 insertions(+), 11 deletions(-) diff --git a/rc/filetype/javascript.kak b/rc/filetype/javascript.kak index 089061ab4..5d9059b17 100644 --- a/rc/filetype/javascript.kak +++ b/rc/filetype/javascript.kak @@ -43,7 +43,7 @@ provide-module javascript %§ define-command -hidden javascript-trim-indent %{ # remove trailing white spaces - try %{ execute-keys -draft -itersel s \h+$ d } + try %{ execute-keys -draft 1s^(\h+)$ d } } define-command -hidden javascript-indent-on-char %< @@ -55,21 +55,112 @@ define-command -hidden javascript-indent-on-char %< define-command -hidden javascript-insert-on-new-line %< evaluate-commands -draft -itersel %< - # copy // comments prefix and following white spaces - try %{ execute-keys -draft k s ^\h*\K/{2,}\h* y gh j P } + execute-keys + # NOT working, copies single line comment "//" + # try %[ + # evaluate-commands -draft -save-regs '/"' %[ + # # copy the commenting prefix + # execute-keys -save-regs '' k 1s^\h*(//+\h*) y + # try %[ + # # if the previous comment isn't empty, create a new one + # execute-keys ^\h*//+\h*$ js^\h*P + # ] catch %[ + # # if there is no text in the previous comment, remove it completely + # execute-keys d + # ] + # ] + # ] + try %[ + # if the previous line isn't within a comment scope, break + execute-keys -draft k ^(\h*/\*|\h+\*(?!/)) + + # find comment opening, validate it was not closed, and check its using star prefixes + execute-keys -draft /\* \*/ \A\h*/\*([^\n]*\n\h*\*)*[^\n]*\n\h*.\z + + try %[ + # if the previous line is opening the comment, insert star preceeded by space + execute-keys -draft k^\h*/\* + execute-keys -draft i* + ] catch %[ + try %[ + # if the next line is a comment line insert a star + execute-keys -draft j^\h+\* + execute-keys -draft i* + ] catch %[ + try %[ + # if the previous line is an empty comment line, close the comment scope + execute-keys -draft k^\h+\*\h+$ 1s\*(\h*)c/ + ] catch %[ + # if the previous line is a non-empty comment line, add a star + execute-keys -draft i* + ] + ] + ] + + # trim trailing whitespace on the previous line + try %[ execute-keys -draft s\h+$ d ] + # align the new star with the previous one + execute-keys K1s^[^*]*(\*)& + ] + # # copy // comments prefix and following white spaces + # try %{ execute-keys -draft k s ^\h*\K/{2,}\h* y gh j P } > > define-command -hidden javascript-indent-on-new-line %< evaluate-commands -draft -itersel %< - # preserve previous line indent - try %{ execute-keys -draft K } - # filter previous line - try %{ execute-keys -draft k : javascript-trim-indent } - # indent after lines beginning / ending with opener token - try %_ execute-keys -draft k s [[({] [\])}] j _ - # deindent closing token(s) when after cursor - try %_ execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 _ + execute-keys + try %< + # if previous line is part of a comment, do nothing + execute-keys -draft /\* ^\h*[^/*\h] + > catch %< + # else if previous line closed a paren (possibly followed by words and a comment), + # copy indent of the opening paren line + execute-keys -draft k 1s(\))(\h+\w+)*\h*(\;\h*)?(?://[^\n]+)?\n\z mJ 1 + > catch %< + # else indent new lines with the same level as the previous one + execute-keys -draft K + > + # remove previous empty lines resulting from the automatic indent + try %< execute-keys -draft k ^\h+$ Hd > + # indent after an opening brace or parenthesis at end of line + try %< execute-keys -draft k [{(]\h*$ j > + # indent after a label (works for case statements) + try %< execute-keys -draft k s[a-zA-Z0-9_-]+:\h*$ j > + # indent after a statement not followed by an opening brace + try %< execute-keys -draft k s\)\h*(?://[^\n]+)?\n\z \ + mB \A\b(if|for|while)\b j > + try %< execute-keys -draft k s \belse\b\h*(?://[^\n]+)?\n\z \ + j > + # deindent after a single line statement end + try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ + K s\)(\h+\w+)*\h*(//[^\n]+)?\n([^\n]*\n){2}\z \ + MB \A\b(if|for|while)\b 1 > + try %< execute-keys -draft K \;\h*(//[^\n]+)?$ \ + K s \belse\b\h*(?://[^\n]+)?\n([^\n]*\n){2}\z \ + 1 > + # deindent closing brace(s) when after cursor + try %< execute-keys -draft ^\h*[})] gh / [})] m 1 > + # align to the opening parenthesis or opening brace (whichever is first) + # on a previous line if its followed by text on the same line + try %< evaluate-commands -draft %< + # Go to opening parenthesis and opening brace, then select the most nested one + try %< execute-keys [c [({],[)}] > + # Validate selection and get first and last char + execute-keys \A[{(](\h*\S+)+\n "(([^"]*"){2})* '(([^']*'){2})* L + # Remove possibly incorrect indent from new line which was copied from previous line + try %< execute-keys -draft s\h+ d > + # Now indent and align that new line with the opening parenthesis/brace + execute-keys 1 & + > > + # # preserve previous line indent + # try %{ execute-keys -draft K } + # # filter previous line + # try %{ execute-keys -draft k : javascript-trim-indent } + # # indent after lines beginning / ending with opener token + # try %_ execute-keys -draft k s [[({] [\])}] j _ + # # deindent closing token(s) when after cursor + # try %_ execute-keys -draft ^\h*[})\]] gh / [})\]] m 1 _ > > From eaea1d20f31f964c893a27a1ab6eaa5d2be3b8a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Wed, 16 Mar 2022 21:55:29 -0500 Subject: [PATCH 03/14] Improved indentation, keywords, and variables for scss --- rc/filetype/scss.kak | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rc/filetype/scss.kak b/rc/filetype/scss.kak index 95167e75c..744691b01 100644 --- a/rc/filetype/scss.kak +++ b/rc/filetype/scss.kak @@ -15,6 +15,7 @@ hook global WinSetOption filetype=scss %[ require-module scss hook window ModeChange pop:insert:.* -group scss-trim-indent scss-trim-indent + hook window InsertChar \n -group scss-indent scss-insert-on-new-line hook window InsertChar \n -group scss-indent scss-indent-on-new-line hook window InsertChar \} -group scss-indent scss-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' @@ -37,15 +38,17 @@ require-module css add-highlighter shared/scss regions add-highlighter shared/scss/core default-region group -add-highlighter shared/scss/comment region // $ fill comment +add-highlighter shared/scss/comment region ^\h*// $ fill comment add-highlighter shared/scss/core/ ref css -add-highlighter shared/scss/core/ regex @[A-Za-z][A-Za-z0-9_-]* 0:meta +add-highlighter shared/scss/core/ regex & 0:keyword +add-highlighter shared/scss/core/ regex \$[A-Za-z][A-Za-z0-9_-]* 0:variable # Commands # ‾‾‾‾‾‾‾‾ define-command -hidden scss-trim-indent css-trim-indent +define-command -hidden scss-insert-on-new-line css-insert-on-new-line define-command -hidden scss-indent-on-new-line css-indent-on-new-line define-command -hidden scss-indent-on-closing-curly-brace css-indent-on-closing-curly-brace From 9ac6669e5081e095ee7532210bf3379f553de4ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Wed, 16 Mar 2022 21:55:44 -0500 Subject: [PATCH 04/14] basic support for twig --- rc/filetype/twig.kak | 95 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 rc/filetype/twig.kak diff --git a/rc/filetype/twig.kak b/rc/filetype/twig.kak new file mode 100644 index 000000000..21f8cebcf --- /dev/null +++ b/rc/filetype/twig.kak @@ -0,0 +1,95 @@ +# https://twig.symfony.com/doc/3.x/templates.html +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +# Detection +# ‾‾‾‾‾‾‾‾‾ + +hook global BufCreate .*[.](twig) %{ + set-option buffer filetype twig +} + +# Initialization +# ‾‾‾‾‾‾‾‾‾‾‾‾‾‾ + +hook global WinSetOption filetype=twig %[ + require-module twig + + hook window ModeChange pop:insert:.* -group twig-trim-indent twig-trim-indent + hook window InsertChar \n -group twig-insert twig-insert-on-new-line + hook window InsertChar \n -group twig-indent twig-indent-on-new-line + hook window InsertChar '>' -group twig-indent twig-indent-on-grater-than + hook window InsertChar '#' -group twig-auto-close twig-auto-close-delim + hook window InsertChar '%' -group twig-auto-close twig-auto-close-delim + set-option buffer extra_word_chars '_' '-' + + hook -once -always window WinSetOption filetype=.* %{ remove-hooks window twig-.+ } +] + +hook -group twig-highlight global WinSetOption filetype=twig %{ + add-highlighter window/twig ref twig + hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/twig } +} + + +provide-module twig %[ + +require-module html + +# Highlighters +# ‾‾‾‾‾‾‾‾‾‾‾‾ + +add-highlighter shared/twig regions +add-highlighter shared/twig/core default-region group +add-highlighter shared/twig/comment region \{# [#]\} fill comment +add-highlighter shared/twig/delim region \{([%]-?|\{) (-?[%]|\})\} regions + +add-highlighter shared/twig/core/ ref html + +add-highlighter shared/twig/delim/base default-region group +add-highlighter shared/twig/delim/double_string region '"' (?hH\h*\{lyp + execute-keys hihi + ] + ] +] + +define-command -hidden twig-insert-on-new-line %[ + evaluate-commands -draft -itersel %/ + execute-keys + try %[ + execute-keys -draft k^\h*\{\[%#\{\]\h+$ + execute-keys -draft jghd + ] + / +] + +] From a05151dd232a22e2f8b862369f90ecc8664fb0fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Wed, 16 Mar 2022 22:09:54 -0500 Subject: [PATCH 05/14] =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez=20Copyright?= =?UTF-8?q?=20Waiver?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.`` From e226c7ea2b382c8340825c3ccc1035825f235bfa Mon Sep 17 00:00:00 2001 From: in0ni Date: Thu, 17 Mar 2022 08:57:40 -0500 Subject: [PATCH 06/14] Update rc/filetype/twig.kak fix typo Co-authored-by: Screwtapello --- rc/filetype/twig.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/twig.kak b/rc/filetype/twig.kak index 21f8cebcf..99bba5839 100644 --- a/rc/filetype/twig.kak +++ b/rc/filetype/twig.kak @@ -17,7 +17,7 @@ hook global WinSetOption filetype=twig %[ hook window ModeChange pop:insert:.* -group twig-trim-indent twig-trim-indent hook window InsertChar \n -group twig-insert twig-insert-on-new-line hook window InsertChar \n -group twig-indent twig-indent-on-new-line - hook window InsertChar '>' -group twig-indent twig-indent-on-grater-than + hook window InsertChar '>' -group twig-indent twig-indent-on-greater-than hook window InsertChar '#' -group twig-auto-close twig-auto-close-delim hook window InsertChar '%' -group twig-auto-close twig-auto-close-delim set-option buffer extra_word_chars '_' '-' From 719f78349acd2deb9e15b21563162087d3f7516f Mon Sep 17 00:00:00 2001 From: in0ni Date: Thu, 17 Mar 2022 08:57:58 -0500 Subject: [PATCH 07/14] Update rc/filetype/twig.kak fix typo Co-authored-by: Screwtapello --- rc/filetype/twig.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/twig.kak b/rc/filetype/twig.kak index 99bba5839..a162d252f 100644 --- a/rc/filetype/twig.kak +++ b/rc/filetype/twig.kak @@ -71,7 +71,7 @@ add-highlighter shared/twig/delim/base/ regex (\{\{|\}\}) 0:operator define-command -hidden twig-trim-indent html-trim-indent define-command -hidden twig-indent-on-new-line html-indent-on-new-line -define-command -hidden twig-indent-on-grater-than html-indent-on-greater-than +define-command -hidden twig-indent-on-greater-than html-indent-on-greater-than define-command -hidden twig-auto-close-delim %[ evaluate-commands -itersel %[ From 1b9929bb735ba8c82a76d80966356645fb867ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Sun, 3 Apr 2022 11:55:31 -0400 Subject: [PATCH 08/14] remove comments for code used to generate lists of elements/units, explicitely name highlighters --- rc/filetype/css.kak | 40 ++++++++++++---------------------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 568c14f59..a97987461 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -46,10 +46,6 @@ evaluate-commands %sh{ # includes elements that cannot be styled, which is fine. # # https://developer.mozilla.org/en-US/docs/Web/HTML/Element - # - # // selector might change on site updates - # var els; document.querySelectorAll('tr td:first-child a[href^="/en-US/docs/Web/HTML/Element/"]').forEach((el) => {els += el.childNodes[0].innerText + " ";}); console.log(els); - # html_tags='html body address article aside footer header h1 h2 h3 h4 h5 h6 main nav section blockquote dd div dl dt figcaption figure hr li ol p pre ul a abbr b bdi bdo br cite code data dfn em i kbd mark q rp rt ruby s samp small span strong sub sup time u var wbr area audio img map track video embed iframe object param picture portal source canvas noscript script del ins caption col colgroup table tbody td tfoot th thead tr button datalist fieldset form input label legend meter optgroup option output progress select textarea details dialog menu summary slot template acronym applet basefont bgsound big blink center content dir font frame frameset hgroup image keygen marquee menuitem nobr noembed noframes plaintext rb rtc shadow spacer strike tt xmp' # Units @@ -58,10 +54,6 @@ evaluate-commands %sh{ # includes #rgb, #rrggbb, #rrggbbaa as color values {3,8} # # https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Values_and_Units - # - # // selector might change on site updates - # var units; document.querySelectorAll('tr td:first-child').forEach((el) => {els += el.childNodes[0].innerText + " ";}); console.log(units) - # units='% cap ch cm deg dpcm dpi dppx em ex grad Hz ic in kHz lh mm ms pc pt px Q rad rem rlh s turn vb vh vi vmax vmin vw x' logical_ops='and not only from to' @@ -84,34 +76,26 @@ evaluate-commands %sh{ # order below matters printf %s " - # html tag selectors - add-highlighter shared/css/code/ regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#]) 1:keyword + add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#]) 1:keyword - #functional notation - add-highlighter shared/css/code/ regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword + add-highlighter shared/css/code/functional_notation regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword - # logical operators, and other keywords - add-highlighter shared/css/code/ regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:keyword 1:+i + add-highlighter shared/css/code/logical_operators regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:keyword 1:+i - # media types - add-highlighter shared/css/code/ regex \b($(join "${media_types}"))\b 1:+i + add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i - # pseudo (after functional notation as they may contain paranthesis) - add-highlighter shared/css/code/ regex (:{1,2})([a-z-]+) 2:attribute 2:+a + # (after functional notation as they may contain paranthesis) + add-highlighter shared/css/code/psudo regex (:{1,2})([a-z-]+) 2:attribute 2:+a - # at-rules - add-highlighter shared/css/code/ regex @[a-z-]+ 0:function + add-highlighter shared/css/code/at_rules regex @[a-z-]+ 0:function - # css property - add-highlighter shared/css/code/ regex ([A-Za-z][A-Za-z0-9_-]*)\h*:\h 1:operator 1:+a + add-highlighter shared/css/code/css_property regex ([A-Za-z][A-Za-z0-9_-]*)\h*:\h 1:operator 1:+a - # universal, class, id selectors - add-highlighter shared/css/code/ regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 1:type - add-highlighter shared/css/code/ regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 1:type 1:+i + add-highlighter shared/css/code/selectors regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 1:type + add-highlighter shared/css/code/selectors_id regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 1:type 1:+i - # hex values - add-highlighter shared/css/code/ regex (#[0-9A-Fa-f]{3,8})\b 0:value 0:+a - add-highlighter shared/css/code/ regex \b(\d*\.)?\d+($(join "${units}"))?\b 0:value 0:+a + add-highlighter shared/css/code/hex_values regex (#[0-9A-Fa-f]{3,8})\b 0:value 0:+a + add-highlighter shared/css/code/units regex \b(\d*\.)?\d+($(join "${units}"))?\b 0:value 0:+a " } From 5fdff9a8ff152b62f93fcacec63e5f5c52b82b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Sun, 3 Apr 2022 11:55:45 -0400 Subject: [PATCH 09/14] explicitely name highlighters, remove comments that described them --- rc/filetype/twig.kak | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/rc/filetype/twig.kak b/rc/filetype/twig.kak index 21f8cebcf..6df90fbe2 100644 --- a/rc/filetype/twig.kak +++ b/rc/filetype/twig.kak @@ -50,21 +50,15 @@ add-highlighter shared/twig/delim/double_string region '"' (? Date: Tue, 12 Apr 2022 08:22:56 -0400 Subject: [PATCH 10/14] allow html tags to be followed by comma, create cssLogicalOperator face --- rc/filetype/css.kak | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index a97987461..8a1d4a10d 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -19,6 +19,7 @@ hook global WinSetOption filetype=css %[ hook window InsertChar \n -group css-indent css-indent-on-new-line hook window InsertChar \} -group css-indent css-indent-on-closing-curly-brace set-option buffer extra_word_chars '_' '-' + set-face global cssLogicalOperator +i@keyword hook -once -always window WinSetOption filetype=.* %{ remove-hooks window css-.+ } ] @@ -76,11 +77,11 @@ evaluate-commands %sh{ # order below matters printf %s " - add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#]) 1:keyword + add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#,]) 0:keyword add-highlighter shared/css/code/functional_notation regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword - add-highlighter shared/css/code/logical_operators regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:keyword 1:+i + add-highlighter shared/css/code/logical_operators regex (\b($(join "${logical_ops}"))\b|$(join "${keywords}")) 1:cssLogicalOperator add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i From 8888b8d5618a65fb82bf8a6a75508bd0f90641be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 12 Apr 2022 08:27:47 -0400 Subject: [PATCH 11/14] only highlight html tags (1:keyword), fix typo in pseudo --- rc/filetype/css.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 8a1d4a10d..1615c2daf 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -77,7 +77,7 @@ evaluate-commands %sh{ # order below matters printf %s " - add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#,]) 0:keyword + add-highlighter shared/css/code/tag_selectors regex \b($(join "${html_tags}"))((:[a-z:])|[\h.#,]) 1:keyword add-highlighter shared/css/code/functional_notation regex ([a-zA-Z0-9-_]+[a-zA-Z0-9])\( 1:keyword @@ -86,7 +86,7 @@ evaluate-commands %sh{ add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i # (after functional notation as they may contain paranthesis) - add-highlighter shared/css/code/psudo regex (:{1,2})([a-z-]+) 2:attribute 2:+a + add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 2:attribute 2:+a add-highlighter shared/css/code/at_rules regex @[a-z-]+ 0:function From b81d38da5e8d8c49f408f66c94253580d464a514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 12 Apr 2022 08:31:06 -0400 Subject: [PATCH 12/14] remove '+a' in pseudo classes face --- rc/filetype/css.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 1615c2daf..a713a6ca8 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -86,7 +86,7 @@ evaluate-commands %sh{ add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i # (after functional notation as they may contain paranthesis) - add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 2:attribute 2:+a + add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 2:attribute add-highlighter shared/css/code/at_rules regex @[a-z-]+ 0:function From 4215e8a6eb4e0cdc4b097c0a6f27481184235471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 12 Apr 2022 08:38:18 -0400 Subject: [PATCH 13/14] use '0:FACE' for selectors as the entire string should be highlighted --- rc/filetype/css.kak | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index a713a6ca8..06e45fe47 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -92,8 +92,8 @@ evaluate-commands %sh{ add-highlighter shared/css/code/css_property regex ([A-Za-z][A-Za-z0-9_-]*)\h*:\h 1:operator 1:+a - add-highlighter shared/css/code/selectors regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 1:type - add-highlighter shared/css/code/selectors_id regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 1:type 1:+i + add-highlighter shared/css/code/selectors regex (\*|[*]?[.][A-Za-z][A-Za-z0-9_-]+) 0:type + add-highlighter shared/css/code/selectors_id regex (\*|[*]?[#][A-Za-z][A-Za-z0-9_-]+) 0:type 0:+i add-highlighter shared/css/code/hex_values regex (#[0-9A-Fa-f]{3,8})\b 0:value 0:+a add-highlighter shared/css/code/units regex \b(\d*\.)?\d+($(join "${units}"))?\b 0:value 0:+a From abc36547659da77c0c576329fc0c1b1d1c40c677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Gonz=C3=A1lez?= Date: Tue, 19 Apr 2022 18:31:33 -0400 Subject: [PATCH 14/14] include : and :: as being highlighted for pseudo classes --- rc/filetype/css.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/css.kak b/rc/filetype/css.kak index 06e45fe47..6e90f4c27 100644 --- a/rc/filetype/css.kak +++ b/rc/filetype/css.kak @@ -86,7 +86,7 @@ evaluate-commands %sh{ add-highlighter shared/css/code/media_types regex \b($(join "${media_types}"))\b 1:+i # (after functional notation as they may contain paranthesis) - add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 2:attribute + add-highlighter shared/css/code/pseudo regex (:{1,2})([a-z-]+) 0:attribute add-highlighter shared/css/code/at_rules regex @[a-z-]+ 0:function