diff options
Diffstat (limited to 'vim/after/ftplugin/php.vim')
-rw-r--r-- | vim/after/ftplugin/php.vim | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/vim/after/ftplugin/php.vim b/vim/after/ftplugin/php.vim index 0ce099a0..20d8d42e 100644 --- a/vim/after/ftplugin/php.vim +++ b/vim/after/ftplugin/php.vim @@ -1,8 +1,11 @@ " Use PHP itself for syntax checking compiler php -setlocal equalprg=phpcsff let b:undo_ftplugin .= '|unlet b:current_compiler' - \ . '|setlocal equalprg< errorformat< makeprg<' + \ . '|setlocal errorformat< makeprg<' +if executable('php-cs-fixer') + setlocal equalprg=phpcsff + let b:undo_ftplugin .= '|setlocal equalprg<' +endif " Set comment formats setlocal comments=s1:/*,m:*,ex:*/,://,:# @@ -26,3 +29,16 @@ let b:undo_ftplugin .= '|unlet b:regex_escape_flavor' if !exists('b:alternate_filetypes') let b:alternate_filetypes = [&filetype, 'html'] endif + +" Stop here if the user doesn't want ftplugin mappings +if exists('no_plugin_maps') || exists('no_php_maps') + finish +endif + +" Mappings to choose 'equalprg' +nnoremap <buffer> <LocalLeader>f + \ :<C-U>setlocal equalprg=phpcsff<CR> +nnoremap <buffer> <LocalLeader>i + \ :<C-U>setlocal equalprg<<CR> +let b:undo_ftplugin .= '|nunmap <buffer> <LocalLeader>f' + \ . '|nunmap <buffer> <LocalLeader>i' |