Skip to content

bug: prettierd formatter does not show error message #486

Description

@powerman

Neovim version (nvim -v)

v0.10.0

Operating system/version

Gentoo Linux

Add the debug logs

  • I have set log_level = vim.log.levels.DEBUG and pasted the log contents below.

Log file

Without DEBUG log level:

04:03:52[ERROR] Formatter 'prettierd' error:

With DEBUG log level:

04:05:21[DEBUG] Running formatters on /home/powerman/tmp/bug-nvim-conform-prettierd/test.html: { "prettierd" }
04:05:21[INFO] Run prettierd on /home/powerman/tmp/bug-nvim-conform-prettierd/test.html
04:05:21[DEBUG] Run command: { "/home/powerman/node_modules/.bin/prettierd", "/home/powerman/tmp/bug-nvim-conform-prettierd/test.html" }
04:05:21[DEBUG] Run CWD: /home/powerman
04:05:21[INFO] prettierd exited with code 1
04:05:21[DEBUG] prettierd stdout: { 'SyntaxError: Unexpected closing tag "p". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (1:15)', "\27[0m\27[31m\27[1m>\27[22m\27[39m\27[90m 1 |\27[39m \27[33m<\27[39m\27[33mp\27[39m\27[33m>\27[39m\27[33m<\27[39m\27[33mpre\27[39m\27[33m>\27[39m\27[33m<\27[39m\27[33m/\27[39m\27[33mpre\27[39m\27[33m>\27[39m\27[33m<\27[39m\27[33m/\27[39m\27[33mp\27[39m\27[33m>\27[39m", " \27[90m   |\27[39m               \27[31m\27[1m^\27[22m\27[39m\27[31m\27[1m^\27[22m\27[39m\27[31m\27[1m^\27[22m\27[39m\27[31m\27[1m^\27[22m\27[39m", " \27[90m 2 |\27[39m\27[0m", "" }
04:05:21[DEBUG] prettierd stderr: { "" }
04:05:21[ERROR] Formatter 'prettierd' error: 

Describe the bug

Without DEBUG log level :ConformInfo does not show actual error message:
изображение

As it became clear from log with DEBUG log level the real problem is prettierd output error to STDOUT instead of STDERR plus use colored output.
изображение

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. Create file test.html with content provided below.
  2. nvim -u repro.lua test.html
  3. :lua require('conform').format()
  4. :ConformInfo
  5. With DEBUG log level you'll see error message but it'll be unreadable, without DEBUG there will be no error message at all.

Expected Behavior

prettierd error should be included in :ConformInfo output with ERROR log level and without terminal escape-sequences.

Minimal example file

<p><pre></pre></p>

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 = {
            html = { "prettierd" },
        },
      })
    end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

Additional context

No response

Activity

  1. powerman commented on Jul 3, 2024

    @powerman
    Author
  2. stevearc commented on Jul 16, 2024

    @stevearc
    Owner

    We should correctly grab the stdout and display that as the error now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions