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.
Install telescope and PHP_CodeSniffer.
-- vim-plug
Plug 'ValentinVoigt/nvim-phpcsf'
-- vim-packer
use({ "ValentinVoigt/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)
vim.api.nvim_create_autocmd({ "BufWritePost", "BufReadPost", "InsertLeave" }, {
pattern = "*.php",
callback = function()
require'phpcs'.cs()
end,
})