Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

add documentation for custom types

author
Giacomo Cavalieri
committer
Louis Pilfold
date (Feb 25, 2026, 4:58 PM UTC) commit e386e421 parent 2cb0a11d change-id umwzrnym
+63 -1
+4
CHANGELOG.md
··· 76 76 variable. 77 77 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 78 78 79 + - The language server now shows hover information when hovering over custom type 80 + definitions. 81 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 82 + 79 83 - The language server is now smarter when producing autocompletions. Imagine 80 84 you're updating your code to fully qualify the uses of the `Json` type: 81 85
+18 -1
language-server/src/engine.rs
··· 935 935 &this.hex_deps, 936 936 )) 937 937 } 938 - Located::ModuleCustomType(_) => None, 938 + Located::ModuleCustomType(custom_type) => { 939 + Some(hover_for_custom_type(custom_type, lines)) 940 + } 939 941 Located::ModuleTypeAlias(_) => None, 940 942 Located::VariantConstructorDefinition(_) => None, 941 943 Located::UnqualifiedImport(UnqualifiedImport { ··· 1460 1462 Hover { 1461 1463 contents: HoverContents::Scalar(MarkedString::String(contents)), 1462 1464 range: Some(src_span_to_lsp_range(location, line_numbers)), 1465 + } 1466 + } 1467 + 1468 + fn hover_for_custom_type(type_: &CustomType<Arc<Type>>, line_numbers: LineNumbers) -> Hover { 1469 + let name = &type_.name; 1470 + let documentation = type_ 1471 + .documentation 1472 + .as_ref() 1473 + .map(|(_, documentation)| documentation.clone()) 1474 + .unwrap_or_default(); 1475 + 1476 + let contents = format!("```gleam\n{name}\n```\n{documentation}"); 1477 + Hover { 1478 + contents: HoverContents::Scalar(MarkedString::String(contents)), 1479 + range: Some(src_span_to_lsp_range(type_.full_location(), &line_numbers)), 1463 1480 } 1464 1481 } 1465 1482
+15
language-server/src/tests/hover.rs
··· 1934 1934 find_position_of("_discard") 1935 1935 ); 1936 1936 } 1937 + 1938 + #[test] 1939 + fn hover_for_custom_type() { 1940 + assert_hover!( 1941 + "/// Exciting documentation 1942 + /// Maybe even multiple lines 1943 + type Wibble { 1944 + /// Some more exciting documentation 1945 + Wibble(String) 1946 + /// The most exciting documentation 1947 + Wobble(arg: Int) 1948 + }", 1949 + find_position_of("Wibble") 1950 + ); 1951 + }
+26
language-server/src/tests/snapshots/gleam_language_server__tests__hover__hover_for_custom_type.snap
··· 1 + --- 2 + source: language-server/src/tests/hover.rs 3 + expression: "/// Exciting documentation\n/// Maybe even multiple lines\ntype Wibble {\n /// Some more exciting documentation\n Wibble(String)\n /// The most exciting documentation\n Wobble(arg: Int)\n}" 4 + --- 5 + /// Exciting documentation 6 + /// Maybe even multiple lines 7 + type Wibble { 8 + ▔▔▔▔▔↑▔▔▔▔▔▔▔ 9 + /// Some more exciting documentation 10 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 11 + Wibble(String) 12 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 13 + /// The most exciting documentation 14 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 15 + Wobble(arg: Int) 16 + ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ 17 + } 18 + 19 + 20 + 21 + ----- Hover content (markdown) ----- 22 + ```gleam 23 + Wibble 24 + ``` 25 + Exciting documentation 26 + Maybe even multiple lines