@@ -14,6 +14,7 @@ call s:initVariable("g:php_cs_fixer_php_path", "php")
14
14
call s: initVariable (" g:php_cs_fixer_fixers_list" , " " )
15
15
call s: initVariable (" g:php_cs_fixer_default_mapping" , 1 )
16
16
call s: initVariable (" g:php_cs_fixer_dry_run" , 0 )
17
+ call s: initVariable (" g:php_cs_fixer_verbose" , 0 )
17
18
18
19
let g: php_cs_fixer_command = g: php_cs_fixer_php_path .' ' .g: php_cs_fixer_path .' fix --config=' .g: php_cs_fixer_config
19
20
@@ -28,12 +29,26 @@ fun! PhpCsFixerFix(path)
28
29
let command = command .' --fixers=' .g: php_cs_fixer_fixers_list
29
30
endif
30
31
31
- let output = system (command )
32
+ let s: output = system (command )
32
33
if v: shell_error
33
- echohl Error | echo output | echohl None
34
+ echohl Error | echo s: output | echohl None
34
35
else
35
- " todo, count how many files have been updated
36
- echohl Title | echo output | echohl None
36
+ let s: nbLines = len (split (s: output , ' \n' ))
37
+ let s: nbFilesModified = (s: nbLines - 1 )
38
+
39
+ if (g: php_cs_fixer_verbose == 1 )
40
+ " @todo, if dry-run, purpose to user to launch command without
41
+ " dry-run
42
+ echohl Title | echo s: output | echohl None
43
+ else
44
+ if (s: nbFilesModified > 0 )
45
+ " @todo, if dry-run, purpose to user to launch command without
46
+ " dry-run
47
+ echohl Title | echo " There is " .s: nbFilesModified ." file(s) modified(s)" | echohl None
48
+ else
49
+ echohl Title | echo " There is no cs to fix" | echohl None
50
+ endif
51
+ endif
37
52
endif
38
53
endfun
39
54
@@ -46,6 +61,6 @@ fun! PhpCsFixerFixFile()
46
61
endfun
47
62
48
63
if (g: php_cs_fixer_default_mapping == 1 )
49
- map <leader> pcd :call PhpCsFixerFixDirectory()<CR>
50
- map <leader> pcf :call PhpCsFixerFixFile()<CR>
64
+ nnoremap <silent> <leader> pcd :call PhpCsFixerFixDirectory()<CR>
65
+ nnoremap <silent> <leader> pcf :call PhpCsFixerFixFile()<CR>
51
66
endif
0 commit comments