From 92558bb67565629a9997bf62e6d32617d3aa0a1b Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 13:15:41 -0600 Subject: [PATCH 1/3] Add rule for % string literals without bracket/style chars; no recurse yet Becuase %Q^hello^ is a perfectly valid Ruby string literal. Strange, I know. --- rc/filetype/ruby.kak | 1 + 1 file changed, 1 insertion(+) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 2be1291a..20cfc82b 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -52,6 +52,7 @@ add-highlighter shared/ruby/ region -recurse \( '%[iqrswxIQRSWX]?\( add-highlighter shared/ruby/ region -recurse \{ '%[iqrswxIQRSWX]?\{' \} fill meta add-highlighter shared/ruby/ region -recurse \[ '%[iqrswxIQRSWX]?\[' \] fill meta add-highlighter shared/ruby/ region -recurse < '%[iqrswxIQRSWX]?<' > fill meta +add-highlighter shared/ruby/ region -match-capture '%[iqrswxIQRSWX]?([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill meta add-highlighter shared/ruby/heredoc region '<<[-~]?(?!self)(\w+)' '^\h*(\w+)$' fill string add-highlighter shared/ruby/division region '[\w\)\]]\K(/|(\h+/\h+))' '\w' group # Help Kakoune to better detect /…/ literals From dee96f8e8282c9146ca8673e844b946d1d53d33e Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 13:37:40 -0600 Subject: [PATCH 2/3] Improve syntax highlighting of Ruby percent literals The syntax highlighting has been broken down into 3 main categories: string: string, array of words variable: symbol, array of symbols meta: regexp, shell execution --- rc/filetype/ruby.kak | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 20cfc82b..b813815b 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -33,7 +33,7 @@ hook -group ruby-highlight global WinSetOption filetype=ruby %{ hook -once -always window WinSetOption filetype=.* %{ remove-highlighter window/ruby } } -provide-module ruby %[ +provide-module ruby %§ # Highlighters # ‾‾‾‾‾‾‾‾‾‾‾‾ @@ -48,11 +48,21 @@ add-highlighter shared/ruby/backtick region '(? fill meta -add-highlighter shared/ruby/ region -match-capture '%[iqrswxIQRSWX]?([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill meta +add-highlighter shared/ruby/ region -recurse \( '%[qwQW]?\(' \) fill string +add-highlighter shared/ruby/ region -recurse \{ '%[qwQW]?\{' \} fill string +add-highlighter shared/ruby/ region -recurse \[ '%[qwQW]?\[' \] fill string +add-highlighter shared/ruby/ region -recurse < '%[qwQW]?<' > fill string +add-highlighter shared/ruby/ region -recurse \( '%[isIS]\(' \) fill variable +add-highlighter shared/ruby/ region -recurse \{ '%[isIS]\{' \} fill variable +add-highlighter shared/ruby/ region -recurse \[ '%[isIS]\[' \] fill variable +add-highlighter shared/ruby/ region -recurse < '%[isIS]<' > fill variable +add-highlighter shared/ruby/ region -recurse \( '%[rxRX]\(' \) fill meta +add-highlighter shared/ruby/ region -recurse \{ '%[rxRX]\{' \} fill meta +add-highlighter shared/ruby/ region -recurse \[ '%[rxRX]\[' \] fill meta +add-highlighter shared/ruby/ region -recurse < '%[rxRX]<' > fill meta +add-highlighter shared/ruby/ region -match-capture '%[qwQW]?([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill string +add-highlighter shared/ruby/ region -match-capture '%[isIS]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill variable +add-highlighter shared/ruby/ region -match-capture '%[rxRX]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill meta add-highlighter shared/ruby/heredoc region '<<[-~]?(?!self)(\w+)' '^\h*(\w+)$' fill string add-highlighter shared/ruby/division region '[\w\)\]]\K(/|(\h+/\h+))' '\w' group # Help Kakoune to better detect /…/ literals @@ -178,4 +188,4 @@ define-command -hidden ruby-insert-on-new-line %[ ] ] -] +§ From 8a02bafe0de59d6e214511ffad070ef14221af9b Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 13:54:16 -0600 Subject: [PATCH 3/3] Beautify indenting in add-highlighter region for percent literals --- rc/filetype/ruby.kak | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index b813815b..5c974580 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -48,18 +48,18 @@ add-highlighter shared/ruby/backtick region '(? fill string -add-highlighter shared/ruby/ region -recurse \( '%[isIS]\(' \) fill variable -add-highlighter shared/ruby/ region -recurse \{ '%[isIS]\{' \} fill variable -add-highlighter shared/ruby/ region -recurse \[ '%[isIS]\[' \] fill variable -add-highlighter shared/ruby/ region -recurse < '%[isIS]<' > fill variable -add-highlighter shared/ruby/ region -recurse \( '%[rxRX]\(' \) fill meta -add-highlighter shared/ruby/ region -recurse \{ '%[rxRX]\{' \} fill meta -add-highlighter shared/ruby/ region -recurse \[ '%[rxRX]\[' \] fill meta -add-highlighter shared/ruby/ region -recurse < '%[rxRX]<' > fill meta +add-highlighter shared/ruby/ region -recurse \( '%[qwQW]?\(' \) fill string +add-highlighter shared/ruby/ region -recurse \{ '%[qwQW]?\{' \} fill string +add-highlighter shared/ruby/ region -recurse \[ '%[qwQW]?\[' \] fill string +add-highlighter shared/ruby/ region -recurse < '%[qwQW]?<' > fill string +add-highlighter shared/ruby/ region -recurse \( '%[isIS]\(' \) fill variable +add-highlighter shared/ruby/ region -recurse \{ '%[isIS]\{' \} fill variable +add-highlighter shared/ruby/ region -recurse \[ '%[isIS]\[' \] fill variable +add-highlighter shared/ruby/ region -recurse < '%[isIS]<' > fill variable +add-highlighter shared/ruby/ region -recurse \( '%[rxRX]\(' \) fill meta +add-highlighter shared/ruby/ region -recurse \{ '%[rxRX]\{' \} fill meta +add-highlighter shared/ruby/ region -recurse \[ '%[rxRX]\[' \] fill meta +add-highlighter shared/ruby/ region -recurse < '%[rxRX]<' > fill meta add-highlighter shared/ruby/ region -match-capture '%[qwQW]?([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill string add-highlighter shared/ruby/ region -match-capture '%[isIS]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill variable add-highlighter shared/ruby/ region -match-capture '%[rxRX]([^0-9A-Za-z\(\{\[<>\]\}\)])' ([^0-9A-Za-z\(\{\[<>\]\}\)]) fill meta