mattn / efm-langserver

General purpose Language Server
MIT License
1.36k stars 61 forks source link

prettier: formatter is executed even if rootMarkers have no match #279

Open gpayer opened 3 months ago

gpayer commented 3 months ago

I'm using the configuration for prettier from efmls-config for javascript and it seems to be enough that prettier is installed in node_modules for the formatter to run.

The expected behaviour is that the prettier formatter should not run.

How to reproduce

  1. have efm configured for javascript with javascript = { require('efmls-configs.formatters.prettier') }
  2. create a small badly configured file, test.js for example
  3. save the file, it will be formatted
tristan957 commented 3 months ago

This is an efmls-configs issue, right?

gpayer commented 3 months ago

No, you can simply replace it with

javascript = {
  formatCanRange = true,
  formatCommand = command,
  formatStdin = true,
  rootMarkers = {
    '.prettierrc',
    '.prettierrc.json',
    '.prettierrc.js',
    '.prettierrc.yml',
    '.prettierrc.yaml',
    '.prettierrc.json5',
    '.prettierrc.mjs',
    '.prettierrc.cjs',
    '.prettierrc.toml',
    'prettier.config.js',
    'prettier.config.cjs',
    'prettier.config.mjs',
  },
}

Just use the correct call for prettier, i.e. fill command with something that works.

But that part works! What does not work is that rootMarkers are ignored, and the formatter is executed for every save on every javascript file.