Skip to content

Conversation

@charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented May 7, 2025

Summary

We now expect an initializationOptions setting to enable completions.

Closes #7.

Test Plan

  • Hardcoded TEST as the returned completions in the LSP.
  • Ran cargo build -p ty in the Ruff repo.
  • Set the hardcoded path in the VS Code extension:
{
    "ty.path": [
        "/Users/crmarsh/workspace/ruff/target/debug/ty"
    ]
}
  • Started the extension.
  • Verified that no completions appeared.
  • Enabled the setting:
{
    "ty.path": [
        "/Users/crmarsh/workspace/ruff/target/debug/ty"
    ],
    "ty.experimental.completions.enable": true
}
  • Verified that the TEST completion appeared.

@charliermarsh
Copy link
Member Author

Note that if you have a Python LSP enabled at all, you won't see these. Even if you uninstall Pylance, by default VS Code will fall back to Jedi, so you have to set "python.languageServer": "None" for this to matter.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting. I had thought the intent was to do this on the server side. Because this only impacts the VS Code extension right? Not anything else. (Maybe it's only worth doing for the VS Code extension.)

@charliermarsh
Copy link
Member Author

Both are required. There's a change in ruff to respect this on the server: astral-sh/ruff#17921. Any client can pass in the necessary initialization options.

@charliermarsh charliermarsh merged commit 1527ead into main May 7, 2025
1 check passed
@charliermarsh charliermarsh deleted the charlie/capabilities branch May 7, 2025 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add opt-in support for code completions

4 participants