File tree Expand file tree Collapse file tree 4 files changed +28
-0
lines changed
Expand file tree Collapse file tree 4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -800,6 +800,11 @@ String style (g:switch_builtins.python_string_style)
800800 "Ham"
801801 f"Ham"
802802<
803+ Dictionary style (g:switch_builtins.python_dict_style)
804+ >
805+ {'foo': 'bar', 'bar': 'baz'}
806+ dict(foo='bar', bar='baz')
807+ <
803808Jinja ~
804809
805810Tag type (g:switch_builtins.jinja_tag_type)
Original file line number Diff line number Diff line change @@ -6,4 +6,5 @@ let b:switch_definitions =
66 \ [
77 \ g: switch_builtins .python_dict_get,
88 \ g: switch_builtins .python_string_style,
9+ \ g: switch_builtins .python_dict_style,
910 \ ]
Original file line number Diff line number Diff line change @@ -236,6 +236,18 @@ let g:switch_builtins =
236236 \ ' \v(%(\%@<!\k)+)\[(.{-})\]' : ' \1.get(\2)' ,
237237 \ ' \v(\k+)\.get\((.{-})\)' : ' \1[\2]' ,
238238 \ },
239+ \ ' python_dict_style' : {
240+ \ ' {\(\s*['' "]\k\+['' "]:\s*.\+,\?\)\+}' : {
241+ \ ' {' : ' dict(' ,
242+ \ ' ['' "]\(\k\+\)['' "]:\s*' : ' \1=' ,
243+ \ ' }' : ' )' ,
244+ \ },
245+ \ ' dict(\(\s*\k\+=\s*.\+,\?\)\+)' : {
246+ \ ' dict(' : ' {' ,
247+ \ ' \(\k\+\)=' : ' ' ' \1'' : ' ,
248+ \ ' )' : ' }' ,
249+ \ },
250+ \ },
239251 \ ' python_string_style' : {
240252 \ ' f"\(\%([^"\\]\|\\.\)*\)"' : ' ' ' \1'' ' ,
241253 \ ' ' ' \(\%([^'' \\]\|\\.\)*\)'' ' : ' "\1"' ,
Original file line number Diff line number Diff line change 2525 vim . switch
2626 assert_file_contents "foo['one']"
2727 end
28+
29+ specify "dict style" do
30+ set_file_contents "data = {'foo': 'bar', 'bar': 'baz'}"
31+
32+ vim . search ( '{' ) . switch
33+ assert_file_contents "data = dict(foo='bar', bar='baz')"
34+
35+ vim . switch
36+ assert_file_contents "data = {'foo': 'bar', 'bar': 'baz'}"
37+ end
2838end
You can’t perform that action at this time.
0 commit comments