mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Formatting
This commit is contained in:
parent
886a367026
commit
03d132cf6d
6 changed files with 86 additions and 5 deletions
|
@ -43,11 +43,17 @@ impl RocLs {
|
|||
work_done_progress: None,
|
||||
},
|
||||
};
|
||||
let document_formatting_provider = DocumentFormattingOptions {
|
||||
work_done_progress_options: WorkDoneProgressOptions {
|
||||
work_done_progress: None,
|
||||
},
|
||||
};
|
||||
|
||||
ServerCapabilities {
|
||||
text_document_sync: Some(text_document_sync),
|
||||
hover_provider: Some(hover_provider),
|
||||
definition_provider: Some(OneOf::Right(definition_provider)),
|
||||
document_formatting_provider: Some(OneOf::Right(document_formatting_provider)),
|
||||
..ServerCapabilities::default()
|
||||
}
|
||||
}
|
||||
|
@ -146,6 +152,16 @@ impl LanguageServer for RocLs {
|
|||
.goto_definition(&text_document.uri, position)
|
||||
})
|
||||
}
|
||||
|
||||
async fn formatting(&self, params: DocumentFormattingParams) -> Result<Option<Vec<TextEdit>>> {
|
||||
let DocumentFormattingParams {
|
||||
text_document,
|
||||
options: _,
|
||||
work_done_progress_params: _,
|
||||
} = params;
|
||||
|
||||
panic_wrapper(|| self.registry().formatting(&text_document.uri))
|
||||
}
|
||||
}
|
||||
|
||||
fn panic_wrapper<T>(f: impl FnOnce() -> Option<T> + std::panic::UnwindSafe) -> Result<Option<T>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue