Skip to content

Commit

Permalink
Merge branch 'master' of github.com:luqui/hothasktags
Browse files Browse the repository at this point in the history
Conflicts:
	hothasktags.cabal
  • Loading branch information
luqui committed Dec 23, 2011
2 parents 59bf67a + 353fe11 commit 88310e4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
16 changes: 14 additions & 2 deletions Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import qualified Language.Haskell.Exts.Annotated as L
import System.Environment (getArgs)
import System.IO (hPutStrLn, stderr)
import qualified Data.Map as Map
import qualified Language.Preprocessor.Cpphs as CPP
import Control.Monad (forM, when)
import Data.List (sort)
import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -157,10 +158,21 @@ makeTag refFile (name, Defn file line) = name ++ "\t" ++ file ++ "\t" ++ show li
makeTags :: FilePath -> Map.Map String Defn -> [String]
makeTags refFile = map (makeTag refFile) . Map.assocs

haskellSource :: FilePath -> IO String
haskellSource file = do
contents <- readFile file
let needsCpp = maybe False (L.CPP `elem`) (L.readExtensions contents)
if needsCpp
then CPP.runCpphs cppOpts file contents
else return contents
where
cppOpts = CPP.defaultCpphsOptions { CPP.boolopts = CPP.defaultBoolOptions { CPP.hashline = False } }


makeDatabase :: [FilePath] -> IO Database
makeDatabase files = do
fmap (Map.fromList . concat) . forM files $ \file -> do
result <- L.parseFileWithMode (mode file) file
result <- L.parseFileContentsWithMode (mode file) `fmap` haskellSource file
case result of
L.ParseOk mod@(L.Module _ (Just (L.ModuleHead _ (L.ModuleName _ name) _ _)) _ _ _) -> do
return [(name, mod)]
Expand All @@ -175,7 +187,7 @@ makeDatabase files = do
L.extensions = [L.MultiParamTypeClasses, L.ExistentialQuantification, L.FlexibleContexts],
L.ignoreLanguagePragmas = False,
L.ignoreLinePragmas = False,
L.fixities = []
L.fixities = Nothing
}

moduleFile :: L.Module L.SrcSpanInfo -> FilePath
Expand Down
25 changes: 13 additions & 12 deletions hothasktags.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: hothasktags
version: 0.1.1
version: 0.2.1
cabal-version: >= 1.6 && < 2
build-type: Simple
author: Luke Palmer <lrpalmer@gmail.com>
Expand All @@ -9,27 +9,28 @@ category: Development
synopsis: Generates ctags for Haskell, incorporating import lists and qualified imports
description:
hothasktags generates ctags files for Haskell, with knowledge of import lists
and qualified imports. It provides a smart go-to-definition for vim, that almost
and qualified imports. It provides a smart go-to-definition for Vim, that almost
always gets it right in the presence of multiple names from different modules.

You will want to configure vim to allow dots in keywords, because hothasktags
.
You will want to configure Vim to allow dots in keywords, because hothasktags
generates tags for qualified names. You can do this with:

set iskeyword=a-z,A-Z,_,.,39

.
> set iskeyword=a-z,A-Z,_,.,39
.
(The 39 is for the prime character)

.
Usage is easy, just give hothasktags the names of all the haskell sources you
want to index and redirect into a tags file. For example:

find . | egrep '\.hs$' | xargs hothasktags > tags

.
> find . | egrep '\.hs$' | xargs hothasktags > tags
.
will index all the hs files under the current directory.
homepage: http://github.com/luqui/hothasktags
executable hothasktags
build-depends:
base == 4.*,
containers,
haskell-src-exts >= 1.8 && < 1.10
haskell-src-exts == 1.11.*,
cpphs >= 1.11 && < 1.14
main-is: Main.hs
ghc-options: -W

0 comments on commit 88310e4

Please sign in to comment.