-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
feat(lsp): will save #8952
base: master
Are you sure you want to change the base?
feat(lsp): will save #8952
Conversation
d339e29
to
89246f7
Compare
89246f7
to
6fb5979
Compare
@pascalkuthe rebased. I don't think #8949 affects this PR as this isn't covered under the file interest. |
helix-core/src/syntax.rs
Outdated
// DocumentSynchronization | ||
Save, | ||
WillSave, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these should not be manually configurable, the fact athat we crruntly don't send these is a bug and there should be no option to turn this off (its not an optional part of the spec)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I am not sure if I follow. These are not configurable but used to request only LSPs support specific features. In this case we are checking for support of TextDocumentSyncOptions
under https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_didRename.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these are config options that allow users to disable/enable only certain LSP features. For convenience when also use these to check capabilities but you can check capabilities without this. You should only add something to this enum if you want the user to be able to turn an LSP feature off
helix-lsp/src/client.rs
Outdated
pub fn text_document_will_save_wait_until( | ||
&self, | ||
text_document: lsp::TextDocumentIdentifier, | ||
) -> Option<impl Future<Output = Result<Vec<lsp::TextEdit>>>> { | ||
let request = | ||
self.call::<lsp::request::WillSaveWaitUntil>(lsp::WillSaveTextDocumentParams { | ||
text_document, | ||
reason: TextDocumentSaveReason::MANUAL, | ||
}); | ||
|
||
Some(async move { | ||
let json = request.await?; | ||
let response: Option<Vec<TextEdit>> = serde_json::from_value(json)?; | ||
Ok(response.unwrap_or_default()) | ||
}) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should have a 1s timeout simiar to willrename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use 5s there, added the same here and extracted it into static DOCUMENT_OPS_TIMEOUT
. I don't think it's worth it adding to config but having the same timeouts on all document-related calls seems sensible.
// ------------------------------------------------------------------------------------------- | ||
// Language features | ||
// https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#languageFeatures | ||
// ------------------------------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems unrelated
@@ -870,6 +870,31 @@ impl Document { | |||
// We encode the file according to the `Document`'s encoding. | |||
let future = async move { | |||
use tokio::{fs, fs::File}; | |||
|
|||
if let Some(identifier) = &identifier { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should definitly4 be handeled by the even t system and what I meant with my previous comments. We essentially want to keep LSP out of the main code and move it all behind events. So there should be a willsave event here and the lsp stuff should be moved to a hook. Same with didsave
cf558bf
to
acf9986
Compare
acf9986
to
03cc560
Compare
Implement
textDocument/willSave
notification1.Footnotes
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_willSave ↩