Ruby LSP indexing enhancements in Literal and Phlex
In the last week or so Zed started sending textDocument/codeLens
requests meaning Ruby LSP is now correctly indexing projects as they change. 🎉
The timing is perfect because I finally figured out how to write Indexing Enhancements. The latest versions of Literal, Phlex and Phlex-Rails now all support basic indexing enhancements for some features.
In Literal, a new indexing enhancement on the prop
method adds an instance variable for each property to the index.
In Phlex, an indexing enhancement on register_element
adds the corresponding instance method to the index, with the correct signature and a comment that shows which HTML tag will be output.
And in Phlex-Rails, theres an indexing enhancement on register_value_helper
and register_output_helper
that adds the generated helper method to the index.
These enhancements take the existing LSP-driven API design even further.
I hope we can do even more to improve the developer experience when Ruby LSP adds support for something like lazy index entries and type hints, but this is a great start.
If you’re interested, you can see the implementations here: