Open ayoub-benali opened 3 years ago
Looking thought sublime API it seems that this can be added via EventListener.on_new(), does it make sense ?
Does this trigger on newly created files, or on any newly created buffers?
on_new()
just notifies about opening a new buffer and such buffer doesn't have file path associated yet.
The DidCreateFiles
registration would normally define file pattern that should be included so at the point of creating an empty buffer we wouldn't be able to notify yet. But possibly we could set a flag that that view was just crated and notify when that buffer is saved.
We could use on_pre_save and on_post_save together to deduce whether it was a raw buffer previously, and a file-backed view after the save perhaps?
If the info is there then sounds like it could work. Though I feel at the point of on_pre_save
the path might be set already.
It also won’t work for files created with the “new file” context menu entry in the sidebar I think.
Right, for those the file watcher would probably be needed.
Just realized that LSP-metals has a "new scala file" command which could send the notification once completed without relying on Sublime API. Do other LSP packages have such a command ?
that wouldn't cover all cases but would be an option, I guess
Yeah I agree, a build in file watcher in LSP would be the best solution.
If the file was created via a plugin, is that considered to be “in-editor”?
For me yes, the plugin is still running in the context of the editor.
I think we're very far away from workspace/didCreateFiles, let alone workspace/willCreateFiles.
os
moduleos
module should be removed. All file/OS operations should go through the sublime
module so that ST can decide if something is in-editor or not.
Is your feature request related to a problem? Please describe. Since LSP 3.17 there DidCreateFiles Notification which allows servers to take action. From example Metals would add the correct package at the top of the file.
Describe the solution you'd like Looking thought sublime API it seems that this can be added via
EventListener.on_new()
, does it make sense ?