Files
.dotfiles/.config/nvim/lua/plugin/nvim-lint.lua
Quinn 3eeff04c9b use shellcheck for bash instead of sh
sh is renamed to bash for treesitter reasons.
2026-02-03 18:05:53 +01:00

51 lines
1.2 KiB
Lua

MiniDeps.add({ source = 'https://github.com/mfussenegger/nvim-lint' })
local lint = require('lint')
local linters = {
glslang = {
cmd = 'glslangValidator',
stdin = false,
args = { '-C' },
ignore_exitcode = true,
parser = function(output)
local diags = {}
for _, line in ipairs(vim.split(output, '\n')) do
local f, lnum, sev, msg = line:match(
'^([^:]+):(%d+):%s+([^:]+):%s+(.+)$') -- file:line: severity: message
if not f then
sev, f, lnum, msg = line:match(
'^(%w+):%s+([^:]+):(%d+):%s+(.+)$')
end -- severity: file:line: message
if lnum then
local s = sev:lower() == 'error'
and vim.diagnostic.severity.ERROR
or vim.diagnostic.severity.WARN
table.insert(diags, {
lnum = tonumber(lnum) - 1,
col = 0,
message = msg,
source = 'glslang',
severity = s
})
end
end
return diags
end
}
}
lint.linters_by_ft = {
bash = { 'shellcheck' },
glsl = { 'glslang' },
}
for name, linter in pairs(linters) do
lint.linters[name] = linter
end
-- autocommand for linting
Autocmd({ 'BufWritePost', 'BufWinEnter', 'TextChanged' },
{ callback = function() lint.try_lint() end });