MyNixOS website logo
Description

Utility for generating ctags and etags with GHC API.

Utility for generating etags (Emacs) and ctags (Vim and other editors) with GHC API for efficient project navigation.

ghc-tags

Build Status Hackage

A command line tool that generates etags (Emacs) and ctags (Vim, VSCode with ctagsx etc.) for efficient code navigation (jump to definition).

Main features:

  • Leverages GHC API to obtain accurate information.
  • Uses multiple CPU cores when processing source files.
  • Supports fast incremental updates.

Supported file extensions:

  • .hs
  • .hs-boot
  • .lhs
  • .x (requires alex)
  • .hsc (requires hsc2hs)

Usage

For simple projects, i.e. the ones that don't use C pre-processor in non-trivial ways nor include any C sources it should be enough to execute ghc-tags -e (for etags) or ghc-tags -c (for ctags) in the root directory of the project.

For more complicated projects you need to create the configuration file (ghc-tags.yaml by default). It can contain the following keys:

  • source_paths - a list of paths for ghc-tags to process. Directories are traversed recursively.
  • exclude_paths - a list of paths for ghc-tags to exclude from processing.
  • language - the flavour of Haskell, either Haskell98 or Haskell2010.
  • extensions - a list of GHC language extensions to enable when parsing. Note that GHC needs much less extensions for parsing alone, so you should almost never need to override this.
  • cpp_includes - include paths for the C pre-processor.
  • cpp_options - other options for the C pre-processor, e.g. defines (usually undefined MIN_VERSION_x macros will go here).

If any of these keys is not specified, an appropriate default value will be picked instead. You can inspect the defaults by executing ghc-tags --default.

Note: it is possible to specify multiple project configurations in the configuration file by separating them with ---. For example, here is a configuration for GHC on Linux (compiler, utils and base):

source_paths:
- compiler

cpp_includes:
- _build/stage1/compiler/build
- compiler
- includes/dist-derivedconstants/header

---

source_paths:
- libraries/base

exclude_paths:
- libraries/base/GHC/Conc/POSIX/Const.hsc
- libraries/base/GHC/Event/Windows.hsc
- libraries/base/GHC/Event/Windows/ConsoleEvent.hsc
- libraries/base/GHC/Event/Windows/FFI.hsc
- libraries/base/GHC/IO/Windows/Handle.hsc
- libraries/base/System/CPUTime/Windows.hsc
- libraries/base/tests

cpp_includes:
- _build/stage1/libraries/base/build/include
- includes
- libraries/base/include

---

source_paths:
- libraries/ghc-bignum

exclude_paths:
- libraries/ghc-bignum/src/GHC/Num/Backend/Selected.hs

cpp_includes:
- libraries/ghc-bignum/include

---

source_paths:
- libraries/ghc-boot
- libraries/ghc-boot-th
- libraries/ghc-compact
- libraries/ghc-heap
- libraries/ghc-prim

exclude_paths:
- libraries/ghc-compact/tests
- libraries/ghc-heap/tests
- libraries/ghc-prim/tests

Acknowledgments

Thanks to Marcin Szamotulski for his work on ghc-tags-pluginghc-tags is based on.

Metadata

Version

1.7

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows