-
Notifications
You must be signed in to change notification settings - Fork 177
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: Formatter not respecting prettier.config.js
file
#618
Comments
Can you follow the steps in debugging tips to discover:
|
I have enabled the log_level but there is still no entry in the file. It is completely empty. return { -- Autoformat
'stevearc/conform.nvim',
lazy = false,
keys = {
{
'<leader>tf',
function()
require('conform').format { async = true, lsp_fallback = true }
end,
mode = '',
desc = '[F]ormat buffer',
},
},
log_level = vim.log.levels.DEBUG,
opts = {
notify_on_error = true,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { sql = true }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
stop_after_first = true,
formatters_by_ft = {
lua = { 'stylua' },
html = { 'prettierd' },
javascript = { 'prettierd' },
typescript = { 'prettierd' },
typescriptreact = { 'prettierd' },
javascriptreact = { 'prettierd' },
},
},
} When I run in my cmd ▶ npx prettier . --write --config prettier.config.js It is formating my files. |
can confirm. same issue happening for me. |
Okay looking closer, your config is all over the place. The options aren't in the right place at all. Try this minimal init and see if that produces logging output -- 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",
lazy = false,
keys = {
{
"<leader>tf",
function() require("conform").format({ async = true, lsp_fallback = true }) end,
mode = "",
desc = "[F]ormat buffer",
},
},
config = function()
require("conform").setup({
log_level = vim.log.levels.DEBUG,
notify_on_error = true,
format_on_save = function(bufnr)
-- Disable "format_on_save lsp_fallback" for languages that don't
-- have a well standardized coding style. You can add additional
-- languages here or re-enable it for the disabled ones.
local disable_filetypes = { sql = true }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
}
end,
formatters_by_ft = {
lua = { "stylua" },
html = { "prettierd" },
javascript = { "prettierd" },
typescript = { "prettierd" },
typescriptreact = { "prettierd" },
javascriptreact = { "prettierd" },
},
})
end,
},
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd.colorscheme("tokyonight") |
Good Morning. Yes this produces output for me. 2025-01-06 08:21:41[DEBUG] Running formatters on /Users/davidschluter/personal/fullstack/WorkChrono/frontend/prettier.config.js: { "prettierd" }
2025-01-06 08:21:41[INFO] Run prettierd on /Users/davidschluter/personal/fullstack/WorkChrono/frontend/prettier.config.js
2025-01-06 08:21:41[DEBUG] Run command: { "/Users/davidschluter/.local/share/nvim/mason/bin/prettierd", "/Users/davidschluter/personal/fullstack/WorkChrono/frontend/prettier.config.js" }
2025-01-06 08:21:41[DEBUG] Run CWD: /Users/davidschluter/personal/fullstack/WorkChrono/frontend
2025-01-06 08:21:41[DEBUG] prettierd exited with code 0 |
I recall this happening before and this was the fix |
The output looks good to me. Do you still have an issue with the prettier-plugin-tailwindcss using the conform, but don't see the issue running the prettier manually? Or the issue can be closed? |
I am using LazyVim with TS and Prettier properly configured (this setup has been working and recently stopped). Here's what my log looks like:
|
@ro0gr The bug is still present. The output looks right I Agree, but the formatter is not doing anything (at least the indentation is not working correctly when switching between Edit: Also the Quotes are not working for me. |
For me it also worked Fine for months. Recently I updated my Plugins and then it stopped working. |
@Maduki-tech the command line invocation that you have that formats the files correctly uses npx and prettier, while the conform formatter using prettierd installed with mason. Can you either reconfigure conform to use the package-local prettier command or try running the mason-installed prettierd command in the terminal? |
Hey, good you saw this. I think now, that I started to use prettier with my local path.
Changed this in my config formatters_by_ft = {
lua = { 'stylua' },
html = { 'prettier' },
javascript = { 'prettier' },
typescript = { 'prettier' },
typescriptreact = { 'prettier' },
javascriptreact = { 'prettier' },
}, |
Seems like you can not use useTabs and tab width at the same time. Removing useTabs gained me the control over everything..... Sorry for time waste! |
Neovim version (nvim -v)
NVIM v0.11.0-dev-1422+g35247b00a4 Build type: RelWithDebInfo LuaJIT 2.1.1734355927
Operating system/version
MacOS 15.2
Read debugging tips
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
No error here in the Debug for me.
Describe the bug
I have my basic NextJS application.
npx create-next-app@latest
Then i added my default
prettier.config.js
file.When I run my format command, is is not respecting this file.
What is the severity of this bug?
minor (annoyance)
Steps To Reproduce
Expected Behavior
To format the files based on the provided configuration in the directory
Minimal example file
You can use this file, it is already in js.
Minimal init.lua
Additional context
No response
The text was updated successfully, but these errors were encountered: