@@ -6,9 +6,19 @@ import { type ResolvedReference, Resolver, parse } from '@authzed/spicedb-parser
66import { getInstallCommand , languageServerBinaryPath } from './binary' ;
77import { CheckWatchProvider } from './checkwatchprovider' ;
88
9+ function reassignZedYamlLanguage ( doc : vscode . TextDocument ) {
10+ if ( doc . fileName . endsWith ( '.zed.yaml' ) && doc . languageId !== 'spicedb-yaml' ) {
11+ vscode . languages . setTextDocumentLanguage ( doc , 'spicedb-yaml' ) ;
12+ }
13+ }
14+
915export function activate ( context : vscode . ExtensionContext ) {
1016 console . log ( 'spicedb-vscode is now active' ) ;
1117
18+ // Reassign language for any already-open .zed.yaml files detected as plain yaml
19+ vscode . workspace . textDocuments . forEach ( reassignZedYamlLanguage ) ;
20+ context . subscriptions . push ( vscode . workspace . onDidOpenTextDocument ( reassignZedYamlLanguage ) ) ;
21+
1222 const checkWatchProvider = new CheckWatchProvider ( context . extensionUri ) ;
1323
1424 context . subscriptions . push ( vscode . window . registerWebviewViewProvider ( CheckWatchProvider . viewType , checkWatchProvider ) ) ;
@@ -197,9 +207,12 @@ async function startLanguageServer(context: vscode.ExtensionContext) {
197207 } ;
198208
199209 const clientOptions : LanguageClientOptions = {
200- documentSelector : [ { scheme : 'file' , language : 'spicedb' } ] ,
210+ documentSelector : [
211+ { scheme : 'file' , language : 'spicedb' } ,
212+ { scheme : 'file' , language : 'spicedb-yaml' } ,
213+ ] ,
201214 synchronize : {
202- fileEvents : vscode . workspace . createFileSystemWatcher ( '**/.zed' ) ,
215+ fileEvents : vscode . workspace . createFileSystemWatcher ( '**/* .zed{,.yaml} ' ) ,
203216 } ,
204217 } ;
205218
0 commit comments