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

VS Code: Add customBinaryPath option

Open palkan opened this issue 8 months ago • 11 comments

Motivation

This option allows to provide any compatible binary to be used as ruby-lsp exec. This is especially useful for containerized development with VS Code running on the host machine (i.e., not using Dev Containers or Remote Containers). A typical use case is the applications using dip (and ruby-on-whales) (see #2919). However, the ability to customize the binary path has many more potential applications.

Motivation continues...

I've been using a similar approach with Zed for a while (it already provides this option). The trick is to use a thin Bash wrapper to run ruby-lsp anywhere. Mine looks as follows:

#!/bin/bash

cd $(dirname $0)/..

dip ruby-lsp $@

That's it.

With this change, we can configure rubyLsp.customBinaryPath to point to a custom executable (say, ".dockerdev/ruby-lsp"), and benefit from LSP features even without having Ruby LSP (and even Ruby) installed locally (let me omit some Docker-specific tricks used to make it work, not relevant to the proposal).

Implementation

  • Added new configuration option to package.json: customBinaryPath
  • Updated client.ts to use the new option if present to generate commands configuration.

Automated Tests

None. Couldn't find any tests for similar functionality (commands configuration). Would love to have some guidance here.

Manual Tests

Packaged and installed the forked version locally and verified that LSP works.

palkan avatar Apr 10 '25 00:04 palkan