-
Notifications
You must be signed in to change notification settings - Fork 589
Watch files over LSP #806
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
base: main
Are you sure you want to change the base?
Watch files over LSP #806
Conversation
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.
Pull Request Overview
This PR adds support for watching files over LSP by integrating file watcher functionality into various parts of the project and refactoring how file events are processed.
- Introduces new file watch APIs and methods in the project and LSP server modules.
- Refactors and propagates comparePathsOptions, file watchers, and diagnostic publishing across services and tests.
- Updates tests and utilities for consistent use of configuration and file watching.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
internal/tsoptions/* | Introduces new utility functions for pattern matching. |
internal/project/* | Adds file watcher fields and update logic in projects. |
internal/lsp/server.go | Integrates LSP file watch requests, notifications, and dynamic registration. |
internal/api/api.go | Updates to script info creation reflecting FS injection. |
internal/testutil/projecttestutil/projecttestutil.go | Refactors file variable naming to improve consistency. |
Comments suppressed due to low confidence (1)
internal/lsp/server.go:70
- The variable name 'watcheEnabled' appears to have a typo. Consider renaming it to 'watchEnabled' for clarity and consistency.
watcheEnabled bool
Method Method `json:"method"` | ||
Params any `json:"params"` | ||
} | ||
|
||
func NewRequestMessage(method Method, id *ID, params any) *RequestMessage { | ||
return &RequestMessage{ | ||
JSONRPC: JSONRPCVersion{}, |
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.
JSONRPC: JSONRPCVersion{}, |
No need to specify this since it's zero'd.
@@ -62,36 +67,100 @@ type Server struct { | |||
initializeParams *lsproto.InitializeParams | |||
positionEncoding lsproto.PositionEncodingKind | |||
|
|||
watcheEnabled bool | |||
watcherID int | |||
watchers map[project.WatcherHandle]struct{} |
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.
Is this just a core.Set[project.WatcherHandle]
?
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.
Oh yeah, I forgot we had something other than OrderedSet
@@ -262,9 +363,14 @@ func (s *Server) handleInitialize(req *lsproto.RequestMessage) error { | |||
} | |||
|
|||
func (s *Server) handleInitialized(req *lsproto.RequestMessage) error { | |||
if s.initializeParams.Capabilities.Workspace.DidChangeWatchedFiles != nil && *s.initializeParams.Capabilities.Workspace.DidChangeWatchedFiles.DynamicRegistration { | |||
s.watcheEnabled = true |
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.
Typo in watcheEnabled
This adds LSP file watching requests for wildcard directories, failed/affecting lookup locations, and tsconfig files.