@@ -370,6 +370,7 @@ fn hoverNumberLiteral(
370370 token_index : Ast.TokenIndex ,
371371 arena : std.mem.Allocator ,
372372 markup_kind : types.MarkupKind ,
373+ client_name : ? []const u8 ,
373374) error {OutOfMemory }! ? []const u8 {
374375 const tree = handle .tree ;
375376 // number literals get tokenized separately from their minus sign
@@ -388,15 +389,21 @@ fn hoverNumberLiteral(
388389 }
389390 };
390391
392+ // Zed currently doesn't render markdown unless wrapped in code blocks
393+ // Remove this when this issue is closed https://github.com/zed-industries/zed/issues/5386
394+ const is_zed = if (client_name ) | name | std .mem .startsWith (u8 , name , "Zed" ) else false ;
391395 switch (markup_kind ) {
392396 .markdown = > return try std .fmt .allocPrint (arena ,
397+ \\{[md_ticks]s}
393398 \\| Base | {[value]s:<[count]} |
394399 \\| ---- | {[dash]s:-<[count]} |
395400 \\| BIN | {[sign]s}0b{[number]b:<[len]} |
396401 \\| OCT | {[sign]s}0o{[number]o:<[len]} |
397402 \\| DEC | {[sign]s}{[number]d:<[len]} |
398403 \\| HEX | {[sign]s}0x{[number]X:<[len]} |
404+ \\{[md_ticks]s}
399405 , .{
406+ .md_ticks = if (is_zed ) "```" else "" ,
400407 .sign = if (is_negative ) "-" else "" ,
401408 .dash = "-" ,
402409 .value = "Value" ,
@@ -422,14 +429,15 @@ fn hoverDefinitionNumberLiteral(
422429 source_index : usize ,
423430 markup_kind : types.MarkupKind ,
424431 offset_encoding : offsets.Encoding ,
432+ client_name : ? []const u8 ,
425433) ! ? types.Hover {
426434 const tracy_zone = tracy .trace (@src ());
427435 defer tracy_zone .end ();
428436
429437 const tree = handle .tree ;
430438 const token_index = offsets .sourceIndexToTokenIndex (tree , source_index );
431439 const num_loc = offsets .tokenToLoc (tree , token_index );
432- const hover_text = (try hoverNumberLiteral (handle , token_index , arena , markup_kind )) orelse return null ;
440+ const hover_text = (try hoverNumberLiteral (handle , token_index , arena , markup_kind , client_name )) orelse return null ;
433441
434442 return .{
435443 .contents = .{ .MarkupContent = .{
@@ -447,6 +455,7 @@ pub fn hover(
447455 source_index : usize ,
448456 markup_kind : types.MarkupKind ,
449457 offset_encoding : offsets.Encoding ,
458+ client_name : ? []const u8 ,
450459) ! ? types.Hover {
451460 const pos_context = try Analyser .getPositionContext (arena , handle .tree , source_index , true );
452461
@@ -456,7 +465,7 @@ pub fn hover(
456465 .field_access = > | loc | try hoverDefinitionFieldAccess (analyser , arena , handle , source_index , loc , markup_kind , offset_encoding ),
457466 .label_access , .label_decl = > | loc | try hoverDefinitionLabel (analyser , arena , handle , source_index , loc , markup_kind , offset_encoding ),
458467 .enum_literal = > try hoverDefinitionEnumLiteral (analyser , arena , handle , source_index , markup_kind , offset_encoding ),
459- .number_literal , .char_literal = > try hoverDefinitionNumberLiteral (arena , handle , source_index , markup_kind , offset_encoding ),
468+ .number_literal , .char_literal = > try hoverDefinitionNumberLiteral (arena , handle , source_index , markup_kind , offset_encoding , client_name ),
460469 else = > null ,
461470 };
462471
0 commit comments