https://github.com/praem90/nvim-phpcsf
A simple nvim plugin wrapper for both phpcs and phpcbf.
https://github.com/praem90/nvim-phpcsf
lua nvim nvim-plugin php-codesniffer
Last synced: 10 months ago
JSON representation
A simple nvim plugin wrapper for both phpcs and phpcbf.
- Host: GitHub
- URL: https://github.com/praem90/nvim-phpcsf
- Owner: praem90
- Created: 2021-05-13T15:50:40.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2025-03-06T13:43:28.000Z (11 months ago)
- Last Synced: 2025-04-12T09:13:53.966Z (10 months ago)
- Topics: lua, nvim, nvim-plugin, php-codesniffer
- Language: Lua
- Homepage: https://praem90.github.io/nvim-phpcsf/
- Size: 31.3 KB
- Stars: 16
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nvim-phpcsf
## What is nvim-phpcsf?
`nvim-phpcsf` is a simple nvim plugin wrapper for both phpcs and phpcbf.
The PHP_CodeSniffer's output is populated using the telescope picker. Telescope helps to navigate through phpcs errors and warnings and preview.
## Instalation
Install [telescope](https://github.com/nvim-telescope/telescope.nvim) and [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
Using the [vim-plug](https://github.com/junegunn/vim-plug) plugin manager add the following in your VIM configuration (e.g. ~/.vimrc or ~/.config/nvim/init.vim when using Neovim):
```
Plug 'praem90/nvim-phpcsf'
```
To run sniffer
```
:lua require'phpcs'.cs()
```
To run beautifier
```
:lua require'phpcs'.cbf()
```
To run PHP_CodeBeautifier after save (It is recommended to run this after the buffer has been written BufWritePost)
```
augroup PHBSCF
autocmd!
autocmd BufWritePost,BufReadPost,InsertLeave *.php :lua require'phpcs'.cs()
autocmd BufWritePost *.php :lua require'phpcs'.cbf()
augroup END
```
## Configurations
```vim
let g:nvim_phpcs_config_phpcs_path = 'phpcs'
let g:nvim_phpcs_config_phpcbf_path = 'phpcbf'
let g:nvim_phpcs_config_phpcs_standard = 'PSR12' " or path to your ruleset phpcs.xml
```
Using lua
```lua
require("phpcs").setup({
phpcs = "phpcs",
phpcbf = "phpcbf",
standard = "PSR12"
})
```
## Thanks
[@thePrimeagen](https://github.com/theprimeagen)
[@tjDevries](https://github.com/tjDevries)
## TODO:
- [x] Detect phpcs.xml automatically on the project root
- [x] Add sign to current buffer