stevearc / conform.nvim

Lightweight yet powerful formatter plugin for Neovim
MIT License
2.55k stars 135 forks source link

bug: npm-groovy-lint fails due to none zero exit code. #477

Closed madelaney closed 1 week ago

madelaney commented 1 week ago

Neovim version (nvim -v)

NVIM v0.10.0

Operating system/version

MacOS 14.5

Add the debug logs

Log file

Log file: /Users/mdelaney/.local/state/nvim/conform.log 19:00:48[DEBUG] Run command: { "npm-groovy-lint", "--fix", "/Users/mdelaney/work/gitlab.mldelaney.io/jenkins-ci/core-library/vars/.conform.7203466.make.groovy" } 19:00:48[DEBUG] Run default CWD: /Users/mdelaney/work/gitlab.mldelaney.io/jenkins-ci/core-library 19:00:50[INFO] npm-groovy-lint exited with code 1 19:00:50[DEBUG] npm-groovy-lint stdout: nil 19:00:50[DEBUG] npm-groovy-lint stderr: { "Failure: 0 error(s) have been found ", " 5 warning(s) have been found ", " 6 info(s) have been found", "Failure: 0 error(s) have been found ", " 5 warning(s) have been found ", " 6 info(s) have been found", "" } 19:00:50[DEBUG] Cleaning up temp file /Users/mdelaney/work/gitlab.mldelaney.io/jenkins-ci/core-library/vars/.conform.7203466.make.groovy 19:00:50[ERROR] Formatter 'npm-groovy-lint' error: Failure: 0 error(s) have been found 5 warning(s) have been found 6 info(s) have been found Failure: 0 error(s) have been found 5 warning(s) have been found 6 info(s) have been found

Formatters for this buffer: npm-groovy-lint ready (groovy) /Users/mdelaney/.local/share/nvim/mason/bin/npm-groovy-lint

Other formatters: eslint_d ready (javascript, typescriptreact, typescript, javascriptreact) /Users/mdelaney/.local/share/nvim/mason/bin/eslint_d prettierd ready (javascript, typescriptreact, typescript, javascriptreact) /Users/mdelaney/.local/share/nvim/mason/bin/prettierd stylua ready (lua) /Users/mdelaney/.local/share/nvim/mason/bin/stylua

Describe the bug

When running npm-groovy-lint, the script will exit with a non zero code if any issues are found.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. setup npm-groovy-lint within conform
  2. open a groovy file
  3. attempt to save the file.

Expected Behavior

I would expect the file to be formatted with npm-groovy-lint.

Minimal example file

def info(message) {
    echo "INFO: ${message}"
}

def warning(message) {
    echo "WARNING: ${message}"
    echo 'Hell'
}

Minimal init.lua

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    "stevearc/conform.nvim",
    config = function()
      require("conform").setup({
        log_level = vim.log.levels.DEBUG,
        -- add your config here
        formatters_by_ft = {
          groovy = { 'npm-groovy-lint' },
        }
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Additional context

I did a little testing and found that --failon=none to the args list seemed to do the trick.

---@type conform.FileFormatterConfig
return {
  meta = {
    url = "https://github.com/nvuillam/npm-groovy-lint",
    description = "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files using command line.",
  },
  command = "npm-groovy-lint",
  args = { "--failon=none", "--fix", "$FILENAME" },
  stdin = false,
}
stevearc commented 1 week ago

Should be fixed!

madelaney commented 1 week ago

Confirmed. I pulled master and the issue seems to have been resolved.