Skip to content

Commit 4f41742

Browse files
committed
MS Windows compatibility, issue stephpy#34
1 parent b63a52a commit 4f41742

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

autoload/php_cs_fixer.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,16 @@ else
2020
end
2121

2222
" Check the php-cs-fixer version
23-
let g:php_cs_fixer_version = system(g:php_cs_fixer_version_command . " | sed -e 's/[^0-9.]*\\([0-9.]*\\).*/\\1/'")
23+
if (has('win32') || has('win64'))
24+
if empty(matchstr(&shell, 'powershell'))
25+
echoerr('This plugin requires PowerShell in Windows')
26+
finish
27+
else
28+
let g:php_cs_fixer_version = system("(Select-String -InputObject (" . g:php_cs_fixer_version_command . ") -Pattern " . shellescape("\"([0-9])\\.\"") . ").Matches.Groups.Groups[1].value\"")
29+
endif
30+
else
31+
let g:php_cs_fixer_version = system(g:php_cs_fixer_version_command . " | sed -e 's/[^0-9.]*\\([0-9.]*\\).*/\\1/'")
32+
endif
2433

2534
if g:php_cs_fixer_version >= 2
2635
let g:php_cs_fixer_rules = get(g:, 'php_cs_fixer_rules', '@PSR2')

0 commit comments

Comments
 (0)