import { Uri , workspace } from 'vscode' ; import { LanguageClient , LanguageClientOptions , ServerOptions , TransportKind } from 'vscode-languageclient' ; export function code2ProtocolConverter ( value ) { if ( /^win32/ . test ( process . platform ) ) { return value . toString ( ) . replace ( '%3A' , ':' ) ; } else { return value . toString ( ) ; } } function protocol2CodeConverter ( value ) { return Uri . parse ( value ) ; } export function createLanguageClient ( serverPath ) { const debugOptions = { execArgv : [ '--nolazy' , '--inspect=6009' ] } ; const serverOptions = { run : { module : serverPath , transport : TransportKind . ipc } , debug : { module : serverPath , transport : TransportKind . ipc , options : debugOptions } } ; const clientOptions = { documentSelector : [ { language : 'html' , scheme : 'file' } , { language : 'javascript' , scheme : 'file' } ] , synchronize : { fileEvents : [ workspace . createFileSystemWatcher ( '**/*.resource' ) , workspace . createFileSystemWatcher ( '**/labels/CustomLabels.labels-meta.xml' ) , workspace . createFileSystemWatcher ( '**/staticresources/*.resource-meta.xml' ) , workspace . createFileSystemWatcher ( '**/contentassets/*.asset-meta.xml' ) , workspace . createFileSystemWatcher ( '**/lwc/*/*.js' ) , workspace . createFileSystemWatcher ( '**/modules/*/*/*.js' ) , workspace . createFileSystemWatcher ( '**/' , false , true , false ) ] } , uriConverters : { code2Protocol : code2ProtocolConverter , protocol2Code : protocol2CodeConverter } } ; return new LanguageClient ( 'lwcLanguageServer' , 'LWC Language Server' , serverOptions , clientOptions ) ; }