Skip to content

x/tools/gopls: add file watcher for headless mode #74292

Open
@findleyr

Description

@findleyr

When gopls is running in headless mode (as for its MCP server), it needs a file watcher (i.e. fsnotify).

It's OK if this file watcher is not perfectly accurate.

Related:

I think we should finally take this on. The good thing about headless mode is that it is experimental and doesn't conflict with ordinary state changes from the client. However, based on what we learn, we can consider integrating the file watcher elsewhere.

For the initial implementation, we don't need to care about the complicated algebra of glob patterns that gopls computes (largely to work around client limitations). Let's just focus on watching *.{go,mod,sum,work}. We can then produce synthetic didChangeWatchedFile notifications (or equivalent).

This is liable to be nontrivial and deal with the gnarly bits of the gopls session construction. For whomever takes this on (if not me): let's discuss the plan before getting hands dirty.

CC @adonovan @madelinekalil @h9jiang

Metadata

Metadata

Assignees

Labels

FeatureRequestIssues asking for a new feature that does not need a proposal.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions