-
Notifications
You must be signed in to change notification settings - Fork 284
feat(files): add autocommand events before performing file actions #1586
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
Conversation
0dbf651 to
d09dcce
Compare
|
Thanks for the PR! I plan to add support for LSP file create/rename/delete directly into 'mini.files', as it seems to be possible to do so relatively concisely. If that would be the case, I'd like to not expose another set of events. My main concern is that there is no guarantee that a file system operation will actually happen.
Are you aware of any other such use cases? If not, I think I'd close this PR in favor of a future work I'd like to do in 'mini.files'. |
|
I'm not sure off the top of my head of any other use cases of these events so all good if you want to just close this. I'm also not sure how the specification guarantees validity in a rigorous manner for operations being unsuccessful. Especially because based on the semantics of the spec, the workspace edits also must be applied before the action takes place. So if you get the edit and apply it, I'm not sure of the means of reverting said edit in the case of the operation being unsuccessful (at least with the current neovim lua API). Very exciting to hear you are adding the LSP support directly! I do agree it can be implemented relatively concise. One thing I would note with the implementation is to make sure to support the regex filtering on the files when deciding if you are sending the LSP requests to the client. I have seen several implementations of the LSP file operations and that is typically missed. If you are curious about some other implementations, AstroNvim's LSP plugin recently got an implementation in place that is pretty complete (and hopefully correct as well) that also implements some caching of the filtering resolution for performance: https://github.com/AstroNvim/astrolsp/blob/main/lua/astrolsp/file_operations.lua |
Yes, that was one of my main concerns in the first place about adding My current starting idea is to issue a "counter request" in case an operation has failed:
Or, as
Thanks, that's really helpful! I didn't know about custom filters... That'll be not that fun to implement, test, and maintain :( Also, do you happen to know which LSP server has good As said above, I am indeed inclined to close this in favor of (very hopeful that near) future built-in support for LSP file methods. |
|
there are a lot of language servers it seems that support I also think all of the instances I have checked that implement |
|
Thanks, that's again very helpful! It also does look similar to my brief search around a year-ish ago. As in: there are some servers that implement "rename" functionality, but none of "create"/"delete". So seeing how they would behave for failed file system actions is problematic. |
The exposed autocommands make it very easy to add support for things such as the file operations defined in the LSP specification. Currently there are some events missing immediately before an operation is taken to support the rest of the events (
workspace/willCreateFiles/workspace/willDeleteFiles/workspace/willRenameFiles). I'm sure there are other use cases as well where the user may want to hook into events right before an action is taken place.