Skip to content
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

Ruby LSP runs code actions with every key input with VIM insertion mode #2933

Closed
erickguan opened this issue Nov 28, 2024 · 3 comments
Closed
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes

Comments

@erickguan
Copy link

Description

Ruby LSP Information


### Ruby LSP Information

#### VS Code Version

1.95.3

#### Ruby LSP Extension Version

0.8.14

#### Ruby LSP Server Version

0.22.1

#### Ruby LSP Addons

- Ruby LSP Rails

#### Ruby Version

3.2.4

#### Ruby Version Manager

mise

#### Installed Extensions

<details>
<summary>Click to expand</summary>

- EditorConfig (0.16.4)
- cmake (0.0.17)
- cmake-tools (1.19.52)
- code-spell-checker (4.0.21)
- cpptools (1.22.11)
- cpptools-extension-pack (1.3.0)
- cpptools-themes (2.0.0)
- debugpy (2024.12.0)
- even-better-toml (0.19.2)
- git-graph (1.30.0)
- gitlens (16.0.4)
- prettier-sql-vscode (1.6.0)
- python (2024.20.0)
- ruby-lsp (0.8.14)
- solarized (2.6.0)
- terraform (2.34.0)
- vim (1.28.1)
- vscode-docker (1.29.3)
- vscode-github-actions (0.27.0)
- vscode-pull-request-github (0.100.3)
- vscode-pylance (2024.11.3)
- vscode-yaml (1.15.0)
- vsliveshare (1.0.5941)
</details>

#### Ruby LSP Settings

<details>
<summary>Click to expand</summary>

##### Workspace

```json
{}
User
{
  "enabledFeatures": {
    "codeActions": false,
    "diagnostics": false,
    "documentHighlights": true,
    "documentLink": true,
    "documentSymbols": true,
    "foldingRanges": true,
    "formatting": false,
    "hover": true,
    "inlayHint": true,
    "onTypeFormatting": false,
    "selectionRanges": true,
    "semanticHighlighting": true,
    "completion": true,
    "codeLens": true,
    "definition": true,
    "workspaceSymbol": true,
    "signatureHelp": true,
    "typeHierarchy": true
  },
  "featuresConfiguration": {},
  "addonSettings": {},
  "rubyVersionManager": {
    "identifier": "mise",
    "miseExecutablePath": "/opt/homebrew/bin/mise"
  },
  "customRubyCommand": "",
  "formatter": "auto",
  "linters": null,
  "bundleGemfile": "",
  "testTimeout": 30,
  "branch": "",
  "pullDiagnosticsOn": "both",
  "useBundlerCompose": false,
  "bypassTypechecker": false,
  "rubyExecutablePath": "",
  "indexing": {},
  "erbSupport": true,
  "useLauncher": false,
  "featureFlags": {
    "all": true
  }
}

### Reproduction steps

1. Start the Ruby LSP with VS Code
2. Install VIM plugin
3. Open a Ruby file in a large Rails project (1000k+ files)
4. Insert a charachar with `INSERT` mode
5. The second key stroke takes a few seconds to appear. Switching to normal mode with `ESC` takes a few seconds too.

```ruby
gem 'brakeman', '~> 5.4', require: false
gem 'rubocop', '~> 1.51', require: false

I can see the extension host becomes unresponsive when RubyLSP runs brakeman and rubocop. (CPU 100%).

@erickguan erickguan added bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes labels Nov 28, 2024
@vinistock
Copy link
Member

Thank you for the bug report! I'm a bit confused though. We don't run brakeman in the Ruby LSP, unless you have some add-on for brakeman.

Also, I'm not sure how the Vim plugin could be impacting this. It's VS Code itself that decides when to trigger code action providers. FWIW, I use the Vim plugin myself.

@andyw8
Copy link
Contributor

andyw8 commented Nov 28, 2024

@erickguan might you have some config in a .vimrc or similar that the extension is picking up?

@erickguan
Copy link
Author

Also, I'm not sure how the Vim plugin could be impacting this. It's VS Code itself that decides when to trigger code action providers. FWIW, I use the Vim plugin myself.

Thanks for your time! From your VIM setup, I was able to find my mistake when debugging again. This is on me. I have an extension fnando.linter runs brakeman and then rubocop.

Name: Linter
Id: fnando.linter
Description: An extension for VSCode that provides linting for multiple languages in on package.
Version: 0.0.19
Publisher: Nando Vieira
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=fnando.linter

I used it for YAMLint but failed to capture its existence when I debugged this performance.

When I disabled RubyLSP, the performance was slower but okay. When I enabled RubyLSP, two extensions hogged my CPU.

@erickguan might you have some config in a .vimrc or similar that the extension is picking up?

@andyw8 Thanks for your reply. It's my environmental contamination (M2 Pro).


ruby-lsp process on save reaches around 30-50% peak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

No branches or pull requests

3 participants