Shopify / Shopify/ruby-lsp

Add file watching in the server as a fallback for editors that don't support it

Open
#1,456 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help-wanted pinned
Dominant language
Ruby
Stars
2k
Forks
281
Avg merge
2h 14m
Merged PRs (30d)
6

Description

We ask editors to watch Ruby files for us here, which we use to update the codebase index upon modifications.

However, the registration may fail in two ways: some editors don't support dynamic feature registration and some don't support file watching. In those cases, only the declarations from the original indexing will be available since we will never receive the modification events.

We can use the listen gem to provide a fallback and listen to modifications from the server when file watching is not available.

This is suboptimal from a performance standpoint since having the editor watch files means that it can broadcast the modification events to all parties interested in handling those - as opposed to having each server watch files on their own. However, it's better than never updating the index.

Questions

File watching is available for VS Code. Is it also available for other popular editors such as NeoVim, Emacs, Sublime?

Implementation suggestion

My suggestion is adding an else statement where we register for file watching. In the else branch, we would:

  • Require the listen gem
  • Use listen to register the callbacks for when files are modified

We should evaluate if there's any way to share the current handler for modifications, with the one using listen.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/ruby_lsp/executor.rb at the file-watching registration around line 538 and inspect the existing modification handler around line 211. Review how the listen gem can provide a fallback when editor registration is unavailable, then verify that modifications still update the codebase index without duplicating editor events.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.