task: Expose current buffer language as $ZED_LANGUAGE variable#51614
Merged
SomeoneToIgnore merged 3 commits intozed-industries:mainfrom Mar 17, 2026
Merged
Conversation
Closes zed-industries#12628 Add a Language variant to VariableName that resolves to the language name of the active buffer. Populated from buffer.language().name() in BasicContextProvider::build_context, following the same pattern as existing variables like File and Stem. Release Notes: - Added `$ZED_LANGUAGE` task variable that exposes the current buffer's language name
Contributor
SomeoneToIgnore
left a comment
There was a problem hiding this comment.
Actually, sorry, one more thing that's needed is an adjustment in tasks.md, could you do that?
Contributor
Author
|
Applied the |
Contributor
|
Indeed, thanks, then — just the last test fix, the one that fails in CI. |
…onfig The test was using LanguageConfig::default() which has an empty language name, so $ZED_LANGUAGE was always "". Set the name field to "Rust" and "TypeScript" to match the expected test assertions.
Contributor
Author
|
Test fix pushed in the latest commit - CI is green across all platforms now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #12628
Adds a
$ZED_LANGUAGEtask variable that resolves to the language name of the active buffer (e.g., "Rust", "Python", "Shell Script"). This lets tasks adapt behavior based on language without parsing file extensions.Use cases from the issue:
rg --type $ZED_LANGUAGE)VS Code provides equivalent functionality via
${command:activeEditorLanguageId}. Neovim exposes it as&filetype.Changes
Languagevariant toVariableNameincrates/task/src/task.rsbuffer.language().name()inBasicContextProvider::build_context(crates/project/src/task_inventory.rs), following the same pattern asFileandStemcrates/tasks_ui/src/tasks_ui.rsto include the new variableZED_LANGUAGEto the variable list indocs/src/tasks.mdTesting
Updated the existing
test_task_variablestest intasks_uito verifyZED_LANGUAGEresolves to "Rust" and "TypeScript" for the respective test buffers.This contribution was developed with AI assistance (Claude Code).
Release Notes:
$ZED_LANGUAGEtask variable that exposes the current buffer's language name