|
45 | 45 | if !exists('g:vim_php_refactoring_default_method_visibility')
|
46 | 46 | let g:vim_php_refactoring_default_method_visibility = 'private'
|
47 | 47 | endif
|
| 48 | + |
| 49 | +if !exists('g:vim_php_refactoring_make_setter_fluent') |
| 50 | + let g:vim_php_refactoring_make_setter_fluent = 0 |
| 51 | +endif |
48 | 52 | " }}}
|
49 | 53 |
|
50 | 54 | " Refactoring mapping {{{
|
@@ -90,6 +94,10 @@ let s:php_regex_fqcn = '[\\_A-Za-z0-9]*'
|
90 | 94 | let s:php_regex_cn = '[_A-Za-z0-9]\+'
|
91 | 95 | " }}}
|
92 | 96 |
|
| 97 | +" Fluent {{{ |
| 98 | +let s:php_fluent_this = "normal! jo\<CR>return $this;" |
| 99 | +" }}} |
| 100 | + |
93 | 101 | function! PhpDocAll() " {{{
|
94 | 102 | if exists("*" . g:vim_php_refactoring_phpdoc) == 0
|
95 | 103 | call s:PhpEchoError(g:vim_php_refactoring_phpdoc . '() vim function doesn''t exists.')
|
@@ -128,9 +136,8 @@ function! PhpCreateSettersAndGetters() " {{{
|
128 | 136 | endif
|
129 | 137 | if search(s:php_regex_func_line . "set" . l:camelCaseName . '\>', 'n') == 0
|
130 | 138 | call s:PhpInsertMethod("public", "set" . l:camelCaseName, ['$' . substitute(l:property, '^_', '', '') ], "$this->" . l:property . " = $" . substitute(l:property, '^_', '', '') . ";\n")
|
131 |
| - call s:PhpEchoError('Make fluent?') |
132 |
| - if inputlist(["0. No", "1. Yes"]) == 1 |
133 |
| - exec "normal! jo\<CR>return $this;" |
| 139 | + if g:vim_php_refactoring_make_setter_fluent > 0 |
| 140 | + call s:PhpInsertFluent() |
134 | 141 | endif
|
135 | 142 | endif
|
136 | 143 | if search(s:php_regex_func_line . "get" . l:camelCaseName . '\>', 'n') == 0
|
@@ -529,3 +536,17 @@ function! s:PhpEchoError(message) " {{{
|
529 | 536 | echohl NONE
|
530 | 537 | endfunction
|
531 | 538 | " }}}
|
| 539 | + |
| 540 | +function! s:PhpInsertFluent() " {{{ |
| 541 | + if g:vim_php_refactoring_make_setter_fluent == 1 |
| 542 | + exec s:php_fluent_this |
| 543 | + elseif g:vim_php_refactoring_make_setter_fluent == 2 |
| 544 | + call s:PhpEchoError('Make fluent?') |
| 545 | + if inputlist(["0. No", "1. Yes"]) == 1 |
| 546 | + exec s:php_fluent_this |
| 547 | + endif |
| 548 | + else |
| 549 | + echoerr 'Invalid option for g:vim_php_refactoring_make_setter_fluent' |
| 550 | + endif |
| 551 | +endfunction |
| 552 | +" }}} |
0 commit comments