@@ -11,13 +11,15 @@ import Visualize from "./Visualize";
11
11
const promiseExec = promisify ( exec ) ;
12
12
13
13
export function activate ( context : ExtensionContext ) {
14
- let languageClient : LanguageClient | null = null ;
15
14
const outputChannel = window . createOutputChannel ( "Syntax Tree" ) ;
15
+ let languageClient : LanguageClient | null = null ;
16
+ let visualizer : Visualize | null = null ;
16
17
17
18
context . subscriptions . push (
18
19
commands . registerCommand ( "syntaxTree.start" , startLanguageServer ) ,
19
20
commands . registerCommand ( "syntaxTree.stop" , stopLanguageServer ) ,
20
21
commands . registerCommand ( "syntaxTree.restart" , restartLanguageServer ) ,
22
+ commands . registerCommand ( "syntaxTree.visualize" , ( ) => visualizer ?. visualize ( ) ) ,
21
23
commands . registerCommand ( "syntaxTree.showOutputChannel" , ( ) => outputChannel . show ( ) ) ,
22
24
outputChannel
23
25
) ;
@@ -35,7 +37,7 @@ export function activate(context: ExtensionContext) {
35
37
await promiseExec ( "bundle show syntax_tree" , { cwd } ) ;
36
38
run = { command : "bundle" , args : [ "exec" , "stree" , "lsp" ] , options : { cwd } } ;
37
39
} catch {
38
- outputChannel . appendLine ( "No bundled syntax_tree, running global stree." ) ;
40
+ outputChannel . appendLine ( "No bundled syntax_tree, running global stree." ) ;
39
41
}
40
42
}
41
43
@@ -49,9 +51,10 @@ export function activate(context: ExtensionContext) {
49
51
context . subscriptions . push ( languageClient . start ( ) ) ;
50
52
await languageClient . onReady ( ) ;
51
53
54
+ visualizer = new Visualize ( languageClient , outputChannel ) ;
52
55
context . subscriptions . push (
53
56
new InlayHints ( languageClient , outputChannel ) ,
54
- new Visualize ( languageClient , outputChannel )
57
+ visualizer
55
58
) ;
56
59
}
57
60
0 commit comments