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 error being written to buffer #548

Open
2 tasks done
Ajaymamtora opened this issue Oct 14, 2024 · 0 comments
Open
2 tasks done

bug: prettier error being written to buffer #548

Ajaymamtora opened this issue Oct 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Ajaymamtora
Copy link

Neovim version (nvim -v)

0.10.2

Operating system/version

macos 15

Read debugging tips

Add the debug logs

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

Log file

... filepath
[error] 1 |
[error] > 2 | <input css 1>
[error] | ^
[error] 3 | 13:5 ✖ Unknown word CssSyntaxError
[error] 4 |
[error] 5 | 1 problem (1 error, 0 warnings)

Describe the bug

When theres a syntax error, the error gets written to the buffer despite the exit code being 2 and me specifying 0,1.

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

open this as scss

nav {
ul {
margin: 0;
padding: 0;
list-style: none;
}

li { display: inline-block; }

a {
display: block;
padding: 6px 12px;
text-decoration: none;
}
}

then delete a bracket. Then try to format, the error gets written into the buffer

Expected Behavior

It should not modify the buffer because the exit code was 2.

Minimal example file

      prettier = {
        command = format_utils.from_node_modules("prettier"),
        args = function(self, ctx)
          local args = { "--stdin-filepath", "$FILENAME" }

          -- Get the current buffer's shiftwidth
          local shiftwidth = vim.bo.shiftwidth

          -- Determine if tabs or spaces are being used
          local use_tabs = vim.bo.expandtab == false

          -- Add indentation options
          table.insert(args, "--use-tabs")
          table.insert(args, tostring(use_tabs))
          table.insert(args, "--tab-width")
          table.insert(args, tostring(shiftwidth))

          -- Add config path if specified
          local config_path = format_utils.find_config_file("prettier", prettier_config_patterns, ctx)
          if config_path then
            table.insert(args, "--config")
            table.insert(args, config_path)
          end

          return args
        end,
        stdin = true,
        exit_codes = { 0, 1 },
        cwd = function()
          return file_utils.find_closest_node_modules_to_current_file()
        end,
        condition = function(_, ctx)
          return format_utils.formatter_condition("prettier", prettier_config_patterns, ctx)
        end,
      },

Minimal init.lua

No response

Additional context

No response

@Ajaymamtora Ajaymamtora added the bug Something isn't working label Oct 14, 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
Projects
None yet
Development

No branches or pull requests

1 participant