zaucy / zed-starlark

Zed Starlark Extension
MIT License
8 stars 5 forks source link

feat: Include support for buck2 #4

Closed huwaireb closed 1 month ago

huwaireb commented 2 months ago

Given both build systems leverage starlark, thought i might as well just submit a PR to this extension instead of creating a separate one specific to Buck2. Hope that's fine, buck2.

Similar to the elixir situation in Zed, this'll require extra configuration to be added to the default zed settings. Something along the lines:

    "Starlark": {
      "language_servers": ["starpls", "!buck2-lsp"]
    }

Do please include it when opening the PR to Zed, you can include it here: https://github.com/zed-industries/zed/blob/main/assets/settings/default.json

See how elixir does it: https://github.com/zed-industries/zed/blob/59ce3535d38946acaa7f7dcf6fcdf0aedd127432/assets/settings/default.json#L737-L739

Those who'd like to use buck2 can by changing it to:

    "Starlark": {
      "language_servers": ["!starpls", "buck2-lsp"]
    }
huwaireb commented 2 months ago

Quick question though - why is the default config change in the Zed repository necessary? What would be the consequence of not adding to the default config in the Zed repository?

No way to set the default LSP on our side, I'm not sure exactly about the behavior either it might spawn both LSPs at the same time or outright not work? It's fine they'll accept it if that's what you are concerned about, given the Elixir extension does it.

zaucy commented 2 months ago

This does make me feel like we should define separate languages for both bazel and buck2. That would probably be a nicer experience for the extension user since it will "just work" if they're using buck vs bazel.

I'm down to get this merged in soon - I just want to do a little research on whats possible first.

huwaireb commented 1 month ago

This does make me feel like we should define separate languages for both bazel and buck2. That would probably be a nicer experience for the extension user since it will "just work" if they're using buck vs bazel.

I'm down to get this merged in soon - I just want to do a little research on whats possible first.

It'll work by default for Bazel users. It's a two character change for Buck2 users.

zaucy commented 1 month ago

I didn't end up looking for other solutions and I'm just going to merge this in. Feel free to make default config change in the Zed repository.