From c793712318bc1223d621bab68084863ae1ea2a60 Mon Sep 17 00:00:00 2001 From: John Isom Date: Fri, 31 Jul 2020 19:24:19 -0600 Subject: [PATCH 1/6] Fix ruby-indent-on-char --- 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 2be1291a..df3c496a 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -139,10 +139,10 @@ define-command -hidden ruby-trim-indent %{ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start - try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) s \A | \z ) } - try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) s \A | \z ) } + try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) ) } + try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) ) } + try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) ) } + try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) ) } } } From e84ebfdfab5adc394a8fa723b4e1f1ef79e68b26 Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 10:16:48 -0600 Subject: [PATCH 2/6] Replace ') ' with '1' --- 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 df3c496a..c10bfb64 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -139,10 +139,10 @@ define-command -hidden ruby-trim-indent %{ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start - try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) ) } - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) ) } - try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) ) } - try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) ) } + try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) 1 } + try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) 1 } + try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) 1 } + try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } } } From b7490d853ddb0af3c1ff51664f3258a06785706d Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 10:28:54 -0600 Subject: [PATCH 3/6] Add support for deindenting `rescue` statment when part of `def` (instead of just `begin`) --- rc/filetype/ruby.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index c10bfb64..25981378 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -141,7 +141,7 @@ define-command -hidden ruby-indent-on-char %{ # align middle and end structures to start try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) 1 } try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) 1 } - try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin) 1 } + try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin|def) 1 } try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } } } From d6e3c1ff19a614502c4f56bce0ce895c01b9f201 Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 10:52:26 -0600 Subject: [PATCH 4/6] Fix deindenting nested blocks/statements --- 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 25981378..e5a2f711 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -139,10 +139,10 @@ define-command -hidden ruby-trim-indent %{ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start - try %{ execute-keys -draft ^ \h * (else|elsif) $ ^ \h * (if) 1 } - try %{ execute-keys -draft ^ \h * (when) $ ^ \h * (case) 1 } - try %{ execute-keys -draft ^ \h * (rescue) $ ^ \h * (begin|def) 1 } - try %{ execute-keys -draft ^ \h * (end) $ ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } + try %{ execute-keys -draft ^ \h * (else|elsif) $ i ^ \h * (if) 1 } + try %{ execute-keys -draft ^ \h * (when) $ i ^ \h * (case) 1 } + try %{ execute-keys -draft ^ \h * (rescue) $ i ^ \h * (begin|def) 1 } + try %{ execute-keys -draft ^ \h * (end) $ i ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } } } From 322d0659fd1882582fae4f1e13c628ace32ae0c1 Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 11:54:57 -0600 Subject: [PATCH 5/6] Add 'when' to list of keywords that signifies end for `ruby-insert-on-new-line` --- rc/filetype/ruby.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index e5a2f711..272dcf09 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -169,7 +169,7 @@ define-command -hidden ruby-insert-on-new-line %[ # 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\|.+(?=\|))[^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)[^0-9A-Za-z_!?] + execute-keys -draft }i J ^x(end|else|elsif|rescue|when)[^0-9A-Za-z_!?] ] execute-keys -draft oxend # insert a new line with containing end ] From 57e9719c25a3038d34b91bff2258cac323e80813 Mon Sep 17 00:00:00 2001 From: John Isom Date: Sat, 1 Aug 2020 11:57:38 -0600 Subject: [PATCH 6/6] Add 'else' to auto deindent/align logic in context of 'case' statement --- rc/filetype/ruby.kak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rc/filetype/ruby.kak b/rc/filetype/ruby.kak index 272dcf09..dd45d85a 100644 --- a/rc/filetype/ruby.kak +++ b/rc/filetype/ruby.kak @@ -140,7 +140,7 @@ define-command -hidden ruby-indent-on-char %{ evaluate-commands -no-hooks -draft -itersel %{ # align middle and end structures to start try %{ execute-keys -draft ^ \h * (else|elsif) $ i ^ \h * (if) 1 } - try %{ execute-keys -draft ^ \h * (when) $ i ^ \h * (case) 1 } + try %{ execute-keys -draft ^ \h * (else|when) $ i ^ \h * (case) 1 } try %{ execute-keys -draft ^ \h * (rescue) $ i ^ \h * (begin|def) 1 } try %{ execute-keys -draft ^ \h * (end) $ i ^ \h * (begin|case|class|def|for|if|module|unless|until|while) 1 } }