-
Notifications
You must be signed in to change notification settings - Fork 234
Add VS Code rubyLsp.serverPath configuration #3713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -58,6 +58,20 @@ with a debugger. Note that the debug mode applies only until the editor is close | |||||
| Caveat: since you are debugging the language server instance that is currently running in your own editor, features will | ||||||
| not be available if the execution is currently suspended at a breakpoint. | ||||||
|
|
||||||
| #### Configuring the server version | ||||||
|
|
||||||
| When developing the Ruby LSP server, you may want to test your changes in your own Ruby projects to ensure they work correctly in real-world scenarios. | ||||||
|
|
||||||
| The running server, even in debug mode, will default to the installed release version*. You can use the `rubyLsp.serverPath` configuration setting in the target workspace to start your local copy instead. Make sure to restart the language server after making changes to pick up your updates. | ||||||
|
||||||
| The running server, even in debug mode, will default to the installed release version*. You can use the `rubyLsp.serverPath` configuration setting in the target workspace to start your local copy instead. Make sure to restart the language server after making changes to pick up your updates. | |
| The running server, even in debug mode, will default to the installed release version*. You can use the `rubyLsp.serverPath` configuration setting in the target workspace to start your local copy instead. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,13 @@ def stdout | |
| def initialize(project_path, **options) | ||
| @project_path = project_path | ||
| @branch = options[:branch] #: String? | ||
| @path = options[:path] #: String? | ||
| @launcher = options[:launcher] #: bool? | ||
|
|
||
| if @branch && [email protected]? && @path && [email protected]? | ||
|
||
| raise ArgumentError, "Branch and path options are mutually exclusive. Please specify only one." | ||
| end | ||
|
|
||
| patch_thor_to_print_progress_to_stderr! if @launcher | ||
|
|
||
| # Regular bundle paths | ||
|
|
@@ -165,7 +171,13 @@ def write_custom_gemfile | |
|
|
||
| unless @dependencies["ruby-lsp"] | ||
| ruby_lsp_entry = +'gem "ruby-lsp", require: false, group: :development' | ||
| ruby_lsp_entry << ", github: \"Shopify/ruby-lsp\", branch: \"#{@branch}\"" if @branch | ||
| if @branch && [email protected]? | ||
| ruby_lsp_entry << ", github: \"Shopify/ruby-lsp\", branch: \"#{@branch}\"" | ||
| end | ||
| if @path && [email protected]? | ||
| absolute_path = File.expand_path(@path, @project_path) | ||
|
||
| ruby_lsp_entry << ", path: \"#{absolute_path}\"" | ||
| end | ||
| parts << ruby_lsp_entry | ||
| end | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -467,6 +467,11 @@ | |
| "type": "string", | ||
| "default": "" | ||
| }, | ||
| "rubyLsp.serverPath": { | ||
| "description": "Absolute or workspace-relative path to a local ruby-lsp repository or its ruby-lsp executable. Only supported if not using bundleGemfile", | ||
|
||
| "type": "string", | ||
| "default": "" | ||
|
||
| }, | ||
| "rubyLsp.pullDiagnosticsOn": { | ||
| "description": "When to pull diagnostics from the server (on change, save or both). Selecting 'save' may significantly improve performance on large files", | ||
| "type": "string", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import path from "path"; | ||
| import fs from "fs"; | ||
| import os from "os"; | ||
| import { performance as Perf } from "perf_hooks"; | ||
|
|
||
|
|
@@ -85,6 +86,7 @@ function getLspExecutables(workspaceFolder: vscode.WorkspaceFolder, env: NodeJS. | |
| const customBundleGemfile: string = config.get("bundleGemfile")!; | ||
| const useBundlerCompose: boolean = config.get("useBundlerCompose")!; | ||
| const bypassTypechecker: boolean = config.get("bypassTypechecker")!; | ||
| const serverPath: string = config.get("serverPath")!; | ||
|
|
||
| const executableOptions: ExecutableOptions = { | ||
| cwd: workspaceFolder.uri.fsPath, | ||
|
|
@@ -119,13 +121,40 @@ function getLspExecutables(workspaceFolder: vscode.WorkspaceFolder, env: NodeJS. | |
| options: executableOptions, | ||
| }; | ||
| } else { | ||
| const args = []; | ||
| const workspacePath = workspaceFolder.uri.fsPath; | ||
| const command = | ||
| path.basename(workspacePath) === "ruby-lsp" && os.platform() !== "win32" | ||
| ? path.join(workspacePath, "exe", "ruby-lsp") | ||
| : "ruby-lsp"; | ||
| let command: string; | ||
|
|
||
| const args = []; | ||
| if (serverPath.length > 0 && branch.length > 0) { | ||
|
||
| throw new Error( | ||
| 'Invalid configuration: "rubyLsp.serverPath" and "rubyLsp.branch" cannot both be set. Please unset one of them.', | ||
| ); | ||
| } | ||
|
|
||
| if (serverPath.length > 0) { | ||
| const absoluteServerPath = path.isAbsolute(serverPath) ? serverPath : path.resolve(workspacePath, serverPath); | ||
| const exists = fs.existsSync(absoluteServerPath); | ||
|
|
||
| if (exists) { | ||
| args.push("--path", absoluteServerPath); | ||
| const stat = fs.statSync(absoluteServerPath); | ||
|
|
||
| if (stat.isDirectory()) { | ||
| command = os.platform() !== "win32" ? path.join(absoluteServerPath, "exe", "ruby-lsp") : "ruby-lsp"; | ||
| } else { | ||
| command = absoluteServerPath; | ||
| } | ||
| } else { | ||
| throw new Error( | ||
| `The configured rubyLsp.serverPath "${serverPath}" does not exist at "${absoluteServerPath}". `, | ||
| ); | ||
| } | ||
|
||
| } else { | ||
| command = | ||
| path.basename(workspacePath) === "ruby-lsp" && os.platform() !== "win32" | ||
| ? path.join(workspacePath, "exe", "ruby-lsp") | ||
| : "ruby-lsp"; | ||
| } | ||
|
|
||
| if (branch.length > 0) { | ||
| args.push("--branch", branch); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we call this
--lsp-pathto prevent any confusion with a potential ability to configure the workspace path or some other path?