Skip to content
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

cmd/govim: use gopls registered file globs for watching #950

Open
myitcv opened this issue Sep 16, 2020 · 0 comments
Open

cmd/govim: use gopls registered file globs for watching #950

myitcv opened this issue Sep 16, 2020 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Sep 16, 2020

gopls calls the client via RegisterCapability to indicate what file globs should be watched. e.g.

RegisterCapability: &protocol.RegistrationParams{
    Registrations: {
        {
            ID:              "workspace/didChangeWatchedFiles-0",
            Method:          "workspace/didChangeWatchedFiles",
            RegisterOptions: map[string]interface {}{
                "watchers": []interface {}{
                    map[string]interface {}{
                        "globPattern": "**/*.{go,mod,sum}",
                        "kind":        float64(7),
                    },
                    map[string]interface {}{
                        "globPattern": "/home/myitcv/gostuff/src/github.com/myitcv/playground/**/*.{go,mod,sum}",
                        "kind":        float64(7),
                    },
                    map[string]interface {}{
                        "globPattern": "/home/myitcv/gostuff/src/github.com/myitcv/playground/blah/**/*.{go,mod,sum}",
                        "kind":        float64(7),
                    },
                },
            },
        },
    },
}

It then calls UnregisterCapability (with a corresponding ID) when the client should drop a watcher:

UnregisterCapability: &protocol.UnregistrationParams{
    Unregisterations: {
        {ID:"workspace/didChangeWatchedFiles-0", Method:"workspace/didChangeWatchedFiles"},
    },
}

Currently our file watcher is rather dumb and just tries to watch everything (ignoring submodules) under the workspace root. However, per #604, even this is not complete.

So closing #604 in favour of this and noting the following enhancements:

  • new directories should be recursively added to the watcher subject to them matching the glob supplied by gopls
  • if the glob sent by gopls can't be made more specific (to ignore sub modules for example, or . prefixed directories, etc) then we could implement this client-side
@myitcv myitcv added the enhancement New feature or request label Sep 16, 2020
@myitcv myitcv added this to the Unplanned milestone Sep 16, 2020
myitcv added a commit that referenced this issue Sep 16, 2020
Until we resolve #172, #949 and #950, simply log any known calls to
RegisterCapability and UnregisterCapability. Panic if there are any
calls for methods we don't know about (so we then know to start
supporting them).
myitcv added a commit that referenced this issue Sep 16, 2020
Until we resolve #172, #949 and #950, simply log any known calls to
RegisterCapability and UnregisterCapability. Panic if there are any
calls for methods we don't know about (so we then know to start
supporting them).
myitcv added a commit that referenced this issue Sep 16, 2020
Until we resolve #172, #949 and #950, simply log any known calls to
RegisterCapability and UnregisterCapability. Panic if there are any
calls for methods we don't know about (so we then know to start
supporting them).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant