Change:
It would be really helpful if a variable with the repository name (workspace name or opened folder) that was available to use in the snippets. In my case, i use the snippets to create copyright messages, and i am using the project name (the same of the repository) as part of this message.
Hey I'd like to work on this. Can I give it a shot? I appreciate if you have any quick guidance.
Snippet variables are implemented and instantiated . add a variable resolver that uses the (like the and ) add a test here
Thanks :)

Discussion:
import { IIdentifiedSingleEditOperation, ITextModel, TrackedRangeStickiness } from 'vs/editor/common/model'; import { ModelDecorationOptions } from 'vs/editor/common/model/textModel'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; <ins> import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; </ins> import { optional } from 'vs/platform/instantiation/common/instantiation'; import { Choice, Placeholder, SnippetParser, Text, TextmateSnippet } from './snippetParser'; <del> import { ClipboardBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, SelectionBasedVariableResolver, TimeBasedVariableResolver, CommentBasedVariableResolver } from './snippetVariables'; </del> <ins> import { ClipboardBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, SelectionBasedVariableResolver, TimeBasedVariableResolver, CommentBasedVariableResolver, WorkspaceBasedVariableResolver } from './snippetVariables'; </ins> import { registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import * as colors from 'vs/platform/theme/common/colorRegistry';

const modelBasedVariableResolver = new ModelBasedVariableResolver(model); const clipboardService = editor.invokeWithinContext(accessor => accessor.get(IClipboardService, optional)); <ins> const workspaceService = editor.invokeWithinContext(accessor => accessor.get(IWorkspaceContextService, optional)); </ins> let delta = 0;

new ClipboardBasedVariableResolver(clipboardService, idx, indexedSelections.length), new SelectionBasedVariableResolver(model, selection), new CommentBasedVariableResolver(model), <del> new TimeBasedVariableResolver </del> <ins> new TimeBasedVariableResolver, new WorkspaceBasedVariableResolver(workspaceService), </ins> ])); const offset = model.getOffsetAt(start) + delta;

import { LanguageConfigurationRegistry } from 'vs/editor/common/modes/languageConfigurationRegistry'; import { getLeadingWhitespace, commonPrefixLength, isFalsyOrWhitespace, pad } from 'vs/base/common/strings'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; <ins> import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { isSingleFolderWorkspaceIdentifier, toWorkspaceIdentifier, WORKSPACE_EXTENSION } from 'vs/platform/workspaces/common/workspaces'; </ins> export const KnownSnippetVariableNames = Object.freeze({ 'CURRENT_YEAR': true,

'BLOCK_COMMENT_START': true, 'BLOCK_COMMENT_END': true, 'LINE_COMMENT': true, <ins> 'WORKSPACE_NAME': true, </ins> }); export class CompositeSnippetVariableResolver implements VariableResolver {

return undefined; } } <ins> export class WorkspaceBasedVariableResolver implements VariableResolver { constructor( private readonly _workspaceService: IWorkspaceContextService, ) { // } resolve(variable: Variable): string | undefined { if (variable.name !== 'WORKSPACE_NAME' || !this._workspaceService) { return undefined; } const workspaceIdentifier = toWorkspaceIdentifier(this._workspaceService.getWorkspace()); if (!workspaceIdentifier) { return undefined; } if (isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) { return basename(workspaceIdentifier.path); } const filename = basename(workspaceIdentifier.configPath.path); return filename.substr(0, filename.length - WORKSPACE_EXTENSION.length - 1); } } </ins>  No newline at end of file

import { isWindows } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; import { Selection } from 'vs/editor/common/core/selection'; <del> import { SelectionBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, ClipboardBasedVariableResolver, TimeBasedVariableResolver } from 'vs/editor/contrib/snippet/snippetVariables'; </del> <ins> import { SelectionBasedVariableResolver, CompositeSnippetVariableResolver, ModelBasedVariableResolver, ClipboardBasedVariableResolver, TimeBasedVariableResolver, WorkspaceBasedVariableResolver } from 'vs/editor/contrib/snippet/snippetVariables'; </ins> import { SnippetParser, Variable, VariableResolver } from 'vs/editor/contrib/snippet/snippetParser'; import { TextModel } from 'vs/editor/common/model/textModel'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; <ins> import { Workspace, toWorkspaceFolders, IWorkspace, IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; </ins> suite('Snippet Variables Resolver', function () {

snippet.resolveVariables({ resolve() { return '11'; } }); assert.equal(snippet.toString(), 'It is not line 10'); }); <del> }); </del> <ins> test('Add workspace name variable for snippets #68261', function () { let workspace: IWorkspace; let resolver: VariableResolver; const workspaceService = new class implements IWorkspaceContextService { _serviceBrand: any; _throw = () => { throw new Error(); }; onDidChangeWorkbenchState = this._throw; onDidChangeWorkspaceName = this._throw; onDidChangeWorkspaceFolders = this._throw; getCompleteWorkspace = this._throw; getWorkspace(): IWorkspace { return workspace; } getWorkbenchState = this._throw; getWorkspaceFolder = this._throw; isCurrentWorkspace = this._throw; isInsideWorkspace = this._throw; }; resolver = new WorkspaceBasedVariableResolver(workspaceService); // empty workspace workspace = new Workspace(''); assertVariableResolve(resolver, 'WORKSPACE_NAME', undefined); // single folder workspace without config workspace = new Workspace('', toWorkspaceFolders([{ path: '/folderName' }])); assertVariableResolve(resolver, 'WORKSPACE_NAME', 'folderName'); // workspace with config workspace = new Workspace('', toWorkspaceFolders([{ path: 'folderName' }]), URI.file('testWorkspace.code-workspace')); assertVariableResolve(resolver, 'WORKSPACE_NAME', 'testWorkspace'); }); }); </ins>  No newline at end of file