Skip to content

Commit

Permalink
feat(nvim-lint): add PMD and thus remove none-ls
Browse files Browse the repository at this point in the history
  • Loading branch information
kmoschcau committed Jan 4, 2025
1 parent 815429a commit 5da733c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 106 deletions.
3 changes: 0 additions & 3 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,12 @@
"markdown.nvim": { "branch": "master", "commit": "dfa0d2def6dbf77e9206b16dc90cad4dd23d55d2" },
"mason-conform.nvim": { "branch": "main", "commit": "abce2be529f3b4b336c56d0ba6336a9144e0fee6" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" },
"mason-null-ls.nvim": { "branch": "main", "commit": "de19726de7260c68d94691afb057fa73d3cc53e7" },
"mason-nvim-dap.nvim": { "branch": "main", "commit": "8b9363d83b5d779813cdd2819b8308651cec2a09" },
"mason-nvim-lint": { "branch": "main", "commit": "910dadb99cb2bf0d5176026c7a4ab1861c4e561f" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.nvim": { "branch": "main", "commit": "546b9c8bd8ebba594bd18811e54bd3e6f9a662ec" },
"muren.nvim": { "branch": "main", "commit": "818c09097dba1322b2ca099e35f7471feccfef93" },
"neoconf.nvim": { "branch": "main", "commit": "1e6c856d062b92ef201b35e0a4fc798331750118" },
"none-ls.nvim": { "branch": "main", "commit": "00421b9dc7a4d132ca74cfb4c7e8030d05d6fd0b" },
"nvim-autopairs": { "branch": "master", "commit": "b464658e9b880f463b9f7e6ccddd93fb0013f559" },
"nvim-cmp": { "branch": "main", "commit": "b555203ce4bd7ff6192e759af3362f9d217e8c89" },
"nvim-config-local": { "branch": "main", "commit": "83bb6d9881653a5cf8b489ba8a6fe5a06049a10a" },
Expand All @@ -49,7 +47,6 @@
"nvim-highlight-colors": { "branch": "main", "commit": "68a4df620cf58e2c7336e53738e8cf3a522ad694" },
"nvim-jdtls": { "branch": "master", "commit": "266d0cb912bbe61d66b43c5e73db19a364380360" },
"nvim-lightbulb": { "branch": "master", "commit": "3ac0791be37ba9cc7939f1ad90ebc5e75abf4eea" },
"nvim-lint": { "branch": "master", "commit": "1fea92f1d9908eaa5eb8bafe08b4293d7aadaa55" },
"nvim-lspconfig": { "branch": "master", "commit": "f4ed656e876e45cf914d7beb972830561178e232" },
"nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,20 @@
local checkstyle_default_config = "/google_checks.xml"

local pmd_default_dir = "$ROOT"
local pmd_default_rulesets = "category/java/bestpractices.xml"
local pmd_default_rulesets = "rulesets/java/quickstart.xml"

return {
defaults = {
--- Java specific options
java = {
--- Checkstyle options
checkstyle = {
--- Whether to use file or project wide linting
file = false,
--- The file name for the config file XML
config = checkstyle_default_config,
--- @type string | nil Additional options for checkstyle
options = nil,
},
--- PMD options
pmd = {
--- The run directory for PMD
dir = pmd_default_dir,
--- The rulesets for PMD, comma-separated
rulesets = pmd_default_rulesets,
--- @type string | nil The cache file path, if used
Expand All @@ -38,11 +33,6 @@ return {
description = "Checkstyle options",
additionalProperties = false,
properties = {
file = {
type = "boolean",
description = "Whether to use file or project wide linting",
default = false,
},
config = {
type = { "string" },
description = "The file name for the config file XML",
Expand All @@ -59,14 +49,9 @@ return {
description = "PMD options",
additionalProperties = false,
properties = {
dir = {
type = { "string" },
description = "The run directory for PMD",
default = pmd_default_dir,
},
rulesets = {
type = { "string" },
description = "The rulesets for PMD",
description = "The rulesets for PMD, comma-separated",
default = pmd_default_rulesets,
},
cache = {
Expand Down
16 changes: 0 additions & 16 deletions lua/plugin-management/plugins/mason-null-ls-nvim.lua

This file was deleted.

6 changes: 3 additions & 3 deletions lua/plugin-management/plugins/neoconf-nvim.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ return {
require("neoconf.plugins").register {
name = "none_ls",
on_schema = function(schema)
local none_ls = require "neoconf-schemas.none-ls"
schema:import("none_ls", none_ls.defaults)
schema:set("none_ls.java", none_ls.schema)
local linters = require "neoconf-schemas.linters"
schema:import("linters", linters.defaults)
schema:set("linters.java", linters.schema)
end,
}
end,
Expand Down
54 changes: 0 additions & 54 deletions lua/plugin-management/plugins/none-ls-nvim.lua

This file was deleted.

34 changes: 21 additions & 13 deletions lua/plugin-management/plugins/nvim-lint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ local function do_lint(event_args)
event_args.event,
vim.inspect(names)
),
vim.log.levels.INFO,
vim.log.levels.DEBUG,
{
title = "nvim-lint",
}
Expand All @@ -136,7 +136,7 @@ return {
local linters_by_ft = {
fish = { "fish" },
html = { "markuplint" },
java = { "checkstyle" },
java = { "checkstyle", "pmd" },
json = { "cfn_lint" },
kotlin = { "ktlint" },
lua = { "selene" },
Expand All @@ -151,28 +151,33 @@ return {

local config = require("neoconf").get(
"none_ls",
require("neoconf-schemas.none-ls").defaults
require("neoconf-schemas.linters").defaults
)

local checkstyle_config = config.java.checkstyle

local checkstyle_args = {}

if checkstyle_config.file then
table.insert(checkstyle_args, "$FILENAME")
else
table.insert(checkstyle_args, "$ROOT")
end

table.insert(checkstyle_args, "-c")
table.insert(checkstyle_args, checkstyle_config.config)
local checkstyle_args = { "-f", "sarif", "-c", checkstyle_config.config }

if checkstyle_config.options then
for _, arg in ipairs(vim.fn.split(checkstyle_config.options)) do
table.insert(checkstyle_args, arg)
end
end

local pmd_config = config.java.pmd

local pmd_args =
{ "check", "--format", "json", "--rulesets", pmd_config.rulesets }

if pmd_config.cache then
table.insert(pmd_args, "--cache")
table.insert(pmd_args, pmd_config.cache)
else
table.insert(pmd_args, "--no-cache")
end

table.insert(pmd_args, "--dir")

---@type table<string, lint.LinterOverrideConfig>
local linter_overrides = {
actionlint = {
Expand Down Expand Up @@ -211,6 +216,9 @@ return {
end),
ignore_exitcode = true,
},
pmd = {
args = pmd_args,
},
selene = {
condition = cache.by_bufnr(function(event_args)
return #vim.fs.find("selene.toml", {
Expand Down

0 comments on commit 5da733c

Please sign in to comment.