-
Notifications
You must be signed in to change notification settings - Fork 131
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
Support workspace/didChangeWatchedFiles #15
Comments
@danishprakash This might be relatively simple to resolve - or at least it doesn't have any further upstream dependencies, if you want to tackle a new issue. |
Thanks @radeksimko, I'll start looking into this. |
Hey @radeksimko, I've a few questions while going through this issue, namely:
Apologies if these are rather trivial questions, I thought It better to clear them before starting with the implementation. |
@radeksimko are these^ valid questions here? just checking in. |
Sorry for the delay @danishprakash
I think whenever a folder changes, that should be reflected in the virtual filesystem layer, the filesystem shouldn't need to know whether a path belongs to a registered module or whether it even contains any Terraform code.
Currently a "module" as we track it in memdb in state storage is generally initialized directory of
We have plans to index uninitialized modules too - which practically means any folder with
Are you possibly looking for these places in the codebase? terraform-ls/internal/langserver/handlers/service.go Lines 132 to 141 in 132e82d
Do you mind linking to the relevant part of gopls codebase, for context? FWIW our reliance on the locally sourced schema and hence the role of the internal server-side file watcher is no longer as critical since we prebuild the schema since #454 (released in April 2021 in 0.16.0) so we can be a little more flexible in theory. i.e. if the client misconfigures what files are supposed to be watched, it may still affect the UX, but it is not as big of a deal anymore. Relatedly I think that a first iteration of this feature doesn't have to involve all filetypes, we can start just |
Sorry about the delay on this @radeksimko. Thanks for the thorough response to my questions. I'm still trying to understand the whole thing and from what I can gather till now, we're essentially handling the notifications here. When I mentioned "registration", I actually meant the server registration to the client for a specific event for e.g. this is how gopls registers for the With that being said, I'm thinking of moving ahead with this outline. I can go ahead and raise a WIP PR where you can also track the progress if that looks like the right direction. |
That's correct - dynamic capability registration is an AFAIK optional part of LSP which our server currently doesn't support. This means that all capability negotiation has to happen early during There is no reason for not supporting dynamic (un)registration, other than just "there are other tasks with higher priority currently".
That looks like a reasonable start, feel free to raise a draft PR. |
FYI @danishprakash I have clarified the scope and added some more notes to the initial comment here + I also created hashicorp/vscode-terraform#1068 which may be an easy way to test this. Let me know if you need any further help with #790 or if you'd prefer for anyone else to take it over. We'll likely need to prioritize it in the upcoming weeks as part of larger list tracked in hashicorp/vscode-terraform#715 |
@radeksimko thanks for the heads up, I looked into it last week and I'll share an update by EOD today. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Background
LSP method
textDocument/didChange
(which is already implemented) can be used to find out about changes made through the IDE, but sometimes files are changed outside of the IDE.These can be detected through
workspace/didChangeWatchedFiles
which the LS doesn't implement yet.Clients may choose to send pretty much arbitrary updates to the server and it is up to the server to filter them. Ideally though, the server should document what clients should watch so it doesn't have to filter
garbageunnecessary updates.Server may also add to the list of watched globs, which is a feature described under #867
UX Impact
Users will see completion, go-to-definition or go-to-references etc. involving indexed but unopened modules to be accurate even when these modules change outside of the editor - e.g. when git branch is switched or files are changed in another editor.
Proposal
workspace/didChangeWatchedFiles
*.tf
and*.tfvars
filesterraform-ls/internal/langserver/handlers/did_change.go
Lines 49 to 53 in c277ec6
terraform-ls/internal/langserver/handlers/did_change.go
Lines 55 to 58 in c277ec6
The text was updated successfully, but these errors were encountered: