diff --git a/kclvm/tools/src/LSP/src/hover.rs b/kclvm/tools/src/LSP/src/hover.rs index 2205504e7..3369ca99f 100644 --- a/kclvm/tools/src/LSP/src/hover.rs +++ b/kclvm/tools/src/LSP/src/hover.rs @@ -47,6 +47,7 @@ pub(crate) fn hover( // Use the api provided by GlobalState to get all attrs let module_info = gs.get_packages().get_module_info(&kcl_pos.filename); let schema_attrs = obj.get_all_attributes(gs.get_symbols(), module_info); + let mut attrs: Vec = vec![]; for schema_attr in schema_attrs { if let kclvm_sema::core::symbol::SymbolKind::Attribute = schema_attr.get_kind() @@ -59,14 +60,17 @@ pub(crate) fn hover( Some(ty) => ty.ty_str(), None => ANY_TYPE_STR.to_string(), }; - docs.push(format!( - "{}{}: {}", + attrs.push(format!( + "\t{}{}: {}", name, if attr_symbol.is_optional() { "?" } else { "" }, attr_ty_str, )); } } + if !attrs.is_empty() { + docs.push(attrs.join("\n")); + } } _ => {} },