Browse Source

fix: formatting n stuff

master
Tovi Jaeschke-Rogers 8 months ago
parent
commit
f1a8b7cf3a
4 changed files with 85 additions and 0 deletions
  1. +4
    -0
      .config/nvim/lua/tovi/plugins/formatting.lua
  2. +46
    -0
      .config/nvim/lua/tovi/plugins/linting.lua
  3. +33
    -0
      .config/phpcs.xml
  4. +2
    -0
      .zshrc

+ 4
- 0
.config/nvim/lua/tovi/plugins/formatting.lua View File

@ -39,5 +39,9 @@ return {
timeout_ms = 500, timeout_ms = 500,
}) })
end) end)
conform.formatters.phpcbf = {
prepend_args = { "--standard=~/.config/phpcs.xml" }
}
end, end,
} }

+ 46
- 0
.config/nvim/lua/tovi/plugins/linting.lua View File

@ -4,10 +4,56 @@ return {
config = function() config = function()
local lint = require("lint") local lint = require("lint")
local severities = {
ERROR = vim.diagnostic.severity.ERROR,
WARNING = vim.diagnostic.severity.WARN,
}
lint.linters.ecs = { lint.linters.ecs = {
cmd = "ecs", cmd = "ecs",
} }
lint.linters.phpcs = {
cmd = 'phpcs',
stdin = true,
args = {
'-q',
'--report=json',
'--standard=~/.config/phpcs.xml',
'-', -- need `-` at the end for stdin support
},
ignore_exitcode = true,
parser = function(output, _)
if vim.trim(output) == '' or output == nil then
return {}
end
if not vim.startswith(output,'{') then
vim.notify(output)
return {}
end
local decoded = vim.json.decode(output)
local diagnostics = {}
local messages = decoded['files']['STDIN']['messages']
for _, msg in ipairs(messages or {}) do
table.insert(diagnostics, {
lnum = msg.line - 1,
end_lnum = msg.line - 1,
col = msg.column - 1,
end_col = msg.column - 1,
message = msg.message,
code = msg.source,
source = 'phpcs',
severity = assert(severities[msg.type], 'missing mapping for severity ' .. msg.type),
})
end
return diagnostics
end
}
lint.linters_by_ft = { lint.linters_by_ft = {
javascript = { "eslint" }, javascript = { "eslint" },
typescript = { "eslint" }, typescript = { "eslint" },


+ 33
- 0
.config/phpcs.xml View File

@ -0,0 +1,33 @@
<?xml version="1.0"?>
<ruleset>
<file>app</file>
<file>config</file>
<file>public</file>
<file>resources</file>
<file>routes</file>
<file>tests</file>
<exclude-pattern>*/database/*</exclude-pattern>
<exclude-pattern>*/cache/*</exclude-pattern>
<exclude-pattern>*/*.js</exclude-pattern>
<exclude-pattern>*/*.css</exclude-pattern>
<exclude-pattern>*/*.xml</exclude-pattern>
<exclude-pattern>*/*.blade.php</exclude-pattern>
<exclude-pattern>*/autoload.php</exclude-pattern>
<exclude-pattern>*/storage/*</exclude-pattern>
<exclude-pattern>*/docs/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>*/migrations/*</exclude-pattern>
<arg name="report" value="full"/>
<arg name="colors"/>
<arg value="p"/>
<arg value="n"/>
<ini name="memory_limit" value="512M"/>
<rule ref="PSR12">
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.SpacingAfterOpenBrace"/>
<exclude name="Generic.Files.LineLength"/>
</rule>
</ruleset>

+ 2
- 0
.zshrc View File

@ -224,3 +224,5 @@ export FNM_LOGLEVEL="info"
export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist" export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist"
export FNM_ARCH="x64" export FNM_ARCH="x64"
rehash rehash
export PHPCS_STANDARD=~/.config/phpcs.xml

Loading…
Cancel
Save