Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf91c424

Browse files
committed
Add configuration option for fluent setters.
This commit adds g:php_refactoring_make_setter_fluent which is by default 0.Possible values are:0 - Disabled1 - Enabled2 - PromptOther - Error
1 parentb3fd864 commitf91c424

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

‎README.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,17 @@ let g:vim_php_refactoring_default_property_visibility = 'private'
5252
let g:vim_php_refactoring_default_method_visibility = 'private'
5353
```
5454

55+
To enable fluent setters add either of these lines to your`~/.vimrc` file
56+
```
57+
" default is 0 -- disabled
58+
59+
" to enable for all setters
60+
let g:vim_php_refactoring_fluent_setter = 1
61+
62+
" to enable but be prompted when creating the setter
63+
let g:vim_php_refactoring_fluent_setter = 2
64+
```
65+
5566

5667
##Default Mappings
5768

‎plugin/php-refactoring-toolbox.vim‎

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ endif
4545
if!exists('g:vim_php_refactoring_default_method_visibility')
4646
letg:vim_php_refactoring_default_method_visibility='private'
4747
endif
48+
49+
if!exists('g:vim_php_refactoring_make_setter_fluent')
50+
letg:vim_php_refactoring_make_setter_fluent=0
51+
endif
4852
" }}}
4953

5054
" Refactoring mapping {{{
@@ -90,6 +94,10 @@ let s:php_regex_fqcn = '[\\_A-Za-z0-9]*'
9094
lets:php_regex_cn='[_A-Za-z0-9]\+'
9195
" }}}
9296

97+
" Fluent {{{
98+
lets:php_fluent_this="normal! jo\<CR>return $this;"
99+
" }}}
100+
93101
function!PhpDocAll()" {{{
94102
ifexists("*" .g:vim_php_refactoring_phpdoc)==0
95103
calls:PhpEchoError(g:vim_php_refactoring_phpdoc .'() vim function doesn''t exists.')
@@ -128,9 +136,8 @@ function! PhpCreateSettersAndGetters() " {{{
128136
endif
129137
ifsearch(s:php_regex_func_line ."set" .l:camelCaseName .'\>','n')==0
130138
calls:PhpInsertMethod("public","set" .l:camelCaseName, ['$' .substitute(l:property,'^_','','') ],"$this->" .l:property ." = $" .substitute(l:property,'^_','','') .";\n")
131-
calls:PhpEchoError('Make fluent?')
132-
ifinputlist(["0. No","1. Yes"])==1
133-
exec"normal! jo\<CR>return $this;"
139+
ifg:vim_php_refactoring_make_setter_fluent >0
140+
calls:PhpInsertFluent()
134141
endif
135142
endif
136143
ifsearch(s:php_regex_func_line ."get" .l:camelCaseName .'\>','n')==0
@@ -529,3 +536,17 @@ function! s:PhpEchoError(message) " {{{
529536
echohlNONE
530537
endfunction
531538
" }}}
539+
540+
function!s:PhpInsertFluent()" {{{
541+
ifg:vim_php_refactoring_make_setter_fluent==1
542+
execs:php_fluent_this
543+
elseifg:vim_php_refactoring_make_setter_fluent==2
544+
calls:PhpEchoError('Make fluent?')
545+
ifinputlist(["0. No","1. Yes"])==1
546+
execs: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

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp