-
Notifications
You must be signed in to change notification settings - Fork 242
Description
I have checked that this feature is not already implemented
- This feature does not exist
Use case
The inlay hints are a very useful feature for displaying aditional information of the code that can be infered statically. Currently we want to make a I18n (internationalization) addon to make an inlay hint that shows the translation beside a translation call.
For example:
def foo
# hints: "Hello world!" in the editor,
# and on hover show a tooltip that shows additional informatión about that translation.
I18n.t("hello.world") Currently there is support for addons for other parts of the LSP standard like CodeLens, or Hover requests but not InlayHints so we have to override the LSP RubyLsp::Requests::InlayHints to get the desired behaviour for the i18n addon.
Other cases for different derived information could be shown in the editor for different project standards.
Description
The feature will then open as the other RubyLsp::Requests clases open the InlayHint LSP request to Addons, to support the extension to listen those requests by simply writing an addon that register InlayHint listeners.
Implementation
The implementation is the same as other Requests of the standard that supports addons. Just add an iteration on the addons to call the listeners.
module RubyLsp
class Addon
...
def create_inlay_hints_listener(response_builder, range, hints_configuration, dispatcher); end
...
end
endIn the InlayHint request iterate over the addons to call the methods implemented
module RubyLsp
module Requests
class InlayHints < Request
def initialize(...)
...
Addon.addons.each do |addon|
addon.create_inlay_hints_listener(@response_builder, start_line..end_line, hints_configuration, dispatcher)
end
end
end
endSo each addon can create and use their InlayHints listeners.
Im willing to make a PR that implement this extension support.