vim-php-cs-fixer : Integration of PHP CS Fixer on Vim Editor
script karma |
Rating 3/2,
Downloaded by 57 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
lin jialiang |
|
script type |
ftplugin |
|
description |
source code location: https://github.com/linjialiang/vim-php-cs-fixer
Supports PHP CS Fixer command execution on directories or files
Note: The plug-in is implemented using `vim9script`, which requires vim9.0 or
above to support the plug-in.
==============================================================================
Navigation
1. Options.......................................|vim-php-cs-fixer-options|
1.1 PHP Path...................|phpCsFixerPhpPath|
1.2 php-cs-fixer Path..........|phpCsFixerPath|
1.3 --dry-run..................|phpCsFixerIsDryRun|
1.4 --verbose..................|phpCsFixerIsVerbose|
1.5 --rules....................|phpCsFixerRules|
1.6 fix cache directory........|phpCsFixerFixCacheDir|
2. global function...............................|vim-php-cs-fixer-def|
2.1.file.......................|PhpCsFixerFixFile|
2.2.directory..................|PhpCsFixerFixDir|
3. Mappings......................................|vim-php-cs-fixer-mappings|
3.1.file.......................|phpCsFixFileMap|
3.2.directory..................|phpCsFixDirectoryMap|
3.3.remap......................|phpCsFixRemap|
==============================================================================
1. Options *vim-php-cs-fixer-options*
------------------------------------------------------------------------------
1.1 PHP Path *phpCsFixerPhpPath*
Note: PHP interpreter path
default: `'php'`
example: `g:phpCsFixerPhpPath = expand('~/php')`
------------------------------------------------------------------------------
1.2 php-cs-fixer Path *phpCsFixerPath*
Note: PHP CS Fixer path(must)
default: `''`
example: `g:phpCsFixerPath = expand('~/php/php-cs-fixer-v3.phar')`
------------------------------------------------------------------------------
1.3 --dry-run *phpCsFixerIsDryRun*
Note: enable PHP CS Fixer option --dry-run
default: `false`
example: `g:phpCsFixerIsDryRun = true`
------------------------------------------------------------------------------
1.4 --verbose *phpCsFixerIsVerbose*
Note: enable PHP CS Fixer option --verbose
default: `false`
example: `g:phpCsFixerIsVerbose = true`
------------------------------------------------------------------------------
1.5 --rules *phpCsFixerRules*
Note: settings PHP CS Fixer option --rules
default: `'$PSR12'`
example: `g:phpCsFixerRules = '@PhpCsFixer'`
Common Rule Group: @PSR2,@PSR12,@PER-CS,@Symfony,@PhpCsFixer
------------------------------------------------------------------------------
1.6 temporary file storage directory *phpCsFixerFixCacheDir*
default: vim-php-cs-fixer path to temp plugin subdirectory
example: `g:phpCsFixerFixCacheDir = expand('~/.php-cs-fixer/vim-fix-cache')`
------------------------------------------------------------------------------
==============================================================================
2. global function *vim-php-cs-fixer-def*
------------------------------------------------------------------------------
2.1 single file fix function *PhpCsFixerFixFile*
`g:PhpCsFixerFixFile()`
------------------------------------------------------------------------------
2.2 directory fix function *PhpCsFixerFixDir*
`g:PhpCsFixerFixDir()`
------------------------------------------------------------------------------
==============================================================================
3. Mappings *vim-php-cs-fixer-mappings*
------------------------------------------------------------------------------
3.1 single fix file map *phpCsFixFileMap*
key bindings: `<leader>pcf`
Note: fix current buffer file, filetype must be php
------------------------------------------------------------------------------
3.2 fix directory map *phpCsFixDirectoryMap*
key bindings: `<leader>pcd`
Note: fix the directory where the current buffer file is located
or the label directory(php type file)
------------------------------------------------------------------------------
3.3 remap *phpCsFixRemap*
you can remap, for example:
`nnoremap <unique><silent><Leader>f <Plug>PhpCsFixerFixFile;`
`nnoremap <unique><silent><Leader>d <Plug>PhpCsFixerFixDir;`
Better mapping, if you have multiple code formatting tools, you can refer to
this way to write:
def g:RunCodeFormat()
# Prettier supports many file types, here you can add or delete file types
var prettierSupportTypes = [
'javascript',
'typescript',
'json',
'markdown',
'css',
'html'
]
var currentFiletype = &filetype
if currentFiletype == 'php'
execute 'call PhpCsFixerFixFile()'
elseif prettierSupportTypes->index(currentFiletype) != -1
execute 'Prettier'
endif
enddef
nnoremap <silent><Leader>f :call g:RunCodeFormat()<CR>
------------------------------------------------------------------------------
==============================================================================
|
|
install details |
|
|
script versions (upload new version)
Click on the package to download.
vim-php-cs-fixer.zip |
0.0.13 |
2024-11-30 |
9.0 |
lin jialiang |
- add Chinese help |
vim-php-cs-fixer.zip |
0.0.12 |
2024-11-27 |
9.0 |
lin jialiang |
update readme and help |
vim-php-cs-fixer.zip |
0.0.11 |
2024-11-26 |
9.0 |
lin jialiang |
*vim-php-cs-fixer* {Integration of PHP CS Fixer on Vim Editor}
Supports PHP CS Fixer command execution on directories or files
Note: The plug-in is implemented using `vim9script`, which requires vim9.0 or
above to support the plug-in.
==============================================================================
Navigation
1. Options.......................................|vim-php-cs-fixer-options|
1.1 PHP Path...................|phpCsFixerPhpPath|
1.2 php-cs-fixer Path..........|phpCsFixerPath|
1.3 --dry-run..................|phpCsFixerIsDryRun|
1.4 --verbose..................|phpCsFixerIsVerbose|
1.5 --rules....................|phpCsFixerRules|
1.6 fix cache directory........|phpCsFixerFixCacheDir|
2. global function...............................|vim-php-cs-fixer-def|
2.1.file.......................|PhpCsFixerFixFile|
2.2.directory..................|PhpCsFixerFixDir|
3. Mappings......................................|vim-php-cs-fixer-mappings|
3.1.file.......................|phpCsFixFileMap|
3.2.directory..................|phpCsFixDirectoryMap|
3.3.remap......................|phpCsFixRemap|
==============================================================================
1. Options *vim-php-cs-fixer-options*
------------------------------------------------------------------------------
1.1 PHP Path *phpCsFixerPhpPath*
Note: PHP interpreter path
default: `'php'`
example: `g:phpCsFixerPhpPath = expand('~/php')`
------------------------------------------------------------------------------
1.2 php-cs-fixer Path *phpCsFixerPath*
Note: PHP CS Fixer path(must)
default: `''`
example: `g:phpCsFixerPath = expand('~/php/php-cs-fixer-v3.phar')`
------------------------------------------------------------------------------
1.3 --dry-run *phpCsFixerIsDryRun*
Note: enable PHP CS Fixer option --dry-run
default: `false`
example: `g:phpCsFixerIsDryRun = true`
------------------------------------------------------------------------------
1.4 --verbose *phpCsFixerIsVerbose*
Note: enable PHP CS Fixer option --verbose
default: `false`
example: `g:phpCsFixerIsVerbose = true`
------------------------------------------------------------------------------
1.5 --rules *phpCsFixerRules*
Note: settings PHP CS Fixer option --rules
default: `'$PSR12'`
example: `g:phpCsFixerRules = '@PhpCsFixer'`
Common Rule Group: @PSR2,@PSR12,@PER-CS,@Symfony,@PhpCsFixer
------------------------------------------------------------------------------
1.6 temporary file storage directory *phpCsFixerFixCacheDir*
default: vim-php-cs-fixer path to temp plugin subdirectory
example: `g:phpCsFixerFixCacheDir = expand('~/.php-cs-fixer/vim-fix-cache')`
------------------------------------------------------------------------------
==============================================================================
2. global function *vim-php-cs-fixer-def*
------------------------------------------------------------------------------
2.1 single file fix function *PhpCsFixerFixFile*
`g:PhpCsFixerFixFile()`
------------------------------------------------------------------------------
2.2 directory fix function *PhpCsFixerFixDir*
`g:PhpCsFixerFixDir()`
------------------------------------------------------------------------------
==============================================================================
3. Mappings *vim-php-cs-fixer-mappings*
------------------------------------------------------------------------------
3.1 single fix file map *phpCsFixFileMap*
key bindings: `<leader>pcf`
Note: fix the directory where the current buffer file is located
or the label directory(php type file)
------------------------------------------------------------------------------
3.2 fix directory map *phpCsFixDirectoryMap*
key bindings: `<leader>pcd`
Note: fix current buffer file, filetype must be php, want to support
empty buffer fix, you need to manually set |phpCsFixerFixCacheDir|
If |phpCsFixerFixCacheDir| is not set correctly, the unsaved contents of the
buffer will not participate in the repair and will be discarded.
------------------------------------------------------------------------------
3.3 remap *phpCsFixRemap*
you can remap, for example:
`nnoremap <unique><silent><Leader>f <Plug>PhpCsFixerFixFile;`
`nnoremap <unique><silent><Leader>d <Plug>PhpCsFixerFixDir;`
Better mapping, if you have multiple code formatting tools, you can refer to
this way to write:
def g:RunCodeFormat()
# Prettier supports many file types, here you can add or delete file types
var prettierSupportTypes = [
'javascript',
'typescript',
'json',
'markdown',
'css',
'html'
]
var currentFiletype = &filetype
if currentFiletype == 'php'
execute 'call PhpCsFixerFixFile()'
elseif prettierSupportTypes->index(currentFiletype) != -1
execute 'Prettier'
endif
enddef
nnoremap <silent><Leader>f :call g:RunCodeFormat()<CR>
------------------------------------------------------------------------------
==============================================================================
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim-php-cs-fixer.zip |
0.0.9 |
2024-11-22 |
9.0 |
lin jialiang |
performance optimization |
vim-php-cs-fixer.zip |
0.0.8 |
2024-11-22 |
9.0 |
lin jialiang |
update readme or help |
vim-php-cs-fixer.zip |
0.0.7 |
2024-11-22 |
9.0 |
lin jialiang |
update help |
vim-php-cs-fixer.zip |
v0.0.5 |
2024-11-22 |
9.0 |
lin jialiang |
Fix shortcut key mapping error |
vim-php-cs-fixer.zip |
0.0.2 |
2024-11-21 |
9.0 |
lin jialiang |
Initial upload |
ip used for rating: 18.97.14.90
|