module Neovim.Plugin.ConfigHelper
where
import Neovim.API.TH
import Neovim.Config
import Neovim.Context
import Neovim.Plugin.Classes
import Neovim.Plugin.ConfigHelper.Internal
import Neovim.Plugin.Internal
import Neovim.Plugin.Startup
import Config.Dyre.Paths (getPaths)
import Data.Default
plugin :: Neovim (StartupConfig NeovimConfig) () NeovimPlugin
plugin = asks dyreParams >>= \case
Nothing ->
wrapPlugin Plugin { exports = [], statefulExports = [] }
Just params -> do
ghcEnv <- asks ghcEnvironmentVariables
(_, _, cfgFile, _, libsDir) <- liftIO $ getPaths params
wrapPlugin Plugin
{ exports =
[ $(function' 'pingNvimhs) Sync
]
, statefulExports =
[ StatefulFunctionality
{ readOnly = (params, ghcEnv)
, writable = []
, functionalities =
[ $(autocmd 'recompileNvimhs) "BufWritePost" def
{ acmdPattern = cfgFile
}
, $(autocmd 'recompileNvimhs) "BufWritePost" def
{ acmdPattern = libsDir++"/*"
}
, $(command' 'restartNvimhs) [CmdSync Async, CmdBang, CmdRegister]
]
}
]
}