[Haskell-cafe] UPDATE: haskellmode for Vim now at projects.haskell.org (+screencast; -)

Claus Reinke claus.reinke at talk21.com
Tue Apr 21 13:38:08 EDT 2009

|Yes, I found that one myself.  My old ftplugin/haskell.vim used to
|have autoindent set, but importing your haskell mode overwrote that
|(slightly irritating behaviour if you ask me ;-).  Putting my old
|config into ftplugin/haskell_mine.vim restored the behaviour.

Yes, one cannot have two "major" haskell modes claiming the same 
file, as the file identifies the mode. Fortunately, Vim provides separate 
files for separate aspects of filetype-specific functionality (syntax, indent, 
plugins), allows to split filetype plugins over several files as well (haskellmode 
currently only sets 'include' and 'includeexpr' in 'ftplugin/haskell.vim'; everything 
else is in separate files), and provides several versions of its configuration 
directory trees, to allow for standard plugins, system-wide overrides, 
user-overrides, ..

For user-specific modifications, the main 'ftplugin/' is probably not
the right place (see ':help runtimepath' for directory layout and paths
searched), although adding a unique postfix to the file name works,
as you've noticed (if we get too many generally available haskell 
plugins, we could move them to their own directory..). If you don't 
want to use your 'vimrc' file, then perhaps one of the 'after' directories 
(also in system-wide and user-specific varieties)? See ':help ftplugin-overrule'.

You might also want to look at ':help vimball' - by default, it installs
files in the first directory tree found on 'runtimepath', but you can
give a different path explicitly (eg, if your ~/.vim is first in the list,
but you don't want the plugins to be installed there, so that 
~/.vim/ftplugin/ isn't touched). There doesn't seem to be a documented 
way of asking for confirmation before overwriting exising files of the 
same names, though - perhaps you could suggest this to the vimball 

> |2. My browser doesn't urldecode its command line arguments, so
> |locations like
> "file:///usr/share/doc/ghc6-doc/libraries/base/Prelude.html%23v%253AfromIntegral"
> |don't work. I have to manually fix it up in the location bar. Do you
> |have any tip for dealing with that?
> That is the first I hear about such an issue. As it seems to work with
> most browsers (I tend to use Opera most, but -long ago- tested with
> IE and FireFox as well), I would need to know about the browser in question
> to see what is going on and think about workarounds.

|These are my g:haddock_ setting:
|let g:haddock_browser="/usr/bin/x-www-browser"
|let g:haddock_browser_callformat = "%s %s &"
|It's on a Debian system, hence the use of x-www-browser.  I've tried
|using both epiphany and iceweasel directly as well, with exactly the
|same behaviour.

One thing I learn from trying to support haskellmode for Vim is how
different platforms are, sometime being different is their whole purpose!-)

So, x-www-browser is a dispatcher for calling the default browser,
and epiphany and iceweasel are browsers?-) And you're sure that the
dispatcher doesn't do an extra encoding. And calling the dispatcher
directly with the url 


works without extra encodings appearing?

> file://localhost/c:/ghc/ghc-6.11.20090320/doc/libraries/base/Prelude.html#v%3AfromIntegral
> ><A HREF="base/Prelude.html#v%3AfromIntegral"

|That is what I have in mine as well (though it's located in

Good, so it isn't a Haddock difference.

| I'm not really sure where the extra level of encoding comes from.

> which is copied literally to g:haddock_index['fromIntegral'], and
> passed almost literally to the browser call (with backslash escapes
> for '#'/'%'). Somewhere along that line, or later, something different
> happens on your system, and it seems to happen outside the plugins (you
> could confirm this by using 'echo' as your browser, or by adding
> a Vim breakpoint for function DocBrowser, and look at a:url).

|My Vim-scripting fu is minimal.  Do you have any pointers on how to
|set breakpoints, step, and inspect variables?

Sure, ':help debug';-) In this particular case, using 'echo' as your browser
to echo the url Vim tries to pass would give you the information more directly.
But you could also try to look at it from within Vim (lines starting with " are
comments, not to be typed in):

" this should match the doc-index url
:echo g:haddock_index['fromIntegral']

" set breakpoint
:breakadd func DocBrowser
" now, if you use _? on fromIntegral, you'll end up in the debugger,
" in function DocBrowser, where you can inspect the local environment,
" then quit or continue:
echo a:url
echo printf(g:haddock_browser_callformat,g:haddock_browser,escape(a:url,'#%'))
" delete all breakpoints
:breakdel *

Does the second echo show the extra encoding? If not, it is beyond
haskellmode, I'm afraid - that command is passed directly to the shell
(well, as directly as a configurable editor will allow - see ':help :!').


More information about the Haskell-Cafe mailing list