summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <w0rp@users.noreply.github.com>2018-03-02 20:40:31 +0000
committerGitHub <noreply@github.com>2018-03-02 20:40:31 +0000
commitad7ffe287574745994811f345e0defd863e575a0 (patch)
tree063e947e495e4393074a934ba441fd7a7e5c4849 /autoload
parent2c2c7ceb1d2f3de97ba8a40dd7858e83b6755fcd (diff)
parentfbbb8c17d9634304fd6d10789e78d00c75b70e07 (diff)
downloadale-ad7ffe287574745994811f345e0defd863e575a0.zip
Merge pull request #1390 from jdeniau/jd-feat-phpCsFixer
add php-cs-fixer to list of fixers
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/php_cs_fixer.vim23
2 files changed, 28 insertions, 0 deletions
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 29e263a9..3e407c52 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -104,6 +104,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['php'],
\ 'description': 'Fix PHP files with phpcbf.',
\ },
+\ 'php_cs_fixer': {
+\ 'function': 'ale#fixers#php_cs_fixer#Fix',
+\ 'suggested_filetypes': ['php'],
+\ 'description': 'Fix PHP files with php-cs-fixer.',
+\ },
\ 'clang-format': {
\ 'function': 'ale#fixers#clangformat#Fix',
\ 'suggested_filetypes': ['c', 'cpp'],
diff --git a/autoload/ale/fixers/php_cs_fixer.vim b/autoload/ale/fixers/php_cs_fixer.vim
new file mode 100644
index 00000000..56aa9150
--- /dev/null
+++ b/autoload/ale/fixers/php_cs_fixer.vim
@@ -0,0 +1,23 @@
+" Author: Julien Deniau <julien.deniau@gmail.com>
+" Description: Fixing files with php-cs-fixer.
+
+call ale#Set('php_cs_fixer_executable', 'php-cs-fixer')
+call ale#Set('php_cs_fixer_use_global', 0)
+
+function! ale#fixers#php_cs_fixer#GetExecutable(buffer) abort
+ return ale#node#FindExecutable(a:buffer, 'php_cs_fixer', [
+ \ 'vendor/bin/php-cs-fixer',
+ \ 'php-cs-fixer'
+ \])
+endfunction
+
+function! ale#fixers#php_cs_fixer#Fix(buffer) abort
+ let l:executable = ale#fixers#php_cs_fixer#GetExecutable(a:buffer)
+ return {
+ \ 'command': ale#Escape(l:executable) . ' fix %t',
+ \ 'read_temporary_file': 1,
+ \}
+endfunction
+
+
+