-
Notifications
You must be signed in to change notification settings - Fork 747
Provide Program diagnostics as push diags in tsconfig.json #2118
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
574ee85
wip prog diags in lsp
jakebailey f8e919e
Simplify
jakebailey 9621a3e
Simplify
jakebailey 953928a
fix path
jakebailey 2082a7b
Testing
jakebailey acee2d1
oops
jakebailey a32814b
Apply suggestion from @Copilot
jakebailey 528629f
PR feedback
jakebailey f1117f3
Drop old workarounds
jakebailey a8f9833
Flip the condition I guess
jakebailey 4c8b044
noop client
jakebailey 1a19ca7
Just rely on the bool
jakebailey 28221e8
Reenable
jakebailey 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
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
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 |
|---|---|---|
|
|
@@ -219,6 +219,13 @@ func (s *Server) RefreshDiagnostics(ctx context.Context) error { | |
| return nil | ||
| } | ||
|
|
||
| // PublishDiagnostics implements project.Client. | ||
| func (s *Server) PublishDiagnostics(ctx context.Context, params *lsproto.PublishDiagnosticsParams) error { | ||
| notification := lsproto.TextDocumentPublishDiagnosticsInfo.NewNotificationMessage(params) | ||
| s.outgoingQueue <- notification.Message() | ||
| return nil | ||
| } | ||
|
|
||
| func (s *Server) RequestConfiguration(ctx context.Context) (*lsutil.UserPreferences, error) { | ||
| caps := lsproto.GetClientCapabilities(ctx) | ||
| if !caps.Workspace.Configuration { | ||
|
|
@@ -716,15 +723,26 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali | |
| cwd = s.cwd | ||
| } | ||
|
|
||
| var disablePushDiagnostics bool | ||
| if s.initializeParams != nil && s.initializeParams.InitializationOptions != nil && *s.initializeParams.InitializationOptions != nil { | ||
| // Check for disablePushDiagnostics option | ||
| if initOpts, ok := (*s.initializeParams.InitializationOptions).(map[string]any); ok { | ||
| if disable, ok := initOpts["disablePushDiagnostics"].(bool); ok { | ||
| disablePushDiagnostics = disable | ||
| } | ||
| } | ||
| } | ||
|
|
||
| s.session = project.NewSession(&project.SessionInit{ | ||
| Options: &project.SessionOptions{ | ||
| CurrentDirectory: cwd, | ||
| DefaultLibraryPath: s.defaultLibraryPath, | ||
| TypingsLocation: s.typingsLocation, | ||
| PositionEncoding: s.positionEncoding, | ||
| WatchEnabled: s.watchEnabled, | ||
| LoggingEnabled: true, | ||
| DebounceDelay: 500 * time.Millisecond, | ||
| CurrentDirectory: cwd, | ||
| DefaultLibraryPath: s.defaultLibraryPath, | ||
| TypingsLocation: s.typingsLocation, | ||
| PositionEncoding: s.positionEncoding, | ||
| WatchEnabled: s.watchEnabled, | ||
| LoggingEnabled: true, | ||
| DebounceDelay: 500 * time.Millisecond, | ||
| PushDiagnosticsEnabled: !disablePushDiagnostics, | ||
| }, | ||
| FS: s.fs, | ||
| Logger: s.logger, | ||
|
|
@@ -733,36 +751,28 @@ func (s *Server) handleInitialized(ctx context.Context, params *lsproto.Initiali | |
| ParseCache: s.parseCache, | ||
| }) | ||
|
|
||
| if s.initializeParams != nil && s.initializeParams.InitializationOptions != nil && *s.initializeParams.InitializationOptions != nil { | ||
| // handle userPreferences from initializationOptions | ||
| userPreferences := s.session.NewUserPreferences() | ||
| userPreferences.Parse(*s.initializeParams.InitializationOptions) | ||
| s.session.InitializeWithConfig(userPreferences) | ||
|
Comment on lines
-736
to
-740
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code was unused |
||
| } else { | ||
| // request userPreferences if not provided at initialization | ||
| userPreferences, err := s.RequestConfiguration(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| s.session.InitializeWithConfig(userPreferences) | ||
| userPreferences, err := s.RequestConfiguration(ctx) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| s.session.InitializeWithConfig(userPreferences) | ||
|
|
||
| _, err = sendClientRequest(ctx, s, lsproto.ClientRegisterCapabilityInfo, &lsproto.RegistrationParams{ | ||
| Registrations: []*lsproto.Registration{ | ||
| { | ||
| Id: "typescript-config-watch-id", | ||
| Method: string(lsproto.MethodWorkspaceDidChangeConfiguration), | ||
| RegisterOptions: ptrTo(any(lsproto.DidChangeConfigurationRegistrationOptions{ | ||
| Section: &lsproto.StringOrStrings{ | ||
| // !!! Both the 'javascript' and 'js/ts' scopes need to be watched for settings as well. | ||
| Strings: &[]string{"typescript"}, | ||
| }, | ||
| })), | ||
| }, | ||
| _, err = sendClientRequest(ctx, s, lsproto.ClientRegisterCapabilityInfo, &lsproto.RegistrationParams{ | ||
| Registrations: []*lsproto.Registration{ | ||
| { | ||
| Id: "typescript-config-watch-id", | ||
| Method: string(lsproto.MethodWorkspaceDidChangeConfiguration), | ||
| RegisterOptions: ptrTo(any(lsproto.DidChangeConfigurationRegistrationOptions{ | ||
| Section: &lsproto.StringOrStrings{ | ||
| // !!! Both the 'javascript' and 'js/ts' scopes need to be watched for settings as well. | ||
| Strings: &[]string{"typescript"}, | ||
| }, | ||
| })), | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to register configuration change watcher: %w", err) | ||
| } | ||
| }, | ||
| }) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to register configuration change watcher: %w", err) | ||
| } | ||
|
|
||
| // !!! temporary. | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.