use super::super::{CompletionEnvironment, error::CompletionError};
use crate::server::lsp::{
CompletionItem, CompletionItemBuilder, CompletionItemKind, CompletionList, InsertTextFormat,
ItemDefaults,
};
pub async fn completions(
_context: &CompletionEnvironment,
) -> Result<CompletionList, CompletionError> {
Ok(CompletionList {
is_incomplete: false,
item_defaults: Some(ItemDefaults {
edit_range: None,
commit_characters: None,
data: None,
insert_text_format: Some(InsertTextFormat::Snippet),
insert_text_mode: None,
}),
items: vec![
CompletionItemBuilder::new()
.label("SELECT")
.detail("Select query")
.filter_text("SELECT")
.kind(CompletionItemKind::Snippet)
.insert_text("SELECT ${1:*} WHERE {\n\t${0:?s ?p ?o}\n}")
.insert_text_format(InsertTextFormat::Snippet)
.build(),
CompletionItem::new(
"CONSTRUCT",
Some("Construct query".to_string()),
None,
"CONSTRUCT {\n ${1:?s ?p ?o}\n} WHERE {\n ${0:?s ?p ?o} .\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"ASK",
Some("Ask query".to_string()),
None,
"ASK WHERE {\n ${0:?s ?p ?o}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"DESCRIBE",
Some("Describe query".to_string()),
None,
"DESCRIBE ?s WHERE {\n ${0:?s ?p ?o}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"LOAD",
Some("Load query".to_string()),
None,
"LOAD <${0:iri}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"CLEAR",
Some("Clear graph".to_string()),
None,
"CLEAR <${0:GraphRef}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"DROP",
Some("Drop graph".to_string()),
None,
"DROP <${0:GraphRef}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"ADD",
Some("Add graph".to_string()),
None,
"ADD <${1:GraphRef}> TO <${0:GraphRef}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"MOVE",
Some("Move graph".to_string()),
None,
"MOVE <${1:GraphRef}> TO <${0:GraphRef}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"COPY",
Some("Copy graph".to_string()),
None,
"COPY <${1:GraphRef}> TO <${0:GraphRef}>;",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"INSERT DATA",
Some("Insert data.".to_string()),
None,
"INSERT DATA {\n ${0}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"DELETE DATA",
Some("Delete data.".to_string()),
None,
"DELETE DATA {\n ${0}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"DELETE WHERE",
Some("Delete data with a where clause.".to_string()),
None,
"DELETE WHERE {\n ${0}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"INSERT WHERE",
Some("Insert with a where clause.".to_string()),
None,
"Insert {\n ${1}\n}\nWHERE {\n ${0}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"DELETE MODIFY",
Some("Delete data with a where clause.".to_string()),
None,
"DELETE {\n ${1}\n}\nINSERT {\n ${2}\n}\nWHERE {\n ${0}\n}",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"PREFIX",
Some("Declare a namespace".to_string()),
None,
"PREFIX ${1:namespace}: <${0:iri}>",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"BASE",
Some("Set the Base URI".to_string()),
None,
"BASE <${0}>",
CompletionItemKind::Snippet,
None,
),
CompletionItem::new(
"Query Metadata",
Some("Target endpoint and query description".to_string()),
None,
"#+ summary: ${1}\n#+ endpoint: ${0}",
CompletionItemKind::Snippet,
None,
),
],
})
}