mhartington/formatter.nvim

Failed to run formatter sed

supeep opened this issue · 3 comments

supeep commented

I am using the Windows 10 system, Neovim version 0.9.0. After installing and configuring formatter.nvim, I used the ': Format' command in the '. c' file and generated an error warning without formatting the file.

I have installed sed by scoop
image

Here is my formatter configuration file
Add:I realize that I used the wrong method name. .c should use astyle .java should use clangformat
97F4AE4F68AC3E558F34D3A45ABC2EA9

Here is the error message.
"Failed to run formatter sed ... : -e expression #1, char 1: unknown command: `''^M"
image

supeep commented

I'm sorry, I successfully formatted the .c file by changing from stylua to astyle, although it still reports the same error after formatting.
My configure is:

-- Utilities for creating configurations
local util = require "formatter.util"

-- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands
require("formatter").setup {
  -- Enable or disable logging
  logging = true,
  -- Set the log level
  log_level = vim.log.levels.WARN,
  -- All formatter configurations are opt-in
  filetype = {
    -- Formatter configurations for filetype "lua" go here
    -- and will be executed in order
    lua = {
      -- "formatter.filetypes.lua" defines default configurations for the
      -- "lua" filetype
      require("formatter.filetypes.lua").stylua,

    },

    c = {
      require("formatter.filetypes.c").astyle ,
    },

    java = {
      require("formatter.filetypes.java").clangformat,
    },

    -- Use the special "*" filetype for defining formatter configurations on
    -- any filetype
    ["*"] = {
      -- "formatter.filetypes.any" defines default configurations for any
      -- filetype
      require("formatter.filetypes.any").remove_trailing_whitespace
    }
  }
}
robamu commented

I have the same issue on Windows 11.