packages feed

miv 0.4.3 → 0.4.4

raw patch · 4 files changed

+24/−10 lines, 4 filesdep +filepattern

Dependencies added: filepattern

Files

miv.cabal view
@@ -1,5 +1,5 @@ name:                   miv-version:                0.4.3+version:                0.4.4 author:                 itchyny <https://github.com/itchyny> maintainer:             itchyny <https://github.com/itchyny> license:                MIT@@ -40,6 +40,7 @@                       , unordered-containers                       , monad-parallel                       , filepath+                      , filepattern                       , unix-compat                       , xdg-basedir 
src/Main.hs view
@@ -9,7 +9,7 @@ import Control.Monad (filterM, forM_, unless, void, when, guard) import qualified Control.Monad.Parallel as P import Data.Functor ((<&>))-import Data.List (foldl', isPrefixOf, nub, sort)+import Data.List (foldl', isPrefixOf, nub, sort, (\\)) import Data.Maybe (listToMaybe, fromMaybe, isNothing) import Data.Text (Text, unlines, pack, unpack) import qualified Data.Text as T@@ -26,6 +26,7 @@ import System.Environment.XDG.BaseDir (getUserConfigFile, getUserDataDir) import System.Exit (ExitCode(..)) import System.FilePath ((</>))+import System.FilePattern.Directory (getDirectoryFiles) import System.IO (openFile, IOMode(..), hClose, hFlush, stdout, stderr, hGetLine, hPutStrLn) import System.IO.Error (isDoesNotExistError, tryIOError, isEOFError) import System.PosixCompat.Files (setFileTimes)@@ -374,18 +375,20 @@   cnt <- listDirectory dir   let paths = "miv" : map (unpack . show) (plugins setting)       delpath' = [ dir </> d | d <- cnt, d `notElem` paths ]-  deldir <- filterM doesDirectoryExist delpath'-  delfile <- filterM doesFileExist delpath'-  let delpath = deldir <> delfile-  if not (null delpath)+  deldirs <- filterM doesDirectoryExist delpath'+  files <- getDirectoryFiles (dir </> "miv") $ (unpack . show . ($ "*")) <$> [ Autoload, Ftplugin, Syntax ]+  let delfiles = (delpath' \\ deldirs)+        <> (((dir </> "miv") </>) <$> (files \\ [ unpack (show place) | (place, _) <- vimScriptToList (gatherScript setting) ]))+  let delpaths = deldirs <> delfiles+  if not (null delpaths)      then do putStrLn "Remove:"-             mapM_ (putStrLn . pack . ("  "<>)) delpath+             mapM_ (putStrLn . pack . ("  "<>)) delpaths              putStr "Really? [y/N] "              hFlush stdout              c <- getChar              when (c == 'y' || c == 'Y') $ do-               mapM_ removeDirectoryRecursive deldir-               mapM_ removeFile delfile+               mapM_ removeDirectoryRecursive deldirs+               mapM_ removeFile $ delfiles      else putStrLn "Clean."  saveScript :: (FilePath, Place, [Text]) -> IO ()@@ -423,10 +426,10 @@ generatePluginCode setting = do   dir <- fmap (</>"miv") pluginDirectory   createDirectoryIfMissing True dir-  -- TODO: remove unused directories and files   createDirectoryIfMissing True (dir </> "plugin")   createDirectoryIfMissing True (dir </> "autoload" </> "miv")   createDirectoryIfMissing True (dir </> "ftplugin")+  createDirectoryIfMissing True (dir </> "syntax")   when (any (not . null . dependedby) (plugins setting)) $     hPutStrLn stderr "`dependedby` is deprecated in favor of `loadafter`"   P.mapM_ (saveScript . (\(t, s) -> (dir, t, s)))
src/Setting.hs view
@@ -13,6 +13,7 @@ data Setting =      Setting { plugins  :: [Plugin]              , filetype :: HM.HashMap Text [Text]+             , syntax   :: HM.HashMap Text [Text]              , before   :: [Text]              , after    :: [Text]      } deriving Eq@@ -21,6 +22,7 @@   parseJSON = withObject "setting" $ \o -> do     plugins <- pluginHashMapToList <$> o .:? "plugin" .!= HM.empty     filetype <- HM.map lines <$> o .:? "filetype" .!= HM.empty+    syntax <- HM.map lines <$> o .:? "syntax" .!= HM.empty     before <- lines <$> o .:? "before" .!= ""     after <- lines <$> o .:? "after" .!= ""     return Setting {..}
src/VimScript.hs view
@@ -26,18 +26,21 @@ data Place = Plugin            | Autoload Text            | Ftplugin Text+           | Syntax   Text            deriving (Eq, Generic)  instance Hashable Place where   hashWithSalt a Plugin       = a `hashWithSalt` (0 :: Int) `hashWithSalt` ("" :: Text)   hashWithSalt a (Autoload s) = a `hashWithSalt` (1 :: Int) `hashWithSalt` s   hashWithSalt a (Ftplugin s) = a `hashWithSalt` (2 :: Int) `hashWithSalt` s+  hashWithSalt a (Syntax s) = a `hashWithSalt` (2 :: Int) `hashWithSalt` s  instance ShowText Place where   show Plugin        = "plugin/miv.vim"   show (Autoload "") = "autoload/miv.vim"   show (Autoload s)  = "autoload/miv/" <> s <> ".vim"   show (Ftplugin s)  = "ftplugin/" <> s <> ".vim"+  show (Syntax s)    = "syntax/" <> s <> ".vim"  autoloadSubdirName :: Place -> Maybe Text autoloadSubdirName (Autoload "") = Nothing@@ -76,6 +79,7 @@                     <> filetypeLoader setting                     <> gatherInsertEnter setting                     <> filetypeScript (S.filetype setting)+                    <> syntaxScript (S.syntax setting)                     <> afterScript setting   where plugins = S.plugins setting @@ -269,6 +273,10 @@ filetypeScript :: HM.HashMap Text [Text] -> VimScript filetypeScript =   HM.foldrWithKey (\ft scr val -> val <> VimScript (HM.singleton (Ftplugin ft) scr)) mempty++syntaxScript :: HM.HashMap Text [Text] -> VimScript+syntaxScript =+  HM.foldrWithKey (\ft scr val -> val <> VimScript (HM.singleton (Syntax ft) scr)) mempty  wrapFunction :: Text -> [Text] -> [Text] wrapFunction funcname script =