[Haskell] ANNOUNCE: Doc.vim - Haddock display and Haddock index goodies for Vim

Claus Reinke claus.reinke at talk21.com
Sun Mar 4 08:55:09 EST 2007


the recent discussion about a simpler url-interface to library haddocks prompted
me to write some vimscript to make use of the existing interface. the initial idea was
just to translate qualified name and package into a url to launch a browser with.

but as people pointed out, having to know the qualified name and even the package
makes for an inconvenient interface. so the second version read haddocks index files 
to populate a dictionary of unqualified names and symbols, pointing to possible 
qualifiers and urls.

once we have such a handy documentation index, we can play other ide-style
games as well, so the current version (attached) adds a few more goodies. 

some inspection necessary: this is not a proper, portable, out-of-the-box release!
the script has been tested with gvim 7.0 on windows, using the haddocks released 
with ghc-6.4.1, and opera as the browser. to adapt it for other systems, you'll need 
to change some paths and probably the :start command. feedback/fixes welcome.

what is on offer:-)

    :IDoc "<name>"    -- suggest possible qualifiers, then launch doc browser 
    :Doc "<qualname>","<package>"   -- old-style invocation
    
    :DocIndex    -- populate index from haddock index html files (takes a few secs)
    
    CTRL-X CTRL-U -- one of the user-defined insert-mode completions
                        -- does now complete unqualified ids wrt the doc index

    _?    -- for unqualified id under cursor, suggest possible qualifiers, browse

    _.    -- replace unqualified id under cursor with fully qualified version

so you can place your cursor on 'mapM_', type '_?', select Prelude or Control.Monad,
and find out what it is all about. or you can type 'pres', and still in insert mode, type
CTRL-X CTRL-U, find 'preservingMatrix' as one of the possible completions, and
select it. or you can place your cursor on 'preservingMatrix', type '_.', select one of
the options, and have it replaced with 'Graphics.Rendering.OpenGL.preservingMatrix'.

(for those who believe in gui rather than functionality as the distinction 
 between ides and editors, the last three use little popup menus in gui vim;)

how to: read the script to check that it does what you'd expect, adapt where
necessary, then :source it, run :DocIndex (this takes a few seconds, so we should
probably cache the result in more vim-friendly format somewhere later..), and play.
as usual, no guarantees of any kind.

feel free to adapt this for your haskell filetype plugins. and i'm sure that the
ideas carry over to other intelligent editors, so perhaps someone will come
up with an emacs variant?-)

enjoy,
claus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Doc.vim
Type: application/octet-stream
Size: 7367 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/haskell/attachments/20070304/ca72c5bc/Doc.obj


More information about the Haskell mailing list