Skip to content
This repository has been archived by the owner on Aug 12, 2023. It is now read-only.

Commit

Permalink
feat(diagnostics): add cmake_lint to go alongside cmake_format
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchallain committed Sep 4, 2022
1 parent 7cd491b commit af8a891
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lua/null-ls/builtins/_meta/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ return {
clj_kondo = {
filetypes = { "clojure" }
},
cmake_lint = {
filetypes = { "cmake" }
},
codespell = {
filetypes = {}
},
Expand Down
2 changes: 1 addition & 1 deletion lua/null-ls/builtins/_meta/filetype_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ return {
formatting = { "cljstyle", "zprint" }
},
cmake = {
formatting = { "cmake_format", "gersemi" }
formatting = { "cmake_format", "cmake_lint", "gersemi" }
},
cpp = {
diagnostics = { "cppcheck", "gccdiag" },
Expand Down
38 changes: 38 additions & 0 deletions lua/null-ls/builtins/diagnostics/cmake_lint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")

local DIAGNOSTICS = methods.internal.DIAGNOSTICS

return h.make_builtin({
name = "cmake_lint",
meta = {
url = "https://github.com/cheshirekow/cmake_format",
description = "Check cmake listfiles for style violations, common mistakes, and anti-patterns.",
},
method = DIAGNOSTICS,
filetypes = { "cmake" },
generator_opts = {
command = "cmake-lint",
args = {
"$FILENAME",
},
format = "line",
to_stdin = false,
from_stderr = true,
on_output = h.diagnostics.from_pattern(
[[(%d+),(%d+): %[((%w)[%d]+)%] (.+)]],
{ "row", "col", "code", "severity", "message" },
{
severities = {
E = h.diagnostics.severities["error"],
W = h.diagnostics.severities["warning"],
C = h.diagnostics.severities["information"],
R = h.diagnostics.severities["information"],
I = h.diagnostics.severities["information"],
},
offsets = { col = 1 },
}
),
},
factory = h.generator_factory,
})
3 changes: 3 additions & 0 deletions lua/null-ls/builtins/diagnostics/luacheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ return h.make_builtin({
severities = {
E = h.diagnostics.severities["error"],
W = h.diagnostics.severities["warning"],
C = h.diagnostics.severities["information"],
R = h.diagnostics.severities["information"],
I = h.diagnostics.severities["information"],
},
offsets = { end_col = 1 },
}
Expand Down

0 comments on commit af8a891

Please sign in to comment.