diff --git a/lazy-lock.json b/lazy-lock.json index 0a729172..c07af096 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -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" }, @@ -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" }, diff --git a/lua/neoconf-schemas/none-ls.lua b/lua/neoconf-schemas/linters.lua similarity index 73% rename from lua/neoconf-schemas/none-ls.lua rename to lua/neoconf-schemas/linters.lua index 183e3f5d..4ed776fd 100644 --- a/lua/neoconf-schemas/none-ls.lua +++ b/lua/neoconf-schemas/linters.lua @@ -1,7 +1,6 @@ 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 = { @@ -9,8 +8,6 @@ return { 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 @@ -18,8 +15,6 @@ return { }, --- 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 @@ -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", @@ -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 = { diff --git a/lua/plugin-management/plugins/mason-null-ls-nvim.lua b/lua/plugin-management/plugins/mason-null-ls-nvim.lua deleted file mode 100644 index 46abf6ec..00000000 --- a/lua/plugin-management/plugins/mason-null-ls-nvim.lua +++ /dev/null @@ -1,16 +0,0 @@ --- selene: allow(mixed_table) ---- @type LazyPluginSpec -return { - "jay-babu/mason-null-ls.nvim", - dependencies = { - "nvimtools/none-ls.nvim", - "williamboman/mason.nvim", - }, - -- @type MasonNullLsSettings -- Does not work well, no optional fields - opts = { - automatic_installation = { - -- mason version has issues with GLIBC missing, use cargo - exclude = { "selene" }, - }, - }, -} diff --git a/lua/plugin-management/plugins/neoconf-nvim.lua b/lua/plugin-management/plugins/neoconf-nvim.lua index c88ccc02..fe4d23cf 100644 --- a/lua/plugin-management/plugins/neoconf-nvim.lua +++ b/lua/plugin-management/plugins/neoconf-nvim.lua @@ -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, diff --git a/lua/plugin-management/plugins/none-ls-nvim.lua b/lua/plugin-management/plugins/none-ls-nvim.lua deleted file mode 100644 index af751bd3..00000000 --- a/lua/plugin-management/plugins/none-ls-nvim.lua +++ /dev/null @@ -1,54 +0,0 @@ --- selene: allow(mixed_table) ---- @type LazyPluginSpec -return { - "nvimtools/none-ls.nvim", - dependencies = { - "folke/neoconf.nvim", - "nvim-lua/plenary.nvim", - }, - config = function() - local none_ls = require "null-ls" - local diagnostics = none_ls.builtins.diagnostics - - local config = require("neoconf").get( - "none_ls", - require("neoconf-schemas.none-ls").defaults - ) - - --- Build the extra arguments for PMD - --- @return string[] - local function build_pmd_extra_args() - local pmd_config = config.java.pmd - - local args = {} - - table.insert(args, "--dir") - table.insert(args, pmd_config.dir) - - table.insert(args, "--rulesets") - table.insert(args, pmd_config.rulesets) - - if pmd_config.cache then - table.insert(args, "--cache") - table.insert(args, pmd_config.cache) - else - table.insert(args, "--no-cache") - end - - return args - end - - local sources = { - diagnostics.pmd.with { - args = { "--format", "json" }, - extra_args = build_pmd_extra_args, - timeout = -1, - }, - } - - none_ls.setup { - border = "rounded", - sources = sources, - } - end, -} diff --git a/lua/plugin-management/plugins/nvim-lint.lua b/lua/plugin-management/plugins/nvim-lint.lua index e4373595..17a525eb 100644 --- a/lua/plugin-management/plugins/nvim-lint.lua +++ b/lua/plugin-management/plugins/nvim-lint.lua @@ -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", } @@ -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" }, @@ -151,21 +151,12 @@ 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 @@ -173,6 +164,20 @@ return { 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 local linter_overrides = { actionlint = { @@ -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", {