ghc-tags-plugin 0.1.2.0 → 0.1.2.1
raw patch · 4 files changed
+52/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Makefile +28/−0
- README.md +2/−2
- ghc-tags-plugin.cabal +2/−1
- test/Test/Vim.hs +20/−9
+ Makefile view
@@ -0,0 +1,28 @@+#+# install, uninstall and friends ghc-tags-plugin in cabal store+#++CABAL_STORE = ${HOME}/.cabal/store/ghc-$(shell ghc --numeric-version)/package.db++uninstall:+ ghc-pkg unregister \+ --package-db=${CABAL_STORE} \+ --force \+ z-ghc-tags-plugin-z-ghc-tags-library \+ ghc-tags-plugin++install:+ cabal install --package-db=${CABAL_STORE} --lib ghc-tags-plugin++reinstall: uninstall install++list:+ ghc-pkg list --package-db=${CABAL_STORE} | grep ghc-tags++latest:+ ghc-pkg latest --package-db=${CABAL_STORE} ghc-tags-plugin++recache:+ ghc-pkg recache --package-db=${CABAL_STORE}++.PHONY: install, uninstall, reinstall, show, latest
README.md view
@@ -11,7 +11,7 @@ ghc >= 8.6 ``` -# vim configuration+# Vim configuration Each generated tags file is put next to the corresponding `*.cabal` file. If you just have a repo with a cabal file in the main directory `vim` default@@ -21,7 +21,7 @@ :set tags+=*/tags ``` -# Plugin usage+# Plugin configuration Configuration of this plugin requires some familiarity with `ghc` packages. Check out
ghc-tags-plugin.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: ghc-tags-plugin-version: 0.1.2.0+version: 0.1.2.1 synopsis: A compiler plugin which generates tags file from GHC syntax tree. description: A compiler source plugin which takes parsed Haskell syntax tree and saves@@ -13,6 +13,7 @@ category: Development extra-source-files: CHANGELOG.md README.md+ Makefile homepage: https://github.com/coot/ghc-tags-plugin#readme bug-reports: https://github.com/coot/ghc-tags-plugin/issues tested-with: GHC==8.6.3, GHC==8.8.3
test/Test/Vim.hs view
@@ -6,6 +6,7 @@ import qualified Data.Attoparsec.Text as AT import qualified Data.ByteString.Builder as BB import qualified Data.ByteString.Lazy as BL+import qualified Data.Char as Char import Data.Maybe (isNothing) import Data.Text (Text) import qualified Data.Text as Text@@ -33,8 +34,10 @@ (fixText <$> arbitrary) (not . Text.null) +-- filter only printable characters, removing tabs and newlines which have+-- special role in vim tag syntax fixText :: Text -> Text-fixText = Text.filter (\x -> x /= '\t' && x /= '\n' && x /= '\NUL')+fixText = Text.filter (\x -> x /= '\t' && x /= '\n' && Char.isPrint x) genField :: Gen TagField@@ -42,16 +45,23 @@ TagField <$> suchThat g (not . Text.null) <*> g- where + where g :: Gen Text g = fixFieldText <$> arbitrary +-- filter only printable characters, removing tabs, newlines and colons which+-- have special role in vim field syntax fixFieldText :: Text -> Text-fixFieldText = Text.filter (\x -> x /= '\t' && x /= ':' && x /= '\n' && x /= '\NUL')+fixFieldText = Text.filter (\x -> x /= '\t' && x /= ':' && x /= '\n' && Char.isPrint x) ++-- address cannot contain ";\"" sequence fixAddr :: Text -> Text fixAddr = fixText . Text.replace ";\"" "" +wrap :: Char -> Text -> Text+wrap c = Text.cons c . flip Text.snoc c+ genGhcKind :: Gen GhcKind genGhcKind = elements [ TkTerm@@ -99,9 +109,10 @@ <$> (TagName <$> genTextNonEmpty) <*> genTagKind <*> (TagFile <$> genTextNonEmpty)- <*> oneof- [ Left . getPositive <$> arbitrary- , Right . (Text.cons '/' . flip Text.snoc '/' . fixAddr) <$> genTextNonEmpty+ <*> frequency+ [ (2, Left . getPositive <$> arbitrary)+ , (1, Right . (wrap '/' . fixAddr) <$> genTextNonEmpty)+ , (1, Right . (wrap '?' . fixAddr) <$> genTextNonEmpty) ] <*> listOf genField shrink (ArbTag tag@Tag {tagName, tagFile, tagAddr, tagFields}) =@@ -117,7 +128,7 @@ | addr <- case tagAddr of Left addr -> Left `map` shrink addr Right addr -> Left 0- : (Right . Text.cons '/' . flip Text.snoc '/' . fixAddr)+ : (Right . wrap '/' . fixAddr) `map` (shrink . stripEnds) addr ] ++ [ ArbTag $ tag { tagFields = fields }@@ -130,15 +141,15 @@ Just (_, addr') -> case Text.unsnoc addr' of Nothing -> error "impossible happend" Just (addr'', _) -> addr''- + roundTrip :: Tag -> Property roundTrip tag = let bs = BL.toStrict . BB.toLazyByteString . Vim.formatTag $ tag- mtag = AT.parseOnly Vim.parseTag + mtag = AT.parseOnly Vim.parseTag . Text.decodeUtf8 $ bs in case mtag of