Runtime assertions for Ruby literal.fun
ruby
5
fork

Configure Feed

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

Show prop type signature in Ruby LSP (#330)

Add type signatures to the LSP auto-complete and hover cards.

<img width="790" alt="Screenshot 2025-06-06 at 12 10 52"
src="https://github.com/user-attachments/assets/fe2eaf50-6635-48da-b148-732ecc856f66"
/>

authored by

Joel Drapper and committed by
GitHub
417b16cb f3d7d620

+7 -2
+7 -2
lib/ruby_lsp/literal/addon.rb
··· 39 39 end 40 40 41 41 case args 42 - in [Prism::SymbolNode[unescaped: String => prop_name], *] 42 + in [Prism::SymbolNode[unescaped: String => prop_name], Prism::Node => prop_type, *] 43 + prop_type_location = prop_type.location 44 + prop_type_indentation = prop_type_location.source_lines[prop_type_location.start_line - 1][/\A\s*/] 45 + 46 + prop_signature = prop_type_location.slice.lines.map { |line| line.delete_prefix(prop_type_indentation) }.join 47 + 43 48 @listener.instance_exec do 44 49 @index.add(RubyIndexer::Entry::InstanceVariable.new( 45 50 "@#{prop_name}", 46 51 @uri, 47 52 RubyIndexer::Location.from_prism_location(node.location, @code_units_cache), 48 - collect_comments(node), 53 + [collect_comments(node), "**Type:**\n```ruby\n#{prop_signature}\n```"].join("\n\n"), 49 54 owner, 50 55 )) 51 56 end