zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.77k stars 3.15k forks source link

Proto Extension does not use tab_size for formatting Protobuf files #20009

Open cemoktra opened 4 weeks ago

cemoktra commented 4 weeks ago

Check for existing issues

Describe the bug / provide steps to reproduce it

The following configuration is ignored in latest version when language server is not running:

  "languages": {
    "Proto": {
      "tab_size": 2
    }
  }

Environment

Zed: v0.159.5 (Zed) OS: Linux X11 ubuntu 24.04 Memory: 31.1 GiB Architecture: x86_64 GPU: Intel(R) UHD Graphics (TGL GT1) || Intel open-source Mesa driver || Mesa 24.0.9-0ubuntu0.2

If applicable, add mockups / screenshots to help explain present your vision of the feature

Pressing tab adds 4 spaces despite 2 being configured

If applicable, attach your Zed.log file to this issue.

Zed.log


SomeoneToIgnore commented 4 weeks ago

Do you have an .editorconfig in that repo?

cemoktra commented 4 weeks ago

no

notpeter commented 4 weeks ago
  1. Do you have the "Proto" extension installed?

  2. Is the file being identified as a Proto language file and setting the Language mode appropriately?

    Screenshot 2024-10-31 at 13 59 33
  3. What do you mean when you say "language server is not running" (e.g. is the extension uninstalled? Or...). Is there a setting you can change which causes indent to work properly (e.g. running the language server)?

cemoktra commented 3 weeks ago

Yes i have the proto extension installed. It used to work without installing/running the proto language server manually. But not i saw that in the logs zed was complaining about not finding language server

cemoktra commented 2 weeks ago

I updated to newest version today. The problem still exists. Additionally when i misformat the file and select formatting, it won't fix it. It does not produce any trace/log messages.

I'm using language server protols

notpeter commented 2 weeks ago

Protols uses clang-format under the hood. Can you confirm you have clang-format installed?

I couldn't actually get protols working at all, so as a workaround I am invoking clang-format directly and it works for me:

    "Proto": {
      "tab_size": 4,
      "formatter": {
        "external": {
          "command": "clang-format",
          "arguments": ["-style={IndentWidth: 4, ColumnLimit: 0}"]
        }
      }
    },

Alternatively, you can create a .clang-format with your clang-format style options instead of providing them as CLI arguments.

cemoktra commented 1 week ago

Oh yeah then it formats, but not in the way the CI likes it. Our CI uses https://buf.build/ and i'm not able to configure it as external formatter, also it is very slow and times out.

What kind of of protobuf language server do you use? i had problems using lasorda/protobuf-language-server

cemoktra commented 1 week ago

Ok, well i think i found a ocompatible clang-format config. Anyway it used to work and suddenly stopped working without messing with the config

notpeter commented 1 week ago

Our CI uses https://buf.build/ and i'm not able to configure it as external formatter, also it is very slow and times out.

buf format does not support formatting handling single files via stdin yet. There is an upstream issue here:

Ok, well i think i found a ocompatible clang-format config.

Could you paste your buf compatible .clange-format? I would love to include that it in the docs until the above support is added to buf.

cemoktra commented 1 week ago

"-style={IndentWidth: 2, ColumnLimit: 0, Language: Proto, BasedOnStyle: Google}", at least for now it did not create any differences