From c7c03a0185ac4598331bf88eea1ccd0bc62b87d5 Mon Sep 17 00:00:00 2001 From: René Neumann Date: Fri, 9 Dec 2011 16:29:52 +0100 Subject: Update haskellmode --- .vim/ftplugin/haskell_doc.vim | 120 +++++++++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 38 deletions(-) (limited to '.vim/ftplugin') diff --git a/.vim/ftplugin/haskell_doc.vim b/.vim/ftplugin/haskell_doc.vim index deceec6..482ea69 100644 --- a/.vim/ftplugin/haskell_doc.vim +++ b/.vim/ftplugin/haskell_doc.vim @@ -2,7 +2,7 @@ " use haddock docs and index files " show documentation, complete & qualify identifiers " -" (Claus Reinke; last modified: 30/04/2009) +" (Claus Reinke; last modified: 17/06/2009) " " part of haskell plugins: http://projects.haskell.org/haskellmode-vim " please send patches to @@ -66,14 +66,7 @@ if !exists("g:haddock_browser") echoerr s:scriptname." WARNING: please set g:haddock_browser!" endif -if (!exists("g:ghc") || !executable(g:ghc)) - if !executable('ghc') - echoerr s:scriptname." can't find ghc. please set g:ghc, or extend $PATH" - finish - else - let g:ghc = 'ghc' - endif -endif +if !haskellmode#GHC() | finish | endif if (!exists("g:ghc_pkg") || !executable(g:ghc_pkg)) let g:ghc_pkg = substitute(g:ghc,'\(.*\)ghc','\1ghc-pkg','') @@ -85,13 +78,17 @@ elseif executable(g:ghc_pkg) " try to figure out location of html docs " first choice: where the base docs are (from the first base listed) let [field;x] = split(system(g:ghc_pkg . ' field base haddock-html'),'\n') - let field = substitute(field,'haddock-html: \(.*\)libraries.base','\1','') + " path changes in ghc-6.12.* + " let field = substitute(field,'haddock-html: \(.*\)libraries.base','\1','') + let field = substitute(field,'haddock-html: \(.*\)lib\(raries\)\?.base.*$','\1','') let field = substitute(field,'\\','/','g') - let alternate = substitute(field,'html','doc/html','') - if isdirectory(field) - let s:docdir = field - elseif isdirectory(alternate) + " let alternate = substitute(field,'html','doc/html','') + " changes for ghc-6.12.*: check for doc/html/ first + let alternate = field.'doc/html/' + if isdirectory(alternate) let s:docdir = alternate + elseif isdirectory(field) + let s:docdir = field endif else echoerr s:scriptname." can't find ghc-pkg (set g:ghc_pkg ?)." @@ -102,8 +99,7 @@ if !exists('s:docdir') || !isdirectory(s:docdir) let s:ghc_libdir = substitute(system(g:ghc . ' --print-libdir'),'\n','','') let location1a = s:ghc_libdir . '/doc/html/' let location1b = s:ghc_libdir . '/doc/' - let s:ghc_version = substitute(system(g:ghc . ' --numeric-version'),'\n','','') - let location2 = '/usr/share/doc/ghc-' . s:ghc_version . '/html/' + let location2 = '/usr/share/doc/ghc-' . haskellmode#GHC_Version() . '/html/' if isdirectory(location1a) let s:docdir = location1a elseif isdirectory(location1b) @@ -164,7 +160,7 @@ endif command! DocSettings call DocSettings() function! DocSettings() - for v in ["g:haddock_browser","g:haddock_browser_callformat","g:haddock_docdir","g:haddock_indexfiledir","s:ghc_libdir","s:ghc_version","s:docdir","s:libraries","s:guide","s:haddock_indexfile"] + for v in ["g:haddock_browser","g:haddock_browser_callformat","g:haddock_docdir","g:haddock_indexfiledir","s:ghc_libdir","g:ghc_version","s:docdir","s:libraries","s:guide","s:haddock_indexfile"] if exists(v) echo v '=' eval(v) else @@ -317,8 +313,12 @@ command! DocIndex call DocIndex() function! DocIndex() let files = split(globpath(s:libraries,'doc-index*.html'),'\n') let g:haddock_index = {} - call ProcessHaddockIndexes2(s:libraries,files) - if GHC_VersionGE([6,8,2]) + if haskellmode#GHC_VersionGE([7,0,0]) + call ProcessHaddockIndexes3(s:libraries,files) + else + call ProcessHaddockIndexes2(s:libraries,files) + endif + if haskellmode#GHC_VersionGE([6,8,2]) if &shell =~ 'sh' " unix-type shell let s:addon_libraries = split(system(g:ghc_pkg . ' field \* haddock-html'),'\n') else " windows cmd.exe and the like @@ -330,7 +330,11 @@ function! DocIndex() let [_,quote,file,addon_path;x] = ml let addon_path = substitute(addon_path,'\(\\\\\|\\\)','/','g') let addon_files = split(globpath(addon_path,'doc-index*.html'),'\n') - call ProcessHaddockIndexes2(addon_path,addon_files) + if haskellmode#GHC_VersionGE([7,0,0]) + call ProcessHaddockIndexes3(addon_path,addon_files) + else + call ProcessHaddockIndexes2(addon_path,addon_files) + endif endif endfor endif @@ -425,6 +429,63 @@ function! ProcessHaddockIndexes2(location,files) endfor endfunction +function! ProcessHaddockIndexes3(location,files) + let entryPat= '>\(.*\)$' + let linkPat = 'target[0])) - return 1 - elseif (i==target[0]) - let target = target[1:] - else - return 0 - endif - endfor - return 1 -endfunction -- cgit v1.2.3-54-g00ecf