import * as cmd from "./commands" ; import * as vscode from "vscode" ; import * as fs from "fs" ; import { LanguageClient } from 'vscode-languageclient' ; import { MintFormattingProvider } from "./formatter" ; let client ; export async function activate ( context , isRestart = false ) { vscode . commands . executeCommand ( "setContext" , "mint:isActivated" , true ) ; vscode . languages . registerDocumentFormattingEditProvider ( "mint" , new MintFormattingProvider ( ) ) ; vscode . commands . registerCommand ( "mint.build" , cmd . mintBuildCommand ) ; vscode . commands . registerCommand ( "mint.compile" , cmd . mintCompileCommand ) ; vscode . commands . registerCommand ( "mint.docs" , cmd . mintDocsCommand ) ; vscode . commands . registerCommand ( "mint.formatAll" , cmd . mintFormatAllCommand ) ; vscode . commands . registerCommand ( "mint.init" , cmd . mintInitCommand ) ; vscode . commands . registerCommand ( "mint.install" , cmd . mintInstallCommand ) ; vscode . commands . registerCommand ( "mint.loc" , cmd . mintCountLinesCommand ) ; vscode . commands . registerCommand ( "mint.start" , cmd . mintStartCommand ) ; vscode . commands . registerCommand ( "mint.test" , cmd . mintTestCommand ) ; vscode . commands . registerCommand ( "mint.version" , cmd . mintVersionCommand ) ; const binaryLocation = vscode . workspace . getConfiguration ( 'mint.languageServer' ) . get ( 'location' ) ; if ( binaryLocation ) { if ( fs . existsSync ( binaryLocation ) ) { client = new LanguageClient ( 'mint_language_server' , 'Mint Language Server' , { command : binaryLocation , args : [ 'ls' ] , } , { documentSelector : [ { scheme : 'file' , language : 'mint' } , ] } ) ; context . subscriptions . push ( client . start ( ) ) ; } else { vscode . window . showErrorMessage ( 'Mint binary not found! You specified ' + binaryLocation ) ; } } } export async function deactivate ( isRestart = false ) { vscode . commands . executeCommand ( "setContext" , "mint:isActivated" , false ) ; if ( client ) { client . stop ( ) ; } }