import { DocumentSelector , ExtensionContext , workspace } from 'vscode' ; import { LanguageClient , LanguageClientOptions , ServerOptions , TransportKind } from 'vscode-languageclient' ; import { default_settings } from './svutils' ; import * as path from 'path' ; const selector = [ { scheme : 'file' , language : 'systemverilog' } , { scheme : 'file' , language : 'verilog' } ] ; let client ; let settings = default_settings ; function getSettings ( client ) { let newSettings = new Object ( ) ; let workspaceConfig = workspace . getConfiguration ( ) ; for ( let [ prop , val ] of settings ) { let newVal = workspaceConfig . get ( prop ) ; if ( newVal != val ) { newSettings [ prop ] = newVal ; settings . set ( prop , newVal ) ; } } return { settings : newSettings } ; } export function activate ( context ) { let serverModule = context . asAbsolutePath ( path . join ( 'dist' , 'svlangserver.js' ) ) ; let serverOptions = { run : { module : serverModule , transport : TransportKind . ipc } , debug : { module : serverModule , transport : TransportKind . ipc } } ; let clientOptions = { outputChannelName : "SVLangServer" , documentSelector : selector as string [ ] } ; client = new LanguageClient ( 'systemverilog' , "svlangserver LSP" , serverOptions , clientOptions ) ; context . subscriptions . push ( client . start ( ) ) ; client . onReady ( ) . then ( ( ) => { workspace . onDidChangeConfiguration ( ( ) => { client . sendNotification ( 'workspace/didChangeConfiguration' , getSettings ( client ) ) ; } ) ; } ) ; } export function deactivate ( ) { if ( ! client ) { return undefined ; } return client . stop ( ) ; }