nvim-phpcs is a fork of nvim-phpcsf - A Neovim plugin for PHP_CodeSniffer that provides seamless integration with Telescope for navigating and previewing PHP code sniffer errors and warnings.
- Automatic Ruleset Detection: Automatically detects local ruleset filenames in the following order:
phpcs.xml(highest precedence)ruleset.xml.phpcs.xml.dist
- Improved Diagnostics Mapping: Fixes path normalization issues from the original repository that prevented diagnostics from appearing in the editor.
- Excludes formatting: The formatting functionality (phpcbf) has been removed. You can configure a formatter like conform.nvim for this purpose.
Using lazy.nvim
{
"ppiwo/nvim-phpcs",
event = { "BufReadPost" },
dependencies = {
"nvim-telescope/telescope.nvim",
},
ft = { "php" },
config = function()
vim.g.nvim_phpcs_config_phpcs_path = "phpcs"
vim.g.nvim_phpcs_config_phpcs_standard = ""
vim.api.nvim_create_augroup("PHPCSGroup", { clear = true })
vim.api.nvim_create_autocmd({ "BufWritePost", "BufReadPost" }, {
group = "PHPCSGroup",
pattern = "*.php",
command = "lua require'phpcs'.cs()",
})
end,
}