ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Add advanced semantic highlighting to the `ruby-lsp`

Open vinistock opened this issue 3 years ago • 0 comments

Improve our existing semantic highlighting to address more complex Ruby syntax.

  • [ ] Method and block arguments
  • [ ] Punctuation (e.g.: the namespace separator :: or the pipes in a block argument are sometimes highlighted incorrectly without semantic support)
  • [ ] Class vs constant
  • [ ] self in front of singleton method definitions and the accompanying dot
  • [ ] Add the private modifiers to methods, allowing us to highlight them slightly differently than public methods

We can also enhance the highlighting of syntax that is related to a specific tool, such as Sorbet or Rails. For example,

  • [ ] Sorbet signature declarations
  • [ ] Other Sorbet inline type annotations, such as T.let
  • [ ] Rails callbacks
  • [ ] Rails associations

Etc

  • [ ] Document how to create a theme

Additionally, the specification supports some performance related improvements we can explore. There are two existing options (maybe implementing both is a good idea too)

  • Implementing semantic tokens delta and refresh. This means we have to maintain in memory (inside our Document store) the current semantic tokens for a file and only return the difference between the previous response and the current one (indicating which tokens were deleted and which ones were added)
  • Implement semantic tokens for a range. This one is considerably easier than delta and refresh, it's just a matter of returning only the tokens for the given visible range of the document to avoid flickering. In short, it's a new request endpoint where we could simply re-use our semantic tokens implementation and filter tokens that are outside of range

Documentation: https://microsoft.github.io/language-server-protocol/specification#textDocument_semanticTokens

vinistock avatar Apr 04 '22 20:04 vinistock