@@ -11,13 +11,15 @@ import Visualize from "./Visualize";
1111const promiseExec = promisify ( exec ) ;
1212
1313export function activate ( context : ExtensionContext ) {
14- let languageClient : LanguageClient | null = null ;
1514 const outputChannel = window . createOutputChannel ( "Syntax Tree" ) ;
15+ let languageClient : LanguageClient | null = null ;
16+ let visualizer : Visualize | null = null ;
1617
1718 context . subscriptions . push (
1819 commands . registerCommand ( "syntaxTree.start" , startLanguageServer ) ,
1920 commands . registerCommand ( "syntaxTree.stop" , stopLanguageServer ) ,
2021 commands . registerCommand ( "syntaxTree.restart" , restartLanguageServer ) ,
22+ commands . registerCommand ( "syntaxTree.visualize" , ( ) => visualizer ?. visualize ( ) ) ,
2123 commands . registerCommand ( "syntaxTree.showOutputChannel" , ( ) => outputChannel . show ( ) ) ,
2224 outputChannel
2325 ) ;
@@ -35,7 +37,7 @@ export function activate(context: ExtensionContext) {
3537 await promiseExec ( "bundle show syntax_tree" , { cwd } ) ;
3638 run = { command : "bundle" , args : [ "exec" , "stree" , "lsp" ] , options : { cwd } } ;
3739 } catch {
38- outputChannel . appendLine ( "No bundled syntax_tree, running global stree." ) ;
40+ outputChannel . appendLine ( "No bundled syntax_tree, running global stree." ) ;
3941 }
4042 }
4143
@@ -49,9 +51,10 @@ export function activate(context: ExtensionContext) {
4951 context . subscriptions . push ( languageClient . start ( ) ) ;
5052 await languageClient . onReady ( ) ;
5153
54+ visualizer = new Visualize ( languageClient , outputChannel ) ;
5255 context . subscriptions . push (
5356 new InlayHints ( languageClient , outputChannel ) ,
54- new Visualize ( languageClient , outputChannel )
57+ visualizer
5558 ) ;
5659 }
5760
0 commit comments