mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-02 04:48:27 +00:00
lsp: Support textDocument/formatting request
This commit is contained in:
parent
d769f272e1
commit
70fe0df97f
3 changed files with 137 additions and 2 deletions
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
mod completion;
|
||||
mod component_catalog;
|
||||
mod formatting;
|
||||
mod goto;
|
||||
mod properties;
|
||||
mod semantic_tokens;
|
||||
|
|
@ -29,8 +30,8 @@ use i_slint_compiler::{
|
|||
use i_slint_compiler::{typeloader::TypeLoader, typeregister::TypeRegister};
|
||||
use lsp_types::request::{
|
||||
CodeActionRequest, CodeLensRequest, ColorPresentationRequest, Completion, DocumentColor,
|
||||
DocumentHighlightRequest, DocumentSymbolRequest, ExecuteCommand, GotoDefinition, HoverRequest,
|
||||
PrepareRenameRequest, Rename, SemanticTokensFullRequest,
|
||||
DocumentHighlightRequest, DocumentSymbolRequest, ExecuteCommand, Formatting, GotoDefinition,
|
||||
HoverRequest, PrepareRenameRequest, Rename, SemanticTokensFullRequest,
|
||||
};
|
||||
use lsp_types::{
|
||||
ClientCapabilities, CodeActionOrCommand, CodeActionProviderCapability, CodeLens,
|
||||
|
|
@ -228,6 +229,7 @@ pub fn server_initialize_result(client_cap: &ClientCapabilities) -> InitializeRe
|
|||
OneOf::Left(true)
|
||||
},
|
||||
),
|
||||
document_formatting_provider: Some(OneOf::Left(true)),
|
||||
..ServerCapabilities::default()
|
||||
},
|
||||
server_info: Some(ServerInfo {
|
||||
|
|
@ -423,6 +425,10 @@ pub fn register_request_handlers(rh: &mut RequestHandler) {
|
|||
};
|
||||
Ok(None)
|
||||
});
|
||||
rh.register::<Formatting, _>(|params, ctx| async move {
|
||||
let document_cache = ctx.document_cache.borrow_mut();
|
||||
Ok(formatting::format_document(params, &document_cache))
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "preview-builtin", feature = "preview-external"))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue