-
Notifications
You must be signed in to change notification settings - Fork 54
lsp: Expose implemented features in server caps #1867
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
Merged
charlieegan3
merged 1 commit into
open-policy-agent:main
from
charlieegan3:exp-feature-flags
Feb 16, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package lsp | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "github.com/sourcegraph/jsonrpc2" | ||
|
|
||
| "github.com/open-policy-agent/regal/internal/lsp/clients" | ||
| "github.com/open-policy-agent/regal/internal/lsp/types" | ||
| "github.com/open-policy-agent/regal/internal/lsp/uri" | ||
| "github.com/open-policy-agent/regal/internal/testutil" | ||
| ) | ||
|
|
||
| func TestInitializeExperimentalCapabilities(t *testing.T) { | ||
| t.Parallel() | ||
|
|
||
| ctx, cancel := context.WithCancel(t.Context()) | ||
| defer cancel() | ||
|
|
||
| tempDir := t.TempDir() | ||
|
|
||
| clientHandler := func(_ context.Context, _ *jsonrpc2.Conn, _ *jsonrpc2.Request) (any, error) { | ||
| return struct{}{}, nil | ||
| } | ||
|
|
||
| _, connClient := createAndInitServer(t, ctx, tempDir, clientHandler) | ||
|
|
||
| request := types.InitializeParams{ | ||
| RootURI: uri.FromPath(clients.IdentifierGeneric, tempDir), | ||
| ClientInfo: types.ClientInfo{Name: "go test"}, | ||
| } | ||
|
|
||
| var response types.InitializeResult | ||
| testutil.NoErr(connClient.Call(ctx, "initialize", request, &response))(t) | ||
|
|
||
| if response.Capabilities.Experimental == nil { | ||
| t.Fatal("expected experimental capabilities to be non-nil") | ||
| } | ||
|
|
||
| if !response.Capabilities.Experimental.ExplorerProvider { | ||
| t.Error("expected explorerProvider to be true") | ||
| } | ||
|
|
||
| if !response.Capabilities.Experimental.EvalProvider { | ||
| t.Error("expected evalProvider to be true") | ||
| } | ||
|
|
||
| if !response.Capabilities.Experimental.DebugProvider { | ||
| t.Error("expected debugProvider to be true") | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking we'll most likely want to move as much of the init handler into Rego sooner rather than later .. which makes me wonder if we want to user snake_case for serialized names instead? 🤔 There's no way to do have this done in Rego without actually naming rules like
debugProvider, etc.. and that'll need inline ignores, not to mention of course that it won't be very Rego'y :)(aside, it'd be pretty cool if metadata annotations could provide hints about how a Rego object should be serialized!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps, and we do have control of these for the client and the server.
However, others like
hoverProviderwill need to remain the same regardless of the Go/Rego implementation as that's the spec.I think my preference for now is to use the same style as the existing field names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point!