Skip to content

feat: add setting to disable completion - #3058

Draft
imtiyazakiwat wants to merge 1 commit into
ansible:mainfrom
imtiyazakiwat:feat/disable-completion
Draft

feat: add setting to disable completion#3058
imtiyazakiwat wants to merge 1 commit into
ansible:mainfrom
imtiyazakiwat:feat/disable-completion

Conversation

@imtiyazakiwat

Copy link
Copy Markdown

Summary

Adds ansible.completion.enabled (default true) so users who use the
extension mainly for syntax highlighting can turn off completion entirely.
This was requested in #837, where a maintainer indicated a PR would be
welcome.

Implementation

Follows the existing ansible.validation.enabled pattern:

  • ansible.completion.enabled declared in the existing Completion section
    of contributes.configuration. No new configuration section was added, since
    packages/ansible-language-server/test/globalSetup.ts reads
    contributes.configuration[6] by index.
  • Typed in ExtensionSettings.completion and CompletionSettingsWithDescription,
    with the default and description in SettingsManager.
  • doCompletion reads settings and returns [] at the top of the function,
    deliberately above the schema-completion branch, so schema-backed files
    such as meta/main.yml are covered too.
  • doCompletionResolve returns the item untouched when the setting is off.
  • The two existing ansible.completion.* toggles now cross-reference the new
    setting in their descriptions, matching how ansible.validation.lint.enabled
    refers to ansible.validation.enabled.

Note: this suppresses items offered by this extension. VS Code's own
word-based suggestions remain governed by editor.wordBasedSuggestions, and
Lightspeed inline suggestions stay under
ansible.lightspeed.suggestions.enabled.

Tests

Four cases added to completionProvider.test.ts:

  1. items are offered while enabled (sanity)
  2. no items once disabled
  3. schema-based completions are suppressed too, asserting the stubbed schema
    completer is not consulted a second time, which pins the guard's position
    ahead of the schema branch
  4. doCompletionResolve leaves insertText undefined when disabled

Verification

  • vitest run over completionProvider, completionResolver and
    settingsManager suites: 77 passed, 57 skipped (@ee container tests), exit 0
  • task lint: 19 hooks passed, 0 failed
  • task e2e and task wdio were not run locally; leaving this as a draft for CI

fixes: #837

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Adds `ansible.completion.enabled` (default true) so users who want the
extension only for syntax highlighting can turn off all completion
items.

The guard runs at the top of doCompletion, ahead of the schema-based
completion branch, so schema-backed files such as meta/main.yml are
covered as well. doCompletionResolve leaves items untouched when the
setting is off.

fixes: ansible#837
@imtiyazakiwat
imtiyazakiwat force-pushed the feat/disable-completion branch from 272b737 to 2d1dd32 Compare July 25, 2026 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

Option to completely disable autocomplete

1 participant