Skip to content

Commit ce660d5

Browse files
committed
Replaced s:initVariable with get() build-in function
1 parent 910bed2 commit ce660d5

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

plugin/php-cs-fixer.vim

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,20 @@ if exists("g:vim_php_cs_fixer") || &cp
33
endif
44
let g:vim_php_cs_fixer = 1
55

6-
" Taken from NerdTree
7-
function! s:initVariable(var, value)
8-
if !exists(a:var)
9-
exec 'let ' . a:var . ' = ' . "'" . substitute(a:value, "'", "''", "g") . "'"
10-
return 1
11-
endif
12-
return 0
13-
endfunction
14-
15-
call s:initVariable("g:php_cs_fixer_path", "~/php-cs-fixer.phar")
16-
call s:initVariable("g:php_cs_fixer_level", "all")
17-
call s:initVariable("g:php_cs_fixer_php_path", "php")
18-
call s:initVariable("g:php_cs_fixer_enable_default_mapping", 1)
19-
call s:initVariable("g:php_cs_fixer_dry_run", 0)
20-
call s:initVariable("g:php_cs_fixer_verbose", 0)
6+
" Global options definition."{{{
7+
let g:php_cs_fixer_path = get(g:, 'php_cs_fixer_path', '~/php-cs-fixer.phar')
8+
let g:php_cs_fixer_level = get(g:, 'php_cs_fixer_level', 'all')
9+
let g:php_cs_fixer_php_path = get(g:, 'php_cs_fixer_php_path', 'php')
10+
let g:php_cs_fixer_enable_default_mapping = get(g:, 'php_cs_fixer_enable_default_mapping', '1')
11+
let g:php_cs_fixer_dry_run = get(g:, 'php_cs_fixer_dry_run', 0)
12+
let g:php_cs_fixer_verbose = get(g:, 'php_cs_fixer_verbose', 0)
2113

2214
let g:php_cs_fixer_command = g:php_cs_fixer_php_path.' '.g:php_cs_fixer_path.' fix'
2315

2416
if exists('g:php_cs_fixer_config')
2517
let g:php_cs_fixer_command = g:php_cs_fixer_command.' --config='.g:php_cs_fixer_config
2618
endif
19+
"}}}
2720

2821

2922
fun! PhpCsFixerFix(path, dry_run)
@@ -77,3 +70,5 @@ if(g:php_cs_fixer_enable_default_mapping == 1)
7770
nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
7871
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>
7972
endif
73+
74+
" vim: foldmethod=marker

0 commit comments

Comments
 (0)