biomejs / biome

A toolchain for web projects, aimed to provide functionalities to maintain them. Biome offers formatter and linter, usable via CLI and LSP.
https://biomejs.dev
Apache License 2.0
14.95k stars 464 forks source link

🐛 `biome lsp-proxy --config-path xxx` does not work during formatting #504

Closed xulongwu4 closed 11 months ago

xulongwu4 commented 1 year ago

Environment information

 biome rage
CLI:
  Version:                      0.0.0
  Color support:                true

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_LOG_DIR:                unset
  NO_COLOR:                     unset
  TERM:                         "alacritty"
  JS_RUNTIME_VERSION:           unset
  JS_RUNTIME_NAME:              unset
  NODE_PACKAGE_MANAGER:         unset

Biome Configuration:
  Status:                       unset

Workspace:
  Open Documents:               0

Discovering running Biome servers...

Server:
  Status:                       stopped

Incompatible Biome Server: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

What happened?

I am using the commit 44ae99ff11 on the main branch of biome. I started the lsp server with the command biome lsp-proxy --config-path ~/.config/biome. The ~/.config/biome/biome.json has the following content:

{
  "$schema": "https://biomejs.dev/schemas/1.2.2/schema.json",
  "organizeImports": {
    "enabled": true
  },
  "linter": {
    "enabled": true,
    "rules": {
      "recommended": true
    }
  },
  "formatter": {
    "indentStyle": "space",
    "indentWidth": 2
  }
}

I then used the lsp to format a json file. However, the formatted json file used tab instead of space, while my biome.json file asked to use space.

If I do formatting with the biome format --config-path ~/.config/biome command, then space is used instead of tab. This seems to imply that biome format loads the config file correctly, while biome lsp-proxy does not.

This is the file I tried to format:

{
 <SPACE><SPACE><SPACE><SPACE>"a": "sdf"
}

This is the formatting result by the biome lsp-proxy --config-path ~/.config/biome command:

{
<TAB>"a": "sdf"
}

This is the formatting result by the biome format --config-path ~/.config/biome command:

{
<SPACE><SPACE>"a": "sdf"
}

Expected result

biome lsp-proxy --config-path ~/.config/biome should use my config file ~/.config/biome/biome.json when formatting my json files.

Code of Conduct

ematipico commented 1 year ago

The --config-path wasn't designed for the lsp-proxy command, because this command works only as a proxy for the daemon. This was probably an oversight from our end about how we structured the CLI options.

Have you tried to use any other CLI option and see if they have an effect on the lsp-proxy command?

I mean all the Global options applied to all commands that you can see in the reference page: https://biomejs.dev/reference/cli/#biome-lsp-proxy

xulongwu4 commented 1 year ago

@ematipico, I tried the --max-diagnostics flag and set it to 2, but I didn't see it have any effects on the behavior of the LSP. The language server still reports that there are 5 errors in my file.

I found this old issue in the rome repo: https://github.com/rome/tools/issues/4505. It seems to imply that --config-path is supposed to work for the rome lsp-proxy command?

ematipico commented 1 year ago

Then it's probably a regression that we caused when we switched to another command line parser.

I will investigate when I have time.

xulongwu4 commented 11 months ago

Resolved by #685. Thanks a lot @ematipico!

3rd commented 10 months ago

Hit the same issue today, built biome from main. The config file works for rules, but not for formatting, and everything is ok with biome format.

ematipico commented 10 months ago

@3rd would you mind opening a new issue? Maybe explain a bit what you're trying to do. Unfortunately it's very difficult to test/replicate these cases