stevearc / conform.nvim

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

bug: prettier's `printWidth` setting ignored #483

Open rafaelrinaldi opened 6 days ago

rafaelrinaldi commented 6 days ago

Neovim version (nvim -v)

v0.10.0

Operating system/version

macOS Sonoma 14.5

Add the debug logs

Log file

Log file: /Users/rinaldi/.local/state/nvim/conform.log Formatters for this buffer: LSP: eslint, vtsls prettier ready (html, javascript, jsonc, markdown.mdx, typescriptreact, typescript, graphql, handlebars, less, scss, json, yaml, javascriptreact, css, vue, markdown) /Users/rinaldi/work/web-react/node_modules/.bin/prettier

Other formatters: fish_indent ready (fish) /opt/homebrew/bin/fish_indent shfmt ready (sh) /Users/rinaldi/.local/share/nvim/mason/bin/shfmt stylua ready (lua) /Users/rinaldi/.local/share/nvim/mason/bin/stylua

Describe the bug

I would expect conform to respect Prettier's printWidth setting which automatically would wrap the code/text given a max width/length, but it doesn't somehow.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

mkdir test # create a test dir
cd test # cd into it
echo "{"printWidth": 50}" > .prettierrc # create a prettier config setting max width to 50
echo "{"private": true}" > package.json # startup npm
npm i prettier -D # install prettier under `devDependencies`
nvim index.js # open a javascript file in nvim

Just start typing until the text is longer than 50 characters and run the formatter.

Expected Behavior

On format the printWidth setting should be respected.

Minimal example file

No response

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
      })
    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