<commit_before>{-# LANGUAGE LambdaCase #-}
{- |
Module      :  Neovim.Plugin.ConfigHelper.Internal
Description :  Internals for a config helper plugin that helps recompiling nvim-hs
Copyright   :  (c) <NAME>
License     :  Apache-2.0

Maintainer  :  <EMAIL>
Stability   :  experimental
Portability :  GHC

-}
module Neovim.Plugin.ConfigHelper.Internal
    where

import           Neovim.Context
import           Neovim.Config

import           Config.Dyre         (Params)
import           Config.Dyre.Compile

import           System.Log.Logger

pingNvimhs :: Neovim' String
pingNvimhs = return "Pong"

recompileNvimhs :: Neovim (Params NeovimConfig) (Maybe String) ()
recompileNvimhs = do
    cfg <- ask
    liftIO (customCompile cfg >> getErrorString cfg) >>= \case
        Nothing -> return ()
        Just e -> put (Just e) -- TODO open the quickfix window

-- | Note that restarting the plugin provider implies compilation because Dyre
-- does this automatically. However, if the recompilation fails, the previously
-- compiled bynary is executed. This essentially means that restarting may take
-- more time then you might expect.
restartNvimhs :: Neovim r st ()
restartNvimhs = do
    liftIO $ debugM "ConfigHelper" "Throwing exception to restart"
    restart<commit_msg>Update Internal.hs<commit_after>{-# LANGUAGE LambdaCase #-}
{- |
Module      :  Neovim.Plugin.ConfigHelper.Internal
Description :  Internals for a config helper plugin that helps recompiling nvim-hs
Copyright   :  (c) <NAME>
License     :  Apache-2.0

Maintainer  :  <EMAIL>
Stability   :  experimental
Portability :  GHC

-}
module Neovim.Plugin.ConfigHelper.Internal
    where

import           Neovim.Context
import           Neovim.Config

import           Config.Dyre         (Params)
import           Config.Dyre.Compile

import           System.Log.Logger

pingNvimhs :: Neovim' String
pingNvimhs = return "Pong"

recompileNvimhs :: Neovim (Params NeovimConfig) (Maybe String) ()
recompileNvimhs = do
    cfg <- ask
    liftIO (customCompile cfg >> getErrorString cfg) >>= \case
        Nothing -> return ()
        Just e -> put (Just e) -- TODO open the quickfix window

-- | Note that restarting the plugin provider implies compilation because Dyre
-- does this automatically. However, if the recompilation fails, the previously
-- compiled bynary is executed. This essentially means that restarting may take
-- more time then you might expect.
restartNvimhs :: Neovim r st ()
restartNvimhs = do
    liftIO $ debugM "ConfigHelper" "Issuing restart"
    restart
{'fraction_non_alphanumeric': 0.08199293840721851, 'fraction_numerical': 0.001569242840329541, 'mean_word_length': 3.015748031496063, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1207211', 'n_tokens_mistral': 768, 'n_tokens_neox': 753, 'n_words': 250}