From ce267363fb6bbdafa9fc3284c18296d07d326473 Mon Sep 17 00:00:00 2001 From: light-ly Date: Wed, 13 Nov 2024 23:22:18 +0800 Subject: [PATCH] merge primitives completion to new completion code --- src/completion/sv.rs | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/completion/sv.rs b/src/completion/sv.rs index 63a60d0..2cb1ca6 100644 --- a/src/completion/sv.rs +++ b/src/completion/sv.rs @@ -319,15 +319,30 @@ fn make_module_completions( } } - insert_text.push(make_instantiation_code(&module)); + let (insert_text, module_profile, define_info) = if file_type == "primitives" { + let primitive_map = server.srcs.primitive_text.name_to_text.read().unwrap(); + if let Some(text) = primitive_map.get(&module.name) { + insert_text.push(make_primitives_instantiation_code(text)); + ( + insert_text.join("\n"), + make_primitives_module_profile_code(text), + format!("[Definition] Primitive module: {}", module.name) + ) + } else { + continue; + } + } else { + insert_text.push(make_instantiation_code(&module)); + let path_uri = Url::from_file_path(def_path).unwrap().to_string(); + let def_row = module.range.start.line; + let def_col = module.range.start.character; - let insert_text = insert_text.join("\n"); - let module_profile = make_module_profile_code(&module); - - let path_uri = Url::from_file_path(def_path).unwrap().to_string(); - let def_row = module.range.start.line; - let def_col = module.range.start.character; - let define_info = format!("Go to [Definition]({path_uri}#L{def_row}:{def_col})"); + ( + insert_text.join("\n"), + make_module_profile_code(&module), + format!("Go to [Definition]({path_uri}#L{def_row}:{def_col})") + ) + }; let module_profile = MarkupContent { kind: MarkupKind::Markdown,