Skip to content

Commit

Permalink
Merge pull request #1 from rubocop/add_rubocop_yjit_enabled_option
Browse files Browse the repository at this point in the history
Add `rubocop.yjitEnabled` option to enable YJIT
  • Loading branch information
koic authored Jun 29, 2023
2 parents 57d4922 + b4639c1 commit e659ef9
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

## master (unreleased)

### New features

- Add `rubocop.yjitEnabled` option to speed up the RuboCop LSP server. (@koic)

## 0.1.0 (2023-06-23)

### New features

- Initial release on VS Code Extension Marketplace (@koic)
- Initial release on VS Code Extension Marketplace. (@koic)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ Or, in `settings.json`:
}
```

### rubocop.yjitEnabled

This extension supports YJIT, which can speed up the built-in language server in RuboCop.
The `rubocop.yjitEnabled` option is enabled by default.

![YJIT Enabled](/docs/yjit-enabled.png)

You can disable YJIT by unchecking.

Or, in `settings.json`:

```json
"rubocop.yjitEnabled": false
```

### Changing settings only for a specific project

You may want to apply certain settings to a specific project, which you can do
Expand Down
Binary file added docs/yjit-enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@
"type": "string",
"default": "",
"markdownDescription": "Absolute path to rubocop executable. Overrides default search order and, if missing, will not run RuboCop via Bundler or a `rubocop` executable on your PATH.\n\nSupports variables `${userHome}`, `${pathSeparator}`, and `${cwd}`."
},
"rubocop.yjitEnabled": {
"order": 4,
"type": "boolean",
"default": true,
"markdownDescription": "Use YJIT to speed up the RuboCop LSP server."
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
DidOpenTextDocumentNotification,
Disposable,
Executable,
ExecutableOptions,
ExecuteCommandRequest,
LanguageClient,
LanguageClientOptions,
Expand Down Expand Up @@ -256,9 +257,18 @@ async function buildExecutable(): Promise<Executable | undefined> {
await displayError('Could not find RuboCop executable', ['Show Output', 'View Settings']);
} else if (await supportedVersionOfRuboCop(command)) {
const [exe, ...args] = (command).split(' ');
const env = { ...process.env };
if (getConfig<boolean>('yjitEnabled') ?? true) {
env.RUBY_YJIT_ENABLE = "true";
}
const options: ExecutableOptions = {
env: env
};

return {
command: exe,
args: args.concat('--lsp')
args: args.concat('--lsp'),
options: options
};
}
}
Expand Down

0 comments on commit e659ef9

Please sign in to comment.