ruby-lsp
ruby-lsp copied to clipboard
Provide code navigation features to erb files
Motivation
This commit allows Ruby LSP to start handling requests for ERB files, such as definition, completion, hover...etc., which will give users the same level of code navigation features in ERB and Ruby.
However, certain requests are not supported:
- formatting
- on_type_formatting
- diagnostics
- code_actions
Implementation
- Update extension so VS Code knows it can send erb requests to Ruby LSP too
- Introduce
ERBDocument(written by @vinistock) with a scanner that returns extracted Ruby and remaining html code (not used yet) - Make the requests that don't support erb files return early
- Avoid assuming
Objectas view helper calls receiver type as it'll stop Ruby LSP from suggesting any definition candidates
Demo
https://github.com/Shopify/ruby-lsp/assets/5079556/39cd8227-721f-40c9-8b9c-66316fc098b3
Automated Tests
Manual Tests
Worth adding an ERB fixture just for ease of tophatting?
Hello,
Is there a recommended setup that does format on save for erb files?
We don't support linting or formatting ERB yet. You can follow progress on #536.