Skip to content

bug: formatter fails on paths with parentheses e.g. Next.js route groups (public) #867

@HiRahmatDev

Description

@HiRahmatDev

Neovim version (nvim -v)

NVIM v0.12.0

Operating system/version

Windows 11 (without WSL)

Read debugging tips

Add the debug logs

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

Log file

Working (path without parentheses):

[DEBUG] Running formatters on C:/Users/.../src/app/error.tsx: { "prettier" }
[DEBUG] Run command: { "prettier.cmd", "--stdin-filepath", "C:/Users/.../src/app/error.tsx" }
[DEBUG] prettier exited with code 0

Failing (path with parentheses):

[DEBUG] Running formatters on C:/Users/.../src/app/(public)/download-app/page.tsx: { "prettier" }
[DEBUG] Run command: { "prettier.cmd", "--stdin-filepath", "C:/Users/.../src/app/(public)/download-app/page.tsx" }
[INFO] prettier exited with code 255
[DEBUG] prettier stdout: { '...> "node.exe" "prettier.cjs" --stdin-filepath C:/.../(public)/download-app/page.tsx' }
[DEBUG] prettier stderr: { "/download-app/page.tsx was unexpected at this time." }
[ERROR] Formatter 'prettier' error: /download-app/page.tsx was unexpected at this time.

Describe the bug

On Windows, conform.nvim fails to format files when the file path contains parentheses ( ).
This is a common scenario in Next.js App Router projects which use route groups, e.g. src/app/(public)/page.tsx.

The root cause is that conform.nvim spawns .cmd files directly (e.g. prettier.cmd).
Windows CMD treats ( and ) as reserved characters for group expressions (used in if, for, etc.).
When CMD encounters a path like (public) inside a .cmd execution chain, it misparses it as a group expression instead of a plain string — causing the formatter to fail.

What is the severity of this bug?

tolerable (can work around it)

Steps To Reproduce

  1. Use Windows without WSL
  2. Open a Next.js project that uses route groups, e.g. src/app/(public)/page.tsx
  3. Trigger conform.nvim formatter (e.g. Prettier) on any file inside a route group folder
  4. Formatter fails with exit code 255

Expected Behavior

Conform should handle Windows paths with special characters like ( ) correctly,
either by routing through PowerShell instead of CMD, or by properly escaping arguments before passing them to .cmd executables.

Minimal example file

File path:

src/app/(public)/download-app/page.tsx

File content:

export default function DownloadAppPage() {
  return <div>Download App</div>
}

Minimal init.lua

-- PLUGINS
--
-- See `:h :packadd`, `:h vim.pack`

-- Install third-party plugins via "vim.pack.add()".
vim.pack.add({
  -- LSP
  'https://github.com/neovim/nvim-lspconfig',
  'https://github.com/mason-org/mason.nvim',

  -- Formatter
  'https://github.com/stevearc/conform.nvim',
})

require('conform').setup({
  log_level = vim.log.levels.DEBUG,
  formatters_by_ft = {
    lua = { 'stylua' },
    json = { 'prettier' },
    html = { 'prettier' },
    css = { 'prettier' },
    javascript = { 'prettier' },
    javascriptreact = { 'prettier' },
    typescript = { 'prettier' },
    typescriptreact = { 'prettier' },
  }
})

vim.keymap.set({ 'n' }, ';f', require('conform').format)

Additional context

  • This issue likely affects all Node.js-based formatters that use .cmd wrappers on Windows (e.g. eslint_d, biome, etc.)
  • Native .exe formatters like stylua are not affected
  • This does not affect Windows with WSL

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions