Skip to content

Commit d07cc6f

Browse files
committed
Can use php-cs-fixer on file now
1 parent 0ec0dad commit d07cc6f

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

README.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Vim-php-cs-fixer
33

44
Integrate [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) created by fabpot.
55

6-
This plugin will execute the `php-cs-fixer` command on the directory where you launch the command. See options to know how to customize that.
6+
This plugin will execute the `php-cs-fixer` command on the directory or file (depends on which command you call). See options to know how to customize that.
77

88
**Options available**:
99

@@ -22,7 +22,8 @@ Default mapping is `<leader>pcd`
2222
If you want to change it:
2323

2424
```viml
25-
map <leader>pcd :call PhpCsFixerFix(expand('%:p:h'))<CR>
25+
map <leader>pcd :call PhpCsFixerFixDirectory()<CR>
26+
map <leader>pcf :call PhpCsFixerFixFile()<CR>
2627
```
2728

2829
# Installation
@@ -36,9 +37,3 @@ Bundle 'stephpy/vim-php-cs-fixer'
3637
To see how to install `php-cs-fixer`, look at [php-cs-fixer](https://github.com/fabpot/PHP-CS-Fixer) repository.
3738

3839
If you see any improvement or question, contribute or create an issue
39-
40-
----------------------
41-
42-
Todo
43-
44-
- User can launch command for the actual file OR the actual dir.

plugin/php-cs-fixer.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ fun! PhpCsFixerFix(path)
3131
exe ':! echo '.command.' && '.command
3232
endfun
3333

34+
fun! PhpCsFixerFixDirectory()
35+
call PhpCsFixerFix(expand('%:p:h'))
36+
endfun
37+
38+
fun! PhpCsFixerFixFile()
39+
call PhpCsFixerFix(expand('%:p'))
40+
endfun
41+
3442
if(g:php_cs_fixer_default_mapping == 1)
35-
map <leader>pcd :call PhpCsFixerFix(expand('%:p:h'))<CR>
43+
map <leader>pcd :call PhpCsFixerFixDirectory()<CR>
44+
map <leader>pcf :call PhpCsFixerFixFile()<CR>
3645
endif

0 commit comments

Comments
 (0)