Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: prettierd formatter does not show error message #486

Closed
1 task done
powerman opened this issue Jul 3, 2024 · 2 comments
Closed
1 task done

bug: prettierd formatter does not show error message #486

powerman opened this issue Jul 3, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@powerman
Copy link

powerman commented Jul 3, 2024

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

@powerman
Copy link
Author

powerman commented Jul 3, 2024

@stevearc
Copy link
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
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants