33// Implementations of language utility providers for the captions language.
44// ==========================================================================
55
6- import vscode from "vscode" ;
6+ import vscode , { window } from "vscode" ;
77import KvDocument from "./KvDocument" ;
88//import { KvDocumentFormatter } from "./KvFormatter";
99import { CaptionsColorsProvider } from "./CaptionsColorsProvider" ;
@@ -25,7 +25,32 @@ export function init(context: vscode.ExtensionContext): void {
2525 const captionsTokenProvider = vscode . languages . registerDocumentSemanticTokensProvider ( selectorAll , new CaptionsSemanticTokenProvider ( ) , KvDocument . tokenLegend ) ;
2626 // TODO: Re-enable formatting here too
2727 //const captionsFormatter = vscode.languages.registerDocumentFormattingEditProvider(selectorAll, new KvDocumentFormatter());
28- context . subscriptions . push ( captionsColors , captionsTokenProvider ) ;
28+
29+ const onEditorChange = window . onDidChangeActiveTextEditor ( ( editor : vscode . TextEditor | undefined ) : void => {
30+ if ( editor === undefined ) return ;
31+ if ( editor . document . languageId !== "captions" ) return ;
32+
33+ recommendCompilerSetup ( context ) ;
34+ } ) ;
35+
36+ context . subscriptions . push ( captionsColors , captionsTokenProvider , onEditorChange ) ;
2937}
3038
39+ function recommendCompilerSetup ( context : vscode . ExtensionContext ) : void {
40+
41+ const alreadyRecommended = context . globalState . get ( "captionsCompiler.recommended" , false ) ;
42+
43+ if ( alreadyRecommended ) return ;
44+
45+ window . showInformationMessage ( "Captions can be compiled in the editor using the launch button on the top right. Do you want to set up the compiler?" ,
46+ "Set up compiler" , "Ask later" , "Don't ask again" )
47+ . then ( ( value : string | undefined ) => {
48+ if ( value === "Set up compiler" ) {
49+ vscode . commands . executeCommand ( "workbench.action.openSettings" , "sourceEngine.captionCompiler" ) ;
50+ }
51+
52+ if ( value === "Ask later" ) return ;
3153
54+ context . globalState . update ( "captionsCompiler.recommended" , true ) ;
55+ } ) ;
56+ }
0 commit comments