Difference between revisions of "Tags"

From HaskellWiki
Jump to navigation Jump to search
(added link to gasbag)
(Swap fast-tags and lushtags)
 
(7 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
== Introduction ==
 
== Introduction ==
   
"Tags" are a listing of code objects in a group of files, together with their precise location, often used by text editors to quickly jump around in a program. <tt>ctags</tt> (for C) was the first tag-generation program.
+
"Tags" are a listing of source code definitions in a group of files, together with their precise location, often used by text editors to quickly jump around in a program. For example, they allow you in a editor that supports tags to jump to the definition of a function when you come across a use of that function. <tt>ctags</tt> (for C) was the first tag-generation program. See the [http://en.wikipedia.org/wiki/Ctags wikipedia article] for more information.
   
 
There are currently a number of different ways to generate tags with
 
There are currently a number of different ways to generate tags with
 
Haskell.
 
Haskell.
   
  +
== Tags Formats ==
This page should be used to collect information on tag-generation for Haskell, including information on how to use tags with common editors and what benefits they can give you.
 
  +
  +
Tag files can be produced in a number of different formats supported by different editors. The two most common formats are 'ctags', which is supported by Vim and others, and 'etags', which is supported by Emacs. Note that the default names for the file in ctags format and the file in etags format are 'tags' and 'TAGS' respectively
   
 
== Haskell tag generators ==
 
== Haskell tag generators ==
   
 
=== GHC ===
Chris Ryder and Simon Thompson give a tag generator's source in
 
  +
* [http://www.haskell.org/ghc GHC] can generate tag files from GHCi. Use either the ':ctags' or ':etags' commands to produce a tags file for the currently loaded modules.
[http://www.cs.kent.ac.uk/pubs/2005/2266/content.pdf a paper]
 
 
Norman Ramsey and Kathleen Fisher's partial hasktags implementation
 
using the GHC API is [http://darcs.haskell.org/ghctags/ in darcs].
 
There's also a [http://hackage.haskell.org/trac/ghc/ticket/946 GHC trac task] relating to it.
 
 
<tt>echo ":ctags" | ghci -v0 Main.hs</tt>
 
 
<tt>echo ":etags" | ghci -v0 Main.hs</tt>
 
 
utils/hasktags from GHC.
 
 
[http://kingfisher.nfshost.com/sw/gasbag/ gasbag] (which understands all
 
options recognised by hasktags).
 
== Usage ==
 
 
The tags file generated in ctags format can be used in (amongst others) vim, BBEdit and NEdit. The one in etags format can be used in at least Emacs. Note that the default names for the
 
file in ctags format and the file in etags format are 'tags' and 'TAGS' respectively. These names clash on case-insensitive filesystems, such as Mac OS's HFS and HFS+ in the default configuration.
 
 
In vi, one jumps to a tag using either
 
<pre>
 
:tag <tag-to-jump-to>
 
</pre>
 
or by using control-] with the cursor on the tag to jump to. Using control-T returns to the
 
previous position.
 
   
  +
:For example:
== Random other bits ==
 
 
:<tt>echo ":ctags" | ghci -v0 Main.hs</tt>
 
:<tt>echo ":etags" | ghci -v0 Main.hs</tt>
   
  +
=== Actively developed ===
http://vim-taglist.sourceforge.net/
 
  +
* [http://hackage.haskell.org/package/fast-tags fast-tags]: Incremental Vim tag generation. Designed to be fast. Uses its own parser.
  +
* [http://hackage.haskell.org/package/hasktags Hasktags]: Can produce either a ctags or etags compatible tag file. Uses its own parser.
  +
* [http://hackage.haskell.org/package/hothasktags hothasktags]: Knows about import lists and qualified imports. Vim tags only. Uses haskell-src-exts for parsing.
   
  +
=== Other ===
[http://www.vim.org Vim]
 
  +
* [http://hackage.haskell.org/package/haskdogs haskdogs]: Wrapper script for hasktags. (last update 2013)
  +
* [http://hackage.haskell.org/package/lushtags lushtags]: Designed to have smooth integration with the [http://majutsushi.github.com/tagbar/ Vim Tagbar] plugin. (last update 2011)
  +
* [http://kingfisher.nfshost.com/sw/gasbag/ gasbag]: Attempts to choose the best available definition for a given tag. Will notice bindings that don't have an accompanying type signature. (last update 2011)
  +
* [http://hackage.haskell.org/package/htags htags]: Haskell 98 only. Uses haskell-src for parsing. (last update 2008)
   
  +
=== GHC development ===
[http://vimdoc.sourceforge.net/htmldoc/usr_29.html#29.1 Using tags in Vim]
 
  +
* Use `[https://ghc.haskell.org/trac/ghc/wiki/Building/StandardTargets make tags]` in the root of the ghc source tree when [https://ghc.haskell.org/trac/ghc/wiki hacking] on GHC itself.
   
  +
* Use `[https://ghc.haskell.org/trac/ghc/wiki/Building/StandardTargets make TAGS]` to generate Emacs tags.
[http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags :help tags]
 
   
  +
You can also find the source code for a tag generator in Chris Ryder and Simon Thompson [http://www.cs.kent.ac.uk/pubs/2005/2266/content.pdf paper] on porting the Haskell Refactoring tool, HaRe, to the GHC API.
[http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion insert-mode tag completion] (ctrl-x ctrl-])
 
   
  +
== More Information ==
[http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags-file-format :help tags-file-format]
 
   
  +
=== Vim ===
[http://vimdoc.sourceforge.net/htmldoc/windows.html#CursorHold-example :help cursorhold-example]
 
 
* [http://vimdoc.sourceforge.net/htmldoc/usr_29.html#29.1 Using tags in Vim]
 
* [http://vimdoc.sourceforge.net/htmldoc/tagsrch.html#tags :help tags]
 
* [http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion insert-mode tag completion] (ctrl-x ctrl-])
 
*[http://vimdoc.sourceforge.net/htmldoc/windows.html#CursorHold-example :help cursorhold-example]
 
* [http://vim-taglist.sourceforge.net/ Vim plugin to view all tags in a window]
  +
* [http://majutsushi.github.com/tagbar/ Another plugin]; newer's not always better, but this is still actively maintained as of 2012
   
  +
=== Others ===
[http://www.nedit.org/help/tags.php#Finding_Declarations_(ctags) NEdit documentation for using tags]
 
   
 
* [http://www.nedit.org/help/tags.php#Finding_Declarations_(ctags) NEdit documentation for using tags]
Chapter 14 of the BBEdit manual
+
* Chapter 14 of the BBEdit manual covers using tags

Latest revision as of 05:13, 30 January 2016

Introduction

"Tags" are a listing of source code definitions in a group of files, together with their precise location, often used by text editors to quickly jump around in a program. For example, they allow you in a editor that supports tags to jump to the definition of a function when you come across a use of that function. ctags (for C) was the first tag-generation program. See the wikipedia article for more information.

There are currently a number of different ways to generate tags with Haskell.

Tags Formats

Tag files can be produced in a number of different formats supported by different editors. The two most common formats are 'ctags', which is supported by Vim and others, and 'etags', which is supported by Emacs. Note that the default names for the file in ctags format and the file in etags format are 'tags' and 'TAGS' respectively

Haskell tag generators

GHC

  • GHC can generate tag files from GHCi. Use either the ':ctags' or ':etags' commands to produce a tags file for the currently loaded modules.
For example:
echo ":ctags" | ghci -v0 Main.hs
echo ":etags" | ghci -v0 Main.hs

Actively developed

  • fast-tags: Incremental Vim tag generation. Designed to be fast. Uses its own parser.
  • Hasktags: Can produce either a ctags or etags compatible tag file. Uses its own parser.
  • hothasktags: Knows about import lists and qualified imports. Vim tags only. Uses haskell-src-exts for parsing.

Other

  • haskdogs: Wrapper script for hasktags. (last update 2013)
  • lushtags: Designed to have smooth integration with the Vim Tagbar plugin. (last update 2011)
  • gasbag: Attempts to choose the best available definition for a given tag. Will notice bindings that don't have an accompanying type signature. (last update 2011)
  • htags: Haskell 98 only. Uses haskell-src for parsing. (last update 2008)

GHC development

You can also find the source code for a tag generator in Chris Ryder and Simon Thompson paper on porting the Haskell Refactoring tool, HaRe, to the GHC API.

More Information

Vim

Others