Skip to content

Commit cc55fc1

Browse files
authored
Merge pull request stephpy#31 from adriaanzon/master
Improve startup time with autoloading
2 parents 72bcb6a + 2a376de commit cc55fc1

File tree

2 files changed

+34
-25
lines changed

2 files changed

+34
-25
lines changed

plugin/php-cs-fixer.vim renamed to autoload/php_cs_fixer.vim

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
"=============================================================================
2-
" File: php-cs-fixer.vim
2+
" File: autoload/php_cs_fixer.vim
33
" Author: Stéphane PY
44

5-
if exists("g:vim_php_cs_fixer") || &cp
6-
finish
7-
endif
8-
let g:vim_php_cs_fixer = 1
9-
105
" Global options definition."{{{
116
let g:php_cs_fixer_path = get(g:, 'php_cs_fixer_path', '~/php-cs-fixer.phar')
127
let g:php_cs_fixer_php_path = get(g:, 'php_cs_fixer_php_path', 'php')
@@ -27,9 +22,6 @@ if g:php_cs_fixer_version >= 2
2722
else
2823
let g:php_cs_fixer_level = get(g:, 'php_cs_fixer_level', 'symfony')
2924
endif
30-
let g:php_cs_fixer_enable_default_mapping = get(g:, 'php_cs_fixer_enable_default_mapping', '1')
31-
let g:php_cs_fixer_dry_run = get(g:, 'php_cs_fixer_dry_run', 0)
32-
let g:php_cs_fixer_verbose = get(g:, 'php_cs_fixer_verbose', 0)
3325

3426
if g:php_cs_fixer_version == 1
3527
if exists('g:php_cs_fixer_config')
@@ -50,7 +42,7 @@ if exists('g:php_cs_fixer_cache')
5042
endif
5143
"}}}
5244

53-
fun! PhpCsFixerFix(path, dry_run)
45+
fun! php_cs_fixer#fix(path, dry_run)
5446

5547
if !executable('php-cs-fixer')
5648
if !filereadable(expand(g:php_cs_fixer_path))
@@ -127,18 +119,3 @@ fun! PhpCsFixerFix(path, dry_run)
127119
endif
128120
endif
129121
endfun
130-
131-
fun! PhpCsFixerFixDirectory()
132-
call PhpCsFixerFix(expand('%:p:h'), g:php_cs_fixer_dry_run)
133-
endfun
134-
135-
fun! PhpCsFixerFixFile()
136-
call PhpCsFixerFix(expand('%:p'), g:php_cs_fixer_dry_run)
137-
endfun
138-
139-
if(g:php_cs_fixer_enable_default_mapping == 1)
140-
nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
141-
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>
142-
endif
143-
144-
" vim: foldmethod=marker

plugin/php_cs_fixer.vim

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"=============================================================================
2+
" File: plugin/php_cs_fixer.vim
3+
" Author: Stéphane PY
4+
5+
if exists("g:vim_php_cs_fixer") || &cp
6+
finish
7+
endif
8+
let g:vim_php_cs_fixer = 1
9+
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)
13+
14+
" Backwards compatibility
15+
fun! PhpCsFixerFix(path, dry_run)
16+
call php_cs_fixer#fix(a:path, a:dry_run)
17+
endfun
18+
19+
fun! PhpCsFixerFixDirectory()
20+
call php_cs_fixer#fix(expand('%:p:h'), g:php_cs_fixer_dry_run)
21+
endfun
22+
23+
fun! PhpCsFixerFixFile()
24+
call php_cs_fixer#fix(expand('%:p'), g:php_cs_fixer_dry_run)
25+
endfun
26+
27+
if(g:php_cs_fixer_enable_default_mapping == 1)
28+
nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
29+
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>
30+
endif
31+
32+
" vim: foldmethod=marker

0 commit comments

Comments
 (0)