Skip to content

Commit

Permalink
Try to implement full ruby string switching with quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewRadev committed Apr 25, 2023
1 parent a3fd7bf commit 6b6cfda
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions ftplugin/ruby/switch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ let b:switch_definitions =
\ g:switch_builtins.rspec_expect,
\ g:switch_builtins.rspec_to,
\ g:switch_builtins.rspec_be_truthy_falsey,
\ g:switch_builtins.ruby_keyword_string,
\ g:switch_builtins.ruby_string,
\ g:switch_builtins.ruby_short_blocks,
\ g:switch_builtins.ruby_array_shorthand,
Expand Down
6 changes: 5 additions & 1 deletion plugin/switch.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@ let g:switch_builtins =
\ 'if false and (\(.*\))': 'if \1',
\ 'if \%(true\|false\)\@!\(.*\)': 'if true or (\1)',
\ },
\ 'ruby_string': {
\ 'ruby_keyword_string': {
\ '"\(\k\+\%([?!]\)\=\)"': '''\1''',
\ '''\(\k\+\%([?!]\)\=\)''': ':\1',
\ ':\(\k\+\%([?!]\)\=\)\@>\%(\s*=>\)\@!': '"\1"\2',
\ },
\ 'ruby_string': {
\ '"\(\%([^"\\]\|\\.\)*\)"': '''\1''',
\ '''\(\%([^''\\]\|\\.\)*\)''': '"\1"',
\ },
\ 'ruby_short_blocks': {
\ '\(\k\+\)(&:\(\k\+[!?]\=\))': '\1 { |x| x\.\2 }',
\ '\(\k\+\)\s\={\s*|\(\k\+\)|\s*\2.\(\S\+\)\s*}': '\1(&:\3)',
Expand Down

0 comments on commit 6b6cfda

Please sign in to comment.