Simple completion example
This commit is contained in:
+23
-1
@@ -10,7 +10,19 @@ struct Backend {
|
|||||||
#[tower_lsp::async_trait]
|
#[tower_lsp::async_trait]
|
||||||
impl LanguageServer for Backend {
|
impl LanguageServer for Backend {
|
||||||
async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
|
async fn initialize(&self, _: InitializeParams) -> Result<InitializeResult> {
|
||||||
Ok(InitializeResult::default())
|
let mut res = InitializeResult::default();
|
||||||
|
|
||||||
|
res.capabilities.completion_provider = Some(CompletionOptions {
|
||||||
|
resolve_provider: None,
|
||||||
|
trigger_characters: None,
|
||||||
|
all_commit_characters: None,
|
||||||
|
work_done_progress_options: WorkDoneProgressOptions {
|
||||||
|
work_done_progress: None,
|
||||||
|
},
|
||||||
|
completion_item: None,
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn initialized(&self, _: InitializedParams) {
|
async fn initialized(&self, _: InitializedParams) {
|
||||||
@@ -19,6 +31,16 @@ impl LanguageServer for Backend {
|
|||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn completion(&self, params: CompletionParams) -> Result<Option<CompletionResponse>> {
|
||||||
|
self.client
|
||||||
|
.log_message(MessageType::INFO, "getting completion")
|
||||||
|
.await;
|
||||||
|
|
||||||
|
Ok(Some(CompletionResponse::Array(vec![
|
||||||
|
CompletionItem::new_simple("new".to_string(), "The new keyword".to_string()),
|
||||||
|
])))
|
||||||
|
}
|
||||||
|
|
||||||
async fn shutdown(&self) -> Result<()> {
|
async fn shutdown(&self) -> Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ void main() {
|
|||||||
|
|
||||||
if (args.len() < 2) {
|
if (args.len() < 2) {
|
||||||
print_usage();
|
print_usage();
|
||||||
|
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user