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

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

Open
1 task done
cemoktra opened this issue Oct 31, 2024 · 10 comments
Open
1 task done

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

cemoktra opened this issue Oct 31, 2024 · 10 comments
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc language An umbrella label for all programming languages syntax behaviors needs info / awaiting response Issue that needs more information from the user

Comments

@cemoktra
Copy link

cemoktra commented Oct 31, 2024

Check for existing issues

  • Completed

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
@cemoktra cemoktra added admin read Pending admin review bug [core label] triage Maintainer needs to classify the issue labels Oct 31, 2024
@SomeoneToIgnore
Copy link
Contributor

Do you have an .editorconfig in that repo?

@cemoktra
Copy link
Author

no

@notpeter
Copy link
Member

  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
  1. 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)?

@notpeter notpeter added needs info / awaiting response Issue that needs more information from the user editor Feedback for code editing, formatting, editor iterations, etc language An umbrella label for all programming languages syntax behaviors and removed triage Maintainer needs to classify the issue admin read Pending admin review labels Oct 31, 2024
@cemoktra
Copy link
Author

cemoktra commented Nov 4, 2024

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

@github-actions github-actions bot added admin read Pending admin review triage Maintainer needs to classify the issue labels Nov 5, 2024
@JosephTLyons JosephTLyons removed triage Maintainer needs to classify the issue admin read Pending admin review labels Nov 5, 2024
@cemoktra
Copy link
Author

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
Copy link
Member

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.

@notpeter notpeter changed the title Language specific tab_size is ignored in latest version Proto Extension does not use tab_size for formatting Protobuf files Nov 14, 2024
@cemoktra
Copy link
Author

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
Copy link
Author

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
Copy link
Member

notpeter commented Nov 18, 2024

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
Copy link
Author

cemoktra commented Nov 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug [core label] editor Feedback for code editing, formatting, editor iterations, etc language An umbrella label for all programming languages syntax behaviors needs info / awaiting response Issue that needs more information from the user
Projects
None yet
Development

No branches or pull requests

4 participants