We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I'm new to nvim-lint and php is not my primary language, but I noticed an inconsistency between running phpcs locally versus inside neovim.
.phpcs.xml
<?xml version="1.0"?> <ruleset name="MyApp"> <file>blog/wp-content/themes/mytheme-child/</file> <file>app/</file> <rule ref="WordPress"> <exclude-pattern>app/</exclude-pattern> </rule> <rule ref="PSR12"> <exclude-pattern>blog/</exclude-pattern> </rule> <arg name="colors"/> <arg value="sp"/> <arg name="parallel" value="8"/> <arg name="report" value="full"/> <ini name="memory_limit" value="128M"/> </ruleset>
plugins.lua
{ 'mfussenegger/nvim-lint', config = function() require('plugin.linter') end },
plugins/linter.lua
local lint = require("lint") -- PHP local phpcs = lint.linters.phpcs phpcs.cmd = "vendor/bin/phpcs" -- Setup Linters lint.linters_by_ft = { php = { "phpcs" }, }
Scenario 1: Inside neovim
:lua require('lint').try_lint()
app/test.php
blog/wp-config.php
Scenario 2: Running phpcs
vendor/bin/phpcs app/test.php
vendor/bin/phpcs blog/wp-config.php
The text was updated successfully, but these errors were encountered:
I believe the issue is with stdin and lua/lint/linters/phpcs.lua. I can create a PR, but not sure if I'm heading down the right path.
I was able to match the functionality between running phpcs locally and using the linter in nvim.
I made the following changes to phpcs.lua.
phpcs.lua
parser = function(output, bufnr) -- other unmodified code local filename = vim.fn.fnamemodify(vim.fn.bufname(bufnr), ":p") local files = decoded["files"] local messages = {} if files["STDIN"] == nil then if files[filename] == nil then return {} end messages = files[filename]["messages"] else messages = files["STDIN"]["messages"] end -- other unmodified code end,
And customized the linter in my config to be:
local lint = require("lint") -- PHP local phpcs = lint.linters.phpcs phpcs.cmd = "vendor/bin/phpcs" phpcs.stdin = false phpcs.args = { "--report=json", "-q", }
This does work, but is this something worth submitting?
Sorry, something went wrong.
No branches or pull requests
I'm new to nvim-lint and php is not my primary language, but I noticed an inconsistency between running phpcs locally versus inside neovim.
.phpcs.xml
plugins.lua
plugins/linter.lua
Scenario 1: Inside neovim
:lua require('lint').try_lint()
onapp/test.php
, I see WordPress related errors.:lua require('lint').try_lint()
onblog/wp-config.php
, I see PSR12 related errors.Scenario 2: Running phpcs
vendor/bin/phpcs app/test.php
, I see only PSR12 related errors.vendor/bin/phpcs blog/wp-config.php
, I only see WordPress related errors.The text was updated successfully, but these errors were encountered: