From e142a37f21777952c6965d5e248d5f1edb1c4e6e Mon Sep 17 00:00:00 2001 From: Las Date: Mon, 23 Mar 2020 16:20:02 +0900 Subject: [PATCH] rc ruby: Don't recognize "keyword"-like identifiers In Ruby, identifiers can end with a `!` or `?` too, which means that `class!` or `end?`are not actually keywords, but regular identifiers. This fixes that by not using `\b` but `[^0-9A-Za-z_!?]` instead in some places. --- rc/filetype/ruby.kak | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 6ef7def5..658ba9c3 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -86,7 +86,7 @@ evaluate-commands %sh{ # Highlight keywords printf %s " - add-highlighter shared/ruby/code/ regex \b(${keywords})\b 0:keyword + add-highlighter shared/ruby/code/ regex \b(${keywords})[^0-9A-Za-z_!?] 1:keyword add-highlighter shared/ruby/code/ regex \b(${attributes})\b 0:attribute add-highlighter shared/ruby/code/ regex \b(${values})\b 0:value add-highlighter shared/ruby/code/ regex \b(${meta})\b 0:meta @@ -153,7 +153,7 @@ define-command -hidden ruby-indent-on-new-line %{ # filter previous line try %{ execute-keys -draft k : ruby-trim-indent } # indent after start structure - try %{ execute-keys -draft k ^ \h * (begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|)) \b j } + try %{ execute-keys -draft k ^ \h * (begin|case|class|def|else|elsif|ensure|for|if|module|rescue|unless|until|when|while|.+\bdo$|.+\bdo\h\|.+(?=\|)) [^0-9A-Za-z_!?] j } } } @@ -167,9 +167,9 @@ define-command -hidden ruby-insert-on-new-line %[ try %[ evaluate-commands -draft %[ # Check if previous line opens a block - execute-keys -draft k ^x(begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))\b + execute-keys -draft k ^x(begin|case|class|def|for|if|module|unless|until|while|.+\bdo$|.+\bdo\h\|.+(?=\|))[^0-9A-Za-z_!?] # Check that we do not already have an end for this indent level which is first set via `ruby-indent-on-new-line` hook - execute-keys -draft }i J ^x(end|else|elsif|rescue)\b + execute-keys -draft }i J ^x(end|else|elsif|rescue)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ]