去除 vhdl_parser 中的补全项目

This commit is contained in:
锦恢 2024-12-02 00:30:03 +08:00
parent 99786868b9
commit 509fd1a506
2 changed files with 15 additions and 14 deletions

1
Cargo.lock generated
View File

@ -1416,6 +1416,7 @@ dependencies = [
name = "sv-parser"
version = "0.13.3"
dependencies = [
"log",
"nom",
"nom-greedyerror",
"sv-parser-error",

View File

@ -39,16 +39,16 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
};
let escape_path = to_escape_path(&path);
let project_file = escape_path.as_path();
let Some(source) = global_project.project.get_source(project_file) else {
return None
};
let cursor = from_lsp_pos(params.text_document_position.position);
let vhdl_project_completion_items = global_project.project
.list_completion_options(&source, cursor)
.into_iter()
.map(|item| vhdl_ls::VHDLServer::completion_item_to_tower_lsp_item(item))
.collect::<Vec<CompletionItem>>();
// let Some(source) = global_project.project.get_source(project_file) else {
// return None
// };
// let cursor = from_lsp_pos(params.text_document_position.position);
// let vhdl_project_completion_items = global_project.project
// .list_completion_options(&source, cursor)
// .into_iter()
// .map(|item| vhdl_ls::VHDLServer::completion_item_to_tower_lsp_item(item))
// .collect::<Vec<CompletionItem>>();
let response = match &params.context {
Some(context) => match context.trigger_kind {
@ -64,7 +64,7 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
&doc.text_document.uri,
)?;
completion_items.items.extend(vhdl_project_completion_items);
// completion_items.items.extend(vhdl_project_completion_items);
completion_items.items.dedup_by_key(|i| i.label.to_string());
Some(completion_items)
@ -97,7 +97,7 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
make_module_completions(server, &token, &language_id)
);
completion_items.items.extend(vhdl_project_completion_items);
// completion_items.items.extend(vhdl_project_completion_items);
// 去重
completion_items.items.dedup_by_key(|i| i.label.to_string());
@ -135,7 +135,7 @@ pub fn completion(server: &LSPServer, params: &CompletionParams) -> Option<Compl
.collect(),
);
comps.items.extend(vhdl_project_completion_items);
// comps.items.extend(vhdl_project_completion_items);
comps.items.dedup_by_key(|i| i.label.clone());
Some(comps)
@ -320,7 +320,7 @@ fn make_instantiation_code(module: &crate::core::hdlparam::Module) -> String {
}
i += 1;
}
snippet_codes.push(");\n".to_string());
snippet_codes.push("\n);\n".to_string());
}
snippet_codes.join("")