mirror of https://github.com/voidlizard/hbs2
wip, code size reduced
This commit is contained in:
parent
6ed5bf62ba
commit
9b98d19e7c
|
@ -0,0 +1 @@
|
||||||
|
./state.db
|
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
; fixme-files **/*.hs docs/devlog.md
|
||||||
|
|
||||||
|
; no-debug
|
||||||
|
; debug
|
||||||
|
|
||||||
|
fixme-prefix FIXME:
|
||||||
|
fixme-prefix TODO:
|
||||||
|
|
||||||
|
fixme-git-scan-filter-days 30
|
||||||
|
|
||||||
|
fixme-files **/*.txt docs/devlog.md
|
||||||
|
fixme-files **/*.hs
|
||||||
|
|
||||||
|
fixme-file-comments "*.scm" ";"
|
||||||
|
|
||||||
|
fixme-comments ";" "--"
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,8 @@ localConfig = localConfigDir <&> (</> "config")
|
||||||
readConfig :: FixmePerks m => FixmeM m [Syntax C]
|
readConfig :: FixmePerks m => FixmeM m [Syntax C]
|
||||||
readConfig = do
|
readConfig = do
|
||||||
localConfig
|
localConfig
|
||||||
>>= liftIO . readFile
|
>>= try @_ @IOException . liftIO . readFile
|
||||||
|
<&> fromRight mempty
|
||||||
<&> parseTop
|
<&> parseTop
|
||||||
<&> fromRight mempty
|
<&> fromRight mempty
|
||||||
|
|
||||||
|
@ -109,8 +110,8 @@ init = do
|
||||||
|
|
||||||
let lo0 = takeFileName lo
|
let lo0 = takeFileName lo
|
||||||
|
|
||||||
touch (lo </> "config")
|
|
||||||
mkdir lo
|
mkdir lo
|
||||||
|
touch (lo </> "config")
|
||||||
|
|
||||||
let gitignore = lo </> ".gitignore"
|
let gitignore = lo </> ".gitignore"
|
||||||
here <- doesPathExist gitignore
|
here <- doesPathExist gitignore
|
||||||
|
|
|
@ -73,7 +73,7 @@ scanBlob fpath lbs = do
|
||||||
flip fix (S S0 ls) $ \next -> \case
|
flip fix (S S0 ls) $ \next -> \case
|
||||||
S S0 ((lno,x):xs) -> do
|
S S0 ((lno,x):xs) -> do
|
||||||
|
|
||||||
(l,bs) <- eatPrefix comments x
|
(l,bs) <- eatPrefix0 Nothing comments x
|
||||||
|
|
||||||
let mtag = headMay [ t | t <- tagz, LBS8.isPrefixOf t bs ]
|
let mtag = headMay [ t | t <- tagz, LBS8.isPrefixOf t bs ]
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ scanBlob fpath lbs = do
|
||||||
|
|
||||||
S sf@(Sf env@(SfEnv{..})) (x : xs) -> do
|
S sf@(Sf env@(SfEnv{..})) (x : xs) -> do
|
||||||
|
|
||||||
(li,bs) <- eatPrefix0 l0 comments (snd x)
|
(li,bs) <- eatPrefix0 (Just l0) comments (snd x)
|
||||||
|
|
||||||
if | eln > 1 -> next (S S0 (x:xs))
|
if | eln > 1 -> next (S S0 (x:xs))
|
||||||
|
|
||||||
|
@ -141,10 +141,13 @@ scanBlob fpath lbs = do
|
||||||
let rest = decodeUtf8With ignore (LBS8.toStrict restbs) & Text.stripEnd
|
let rest = decodeUtf8With ignore (LBS8.toStrict restbs) & Text.stripEnd
|
||||||
S.yield (FixmePart lno (FixmeLine rest))
|
S.yield (FixmePart lno (FixmeLine rest))
|
||||||
|
|
||||||
eatPrefix0 lim comments x = do
|
eatPrefix0 lim' comments x = do
|
||||||
over _2 LBS8.pack <$> do
|
over _2 LBS8.pack <$> do
|
||||||
|
|
||||||
flip fix (0, LBS8.unpack x) $ \next w@(k, left) -> do
|
flip fix (0, LBS8.unpack x) $ \next w@(k, left) -> do
|
||||||
|
|
||||||
|
let lim = fromMaybe (succ k) lim'
|
||||||
|
|
||||||
if k > lim then
|
if k > lim then
|
||||||
pure (k, left)
|
pure (k, left)
|
||||||
else
|
else
|
||||||
|
@ -158,27 +161,3 @@ scanBlob fpath lbs = do
|
||||||
Nothing -> pure (n, rest)
|
Nothing -> pure (n, rest)
|
||||||
Just co -> next (n+1, drop (fromIntegral $ LBS8.length co) rest)
|
Just co -> next (n+1, drop (fromIntegral $ LBS8.length co) rest)
|
||||||
|
|
||||||
eatPrefix comments x = do
|
|
||||||
-- дропаем пробелы или табы
|
|
||||||
let (pre1,s1) = LBS8.span (`elem` " \t") x
|
|
||||||
|
|
||||||
-- дропаем токен коммента
|
|
||||||
-- перебираем все коменты, пока не найдем первый
|
|
||||||
let comm = headMay [ co | co <- comments, LBS8.isPrefixOf co s1 ]
|
|
||||||
|
|
||||||
let pre2 = pre1 <> fromMaybe mempty comm
|
|
||||||
let rest2 = LBS8.drop (maybe 0 LBS8.length comm) s1
|
|
||||||
|
|
||||||
let (pre3,s2) = LBS8.span (`elem` " \t") rest2
|
|
||||||
|
|
||||||
let pre = pre1 <> pre2 <> pre3
|
|
||||||
|
|
||||||
l <- for (LBS8.unpack pre) $ \case
|
|
||||||
' ' -> pure 1
|
|
||||||
'\t' -> pure 8
|
|
||||||
_ -> pure 0
|
|
||||||
|
|
||||||
let level = sum l + maybe 0 (const 1) comm
|
|
||||||
|
|
||||||
pure (level, s2)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue