Formatted code not found. You may need to change the stdin setting of prettier.
Closed this issue · 0 comments
pauchiner commented
Which configuration?
Type (custom or builtin): builtin
Filetype: javascript
Formatter: prettier
Expected behavior
When writing to an empty buffer the formatter should not throw any errors, like in this issue #281
Actual behaviour
The formatter throws this error on save an empty buffer
Additional context
My config looks like that
return {
'mhartington/formatter.nvim',
name = "Formatter",
cond = ChinerNvim.plugins.prettier.enabled,
event = "BufEnter *.html,*.css,*.json,*.js,*.jsx,*.ts,*.tsx",
config = function ()
require("formatter").setup {
filetype = {
html = {
require("formatter.filetypes.html").prettier,
},
css = {
require("formatter.filetypes.css").prettier,
},
json = {
require("formatter.filetypes.json").prettier,
},
javascript = {
require("formatter.filetypes.javascript").prettier,
},
javascriptreact = {
require("formatter.filetypes.javascriptreact").prettier,
},
typescript = {
require("formatter.filetypes.typescript").prettier,
},
typescriptreact = {
require("formatter.filetypes.typescriptreact").prettier,
},
},
}
if (ChinerNvim.plugins.prettier.formatOnSave) then
vim.api.nvim_create_autocmd({"BufWritePost"}, {
pattern = {"*.html", "*.css", "*.json", "*.js", "*.jsx", "*.ts", "*.tsx"},
callback = function ()
--- Return if the document is wrong
if (#vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR }) > 0) then return end
vim.cmd[[FormatWriteLock]]
end,
})
end
end
}