import * as vscode from "vscode" ; import { lilypondExists , getConfiguration , getBinPath , setLilypondVersionInStatusBar , } from "./util" ; import { compile , CompileMode , initCompile , killCompilation } from "./lilypond" ; import { subscribeIntellisense } from "./intellisense" ; import { MIDIOut } from "./midi-out" ; import { MIDIIn } from "./midi-in" ; import { langId } from "./consts" ; export function activate ( context ) { if ( ! lilypondExists ( ) ) { vscode . window . showErrorMessage ( `\`lilypond\` (${ getBinPath ( ) }) is not found in your system.` ) ; return ; } setLilypondVersionInStatusBar ( context ) ; const config = getConfiguration ( ) ; initCompile ( ) ; const compileCmd = vscode . commands . registerCommand ( "vslilypond.compile" , ( ) => { compile ( ) ; } ) ; context . subscriptions . push ( compileCmd ) ; const compileThisSpecificFileCmd = vscode . commands . registerCommand ( "vslilypond.compileThisSpecificFile" , ( ) => { compile ( CompileMode . onCompileSpecific ) ; } ) ; context . subscriptions . push ( compileThisSpecificFileCmd ) ; const killCompilationCmd = vscode . commands . registerCommand ( "vslilypond.killCompilationProcess" , ( ) => { killCompilation ( false ) ; } ) ; context . subscriptions . push ( killCompilationCmd ) ; if ( config . compilation . compileOnSave ) { vscode . workspace . onDidSaveTextDocument ( ( textDoc ) => { if ( textDoc . languageId === langId ) { compile ( CompileMode . onSave , true , textDoc ) ; } } ) ; } if ( config . intellisense . enabled ) { const diagnosticCollection = vscode . languages . createDiagnosticCollection ( ) ; subscribeIntellisense ( context , diagnosticCollection ) ; } const playMidiCmd = vscode . commands . registerCommand ( "vslilypond.playMIDI" , ( ) => { MIDIOut . playMIDI ( ) ; } ) ; context . subscriptions . push ( playMidiCmd ) ; const playMidiFromCmd = vscode . commands . registerCommand ( "vslilypond.playMIDIFrom" , ( ) => { MIDIOut . playMIDIFrom ( ) ; } ) ; context . subscriptions . push ( playMidiFromCmd ) ; const stopMidiCmd = vscode . commands . registerCommand ( "vslilypond.stopMIDI" , ( ) => { MIDIOut . stopMIDI ( ) ; } ) ; context . subscriptions . push ( stopMidiCmd ) ; const pauseMidiCmd = vscode . commands . registerCommand ( "vslilypond.pauseMIDI" , ( ) => { MIDIOut . pauseMIDI ( ) ; } ) ; context . subscriptions . push ( pauseMidiCmd ) ; const resumeMidiCmd = vscode . commands . registerCommand ( "vslilypond.resumeMIDI" , ( ) => { MIDIOut . resumeMIDI ( ) ; } ) ; context . subscriptions . push ( resumeMidiCmd ) ; const resetMIDIOutputCmd = vscode . commands . registerCommand ( "vslilypond.resetMIDIOutput" , ( ) => { MIDIOut . resetMIDI ( ) ; } ) ; context . subscriptions . push ( resetMIDIOutputCmd ) ; const setOutputMidiDeviceCmd = vscode . commands . registerCommand ( "vslilypond.setOutputMIDIDevice" , ( ) => { MIDIOut . setOutputMIDIDevice ( ) ; } ) ; context . subscriptions . push ( setOutputMidiDeviceCmd ) ; MIDIOut . initMIDIStatusBarItems ( ) ; const startInputMidiCmd = vscode . commands . registerCommand ( "vslilypond.startMIDIInput" , ( ) => { MIDIIn . startMIDIInput ( ) ; } ) ; context . subscriptions . push ( startInputMidiCmd ) ; const stopInputMidiCmd = vscode . commands . registerCommand ( "vslilypond.stopMIDIInput" , ( ) => { MIDIIn . stopMIDIInput ( ) ; } ) ; context . subscriptions . push ( stopInputMidiCmd ) ; const setInputMidiDeviceCmd = vscode . commands . registerCommand ( "vslilypond.setInputMIDIDevice" , ( ) => { MIDIIn . setInputMIDIDevice ( ) ; } ) ; context . subscriptions . push ( setInputMidiDeviceCmd ) ; const restartMIDIInputCmd = vscode . commands . registerCommand ( "vslilypond.restartMIDIInput" , ( ) => { MIDIIn . restartMIDIInput ( ) ; } ) ; context . subscriptions . push ( restartMIDIInputCmd ) ; MIDIIn . initMIDIStatusBarItems ( ) ; vscode . window . onDidChangeActiveTextEditor ( ( _ ) => { MIDIIn . updateMIDIStatusBarItem ( ) ; MIDIOut . updateMIDIStatusBarItem ( ) ; } ) ; } export function deactivate ( ) { }