packages feed

zwirn-0.2.3.1: app/zwirnzi/Main.hs

{-# LANGUAGE CPP #-}

module Main where

{-
    Main.hs - entry point of the editor program
    Copyright (C) 2023, Martin Gius

    This library is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this library.  If not, see <http://www.gnu.org/licenses/>.
-}

import CI.Backend
#if STREAM_SUPERDIRT
import qualified CI.ConfigSuperDirt as Config
import qualified CI.SetupSuperDirt as Setup
#else
import qualified CI.ConfigDoux as Config
import qualified CI.SetupDoux as Setup
#endif
import Control.Concurrent.MVar
import Control.Monad (void)
import qualified LSP.Main as LSP
import System.IO (BufferMode (..), hSetBuffering, stdin, stdout)

main :: IO ()
main = do
  hSetBuffering stdin NoBuffering

  fullConfig <- Config.getConfig
  env <- Setup.setup fullConfig
  envMV <- newMVar env
  if Config.cliMode fullConfig
    then do
      hSetBuffering stdout NoBuffering
      runZwirnCI env evalInputLoop
    else do
      hSetBuffering stdout LineBuffering
      void $ LSP.main envMV