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: prettier's printWidth setting ignored #483

Open
1 task done
rafaelrinaldi opened this issue Jun 30, 2024 · 1 comment
Open
1 task done

bug: prettier's printWidth setting ignored #483

rafaelrinaldi opened this issue Jun 30, 2024 · 1 comment
Labels
bug Something isn't working question Further information is requested

Comments

@rafaelrinaldi
Copy link

Neovim version (nvim -v)

v0.10.0

Operating system/version

macOS Sonoma 14.5

Add the debug logs

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

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

@rafaelrinaldi rafaelrinaldi added the bug Something isn't working label Jun 30, 2024
@stevearc
Copy link
Owner

It looks like you have pasted some of the contents of :ConformInfo, but there are no actual logs. The logs are important because they will display what command was actually being run. You should find the prettier command that conform is issuing and try running it directly yourself on the command line. Usually this helps narrow down the cause of the problem.

@stevearc stevearc added the question Further information is requested label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants