Skip to content

feat: remove custom gitlab-ci language contribution and defer to Red Hat YAML extension #117

Description

@X-Guardian

Problem statement

The extension currently registers a custom gitlab-ci language for .gitlab-ci.yml and .gitlab-ci.yaml files (see contributes.languages and contributes.grammars in package.json). This claims the language ID away from VS Code's built-in yaml, which has two consequences:

  1. Red Hat's YAML extension stops working on GitLab CI files. Once the document's language ID is gitlab-ci rather than yaml, Red Hat's schema validation, formatting, folding, and GitLab CI schema integration no longer fire. Users lose the richest YAML experience on exactly the files where they need it most.
  2. The custom grammar adds limited value over the built-in YAML grammar. It recolours roughly 13 well-known top-level keys (image:, stages:, include:, etc.) to slightly different TextMate scopes. It also defines a gitlab-ci-components rule keyed off a job-name suffix convention that doesn't match how GitLab actually identifies components in CI files, and two further rules (job-definition, job-keywords) that are declared in the grammar's repository but aren't referenced from the top-level patterns block, so they don't run. There's also no embedded shell highlighting inside script: blocks, no !reference handling, and no $CI_* variable highlighting — the kinds of things that would be a meaningful upgrade over plain YAML.

The net effect is that the extension takes a significant feature (full YAML tooling) away from users in exchange for relatively minor cosmetic differences.

Proposed solution

Remove the contributes.languages and contributes.grammars entries from package.json and delete the now-unused syntaxes/gitlab-ci.tmLanguage.json and language-configuration.json files. .gitlab-ci.yml files will then keep their natural yaml language ID and be handled by Red Hat's YAML extension (or the built-in YAML grammar if Red Hat isn't installed).

The extension's own providers (hover, completion, validation, code actions) already register against language: 'yaml' and filter by filename — they will keep working unchanged. The dead { language: 'gitlab-ci' } selectors and the document.languageId === 'gitlab-ci' defensive branches can be removed at the same time.

Optionally, add "extensionPack": ["redhat.vscode-yaml"] to nudge users to install the Red Hat YAML extension alongside this one.

Example .gitlab-ci.yml usage

N/A

Command/UI impact

New command: none.
Setting changes: none.
Browser/hover/completion changes: hover, completion, validation, and code action providers register against language: 'yaml' only; the redundant { language: 'gitlab-ci' } selectors are removed. User-visible behaviour for these providers is unchanged because the filename-based filter is the load-bearing check.

Acceptance criteria

  • Opening a .gitlab-ci.yml file shows language ID yaml in the status bar.
  • Red Hat YAML extension's schema validation activates on .gitlab-ci.yml files.
  • Hover over an include: - component: line still shows the component card.
  • Completion still suggests components after component: and versions after @.
  • Invalid component inputs still produce diagnostics.
  • npm run check-types passes; npm test passes.

Priority

Important

Alternatives considered

  • Add a setting to disable the language contribution at runtime. Not viable: VS Code reads contributes.languages and contributes.grammars from package.json at extension-load time only; there is no API to unregister a language contribution from activate(). A setting could only mutate the user's files.associations, which is surprising behaviour and still requires a reload.
  • Switch to an injection grammar (injectTo: ["source.yaml"]). Architecturally the most correct alternative — layers GitLab-specific scopes on top of the host YAML grammar without claiming the language ID. Rejected because the current grammar's actual contribution is minimal and largely redundant; the cost/benefit doesn't justify the work over simply removing it.
  • Document the user workaround (files.associations override). Useful as a transitional note but doesn't fix the default experience for users who never read the README.

Target GitLab instance(s)

both

Pre-submit checks

  • I searched existing feature requests and did not find a duplicate.
  • I included concrete examples and acceptance criteria.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions