1
1
"use strict" ;
2
2
3
- import { ExtensionContext , commands , window , workspace } from "vscode" ;
3
+ import { ConfigurationChangeEvent , ExtensionContext , commands , window , workspace } from "vscode" ;
4
4
import { LanguageClient , ServerOptions } from "vscode-languageclient/node" ;
5
5
import { promisify } from "util" ;
6
6
import { exec } from "child_process" ;
@@ -27,8 +27,28 @@ export function activate(context: ExtensionContext) {
27
27
return startLanguageServer ( ) ;
28
28
29
29
async function startLanguageServer ( ) {
30
- outputChannel . appendLine ( "Starting language server..." ) ;
31
- let run : ServerOptions = { command : "stree" , args : [ "lsp" ] } ;
30
+ const config = workspace . getConfiguration ( "syntaxTree" ) ;
31
+ const addlPlugins = config . get < string [ ] > ( "additionalPlugins" ) || [ ] ;
32
+ const singleQuotes = config . get < boolean > ( "singleQuotes" ) ;
33
+ const trailingComma = config . get < boolean > ( "trailingComma" ) ;
34
+
35
+ const args = [ "lsp" ] ;
36
+
37
+ const plugins = new Set < string > ( ) ;
38
+ if ( singleQuotes ) {
39
+ plugins . add ( "plugin/single_quotes" ) ;
40
+ }
41
+ if ( trailingComma ) {
42
+ plugins . add ( "plugin/trailing_comma" ) ;
43
+ }
44
+ addlPlugins . forEach ( plugins . add ) ;
45
+
46
+ if ( plugins . size ) {
47
+ args . push ( `--plugins=${ Array . from ( plugins ) . join ( "," ) } ` ) ;
48
+ }
49
+
50
+ outputChannel . appendLine ( `Starting language server with ${ plugins . size } plugin(s)...` ) ;
51
+ let run : ServerOptions = { command : "stree" , args } ;
32
52
33
53
if ( workspace . workspaceFolders ) {
34
54
const cwd = workspace . workspaceFolders ! [ 0 ] . uri . fsPath ;
0 commit comments