Skip to content
Browse files

Unpacked haskellmode-20101118.vba

  • Loading branch information...
1 parent 7dcd6c2 commit 03f8631d76d8ad20e6bd6368f059c1a2b70b7c3a @ingemaradahl committed Oct 8, 2012
Showing with 22 additions and 62 deletions.
  1. +1 −2 autoload/haskellmode.vim
  2. +7 −21 compiler/ghc.vim
  3. +0 −10 doc/haskellmode.txt
  4. +14 −29 ftplugin/haskell_doc.vim
View
3 autoload/haskellmode.vim
@@ -1,7 +1,7 @@
"
" utility functions for haskellmode plugins
"
-" (Claus Reinke; last modified: 11/12/2010)
+" (Claus Reinke; last modified: 22/06/2010)
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" please send patches to <claus.reinke@talk21.com>
@@ -143,7 +143,6 @@ function! haskellmode#GatherImport(lineno)
let close += strlen(substitute(linecont,'[^)]','','g'))
let import .= linecont
endwhile
- let import = substitute(import,'\s\+',' ','g')
return [lineno,import]
endfunction
View
28 compiler/ghc.vim
@@ -2,7 +2,7 @@
" Vim Compiler File
" Compiler: GHC
" Maintainer: Claus Reinke <claus.reinke@talk21.com>
-" Last Change: 22/01/2011
+" Last Change: 22/06/2010
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
@@ -87,17 +87,10 @@ function! GHC_ShowType(addTypeDecl)
let [_,symb,qual,unqual] = namsym
let name = qual=='' ? unqual : qual.'.'.unqual
let pname = ( symb ? '('.name.')' : name )
- let ok = GHC_HaveTypes()
+ call GHC_HaveTypes()
if !has_key(b:ghc_types,name)
- redraw " this happens to hide messages from GHC_HaveTypes
- if &modified
- let comment = " (buffer has unsaved changes)"
- elseif !ok
- let comment = " (try :make to see any GHCi errors)"
- else
- let comment = ""
- endif
- echo pname "type not known".comment
+ redraw
+ echo pname "type not known"
else
redraw
for type in split(b:ghc_types[name],' -- ')
@@ -130,10 +123,10 @@ if has("balloon_eval")
let pname = name " ( symb ? '('.name.')' : name )
if b:ghc_types == {}
redraw
- echo "no type information (try :GHCReload)"
+ echo "no type information (try :GHGReload)"
elseif (b:my_changedtick != b:changedtick)
redraw
- echo "type information may be out of date (try :GHCReload)"
+ echo "type information may be out of date (try :GHGReload)"
endif
" silent call GHC_HaveTypes()
if b:ghc_types!={}
@@ -177,13 +170,11 @@ function! GHC_HaveTypes()
if b:ghc_types == {} && (b:my_changedtick != b:changedtick)
let b:my_changedtick = b:changedtick
return GHC_BrowseAll()
- else
- return 1
endif
endfunction
" update b:ghc_types after successful make
-au QuickFixCmdPost make if exists("current_compiler") && current_compiler=="ghc" && (GHC_CountErrors()==0) | silent call GHC_BrowseAll() | endif
+au QuickFixCmdPost make if GHC_CountErrors()==0 | silent call GHC_BrowseAll() | endif
" count only error entries in quickfix list, ignoring warnings
function! GHC_CountErrors()
@@ -226,9 +217,6 @@ endfunction
function! GHC_BrowseBangStar(module)
redraw
echo "browsing module " a:module
- " TODO: this doesn't work if a:module is loaded compiled - we
- " could try to give a more helpful error message, or use
- " -fforce-recomp directly
let command = ":browse! *" . a:module
let orig_shellredir = &shellredir
let &shellredir = ">" " ignore error/warning messages, only output or lack of it
@@ -262,7 +250,6 @@ function! GHC_ProcessBang(module,output)
let definedPat = '^-- defined locally'
let importedPat = '^-- imported via \(.*\)'
if !(b=~commentPat)
- redraw
echo s:scriptname.": GHCi reports errors (try :make?)"
return 0
endif
@@ -313,7 +300,6 @@ function! GHC_Process(imports,output)
let modPat = '^-- \(\S*\)'
" add '-- defined locally' and '-- imported via ..'
if !(b=~modPat)
- redraw
echo s:scriptname.": GHCi reports errors (try :make?)"
return 0
endif
View
10 doc/haskellmode.txt
@@ -184,17 +184,7 @@ CONTENTS *haskellmode*
>
:let g:haddock_browser_callformat = '%s file://%s '.printf(&shellredir,'/dev/null').' &'
<
- *g:haddock_browser_nosilent*
-
- If you find that on your system opening the documentation browser corrupts
- the vim display, you can choose to not exec the browser silently. This
- often fixes the display but means you have to press a key to continue
- after opening the browser.
->
- :let g:haddock_browser_nosilent = 1
-<
*g:haddock_docdir*
-
Your system's installed Haddock documentation for GHC and its libraries
should be automatically detected. If the plugin can't locate them, you
must point |g:haddock_docdir| to the path containing the master index.html
View
43 ftplugin/haskell_doc.vim
@@ -2,7 +2,7 @@
" use haddock docs and index files
" show documentation, complete & qualify identifiers
"
-" (Claus Reinke; last modified: 11/12/2010)
+" (Claus Reinke; last modified: 17/06/2009)
"
" part of haskell plugins: http://projects.haskell.org/haskellmode-vim
" please send patches to <claus.reinke@talk21.com>
@@ -38,7 +38,6 @@ let s:scriptname = "haskell_doc.vim"
" script parameters
" g:haddock_browser *mandatory* which browser to call
" g:haddock_browser_callformat [optional] how to call browser
-" g:haddock_browser_nosilent [optional] don't exec the browser silently
" g:haddock_indexfiledir [optional] where to put 'haddock_index.vim'
" g:haddock_docdir [optional] where to find html docs
" g:ghc [optional] which ghc to call
@@ -178,12 +177,7 @@ function! DocBrowser(url)
endif
" start browser to open url, according to specified format
let url = a:url=~'^\(file://\|http://\)' ? a:url : 'file://'.a:url
- if (exists("g:haddock_browser_nosilent") && g:haddock_browser_nosilent)
- exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%'))
- else
- silent exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%'))
- endif
- redraw!
+ silent exe '!'.printf(g:haddock_browser_callformat,g:haddock_browser,escape(url,'#%'))
endfunction
"Doc/Doct are an old interface for documentation lookup
@@ -257,7 +251,7 @@ function! IDoc(name,...)
let choices = HaddockIndexLookup(a:name)
if choices=={} | return | endif
if a:0==0
- let keylist = map(deepcopy(keys(choices)),'substitute(v:val,"\\[.\\]\\( (.*)\\)\\?","","")')
+ let keylist = map(deepcopy(keys(choices)),'substitute(v:val,"\\[.\\]","","")')
let choice = inputlist(keylist)
else
let choice = a:1
@@ -531,7 +525,7 @@ function! MkHaddockModuleIndex()
for module in keys(dict)
let html = dict[module]
let html = substitute(html ,'#.*$','','')
- let module = substitute(module,'\[.\]\( (.*)\)\?','','')
+ let module = substitute(module,'\[.\]','','')
let ml = matchlist(html,'libraries/\([^\/]*\)[\/]')
if ml!=[]
let [_,package;x] = ml
@@ -587,7 +581,7 @@ function! Haddock()
if dict=={} | return | endif
" for qualified items, narrow results to possible imports that provide qualifier
let filteredKeys = filter(copy(keys(dict))
- \ ,'match(asm,substitute(v:val,''\[.\]\( (.*)\)\?'','''',''''))!=-1')
+ \ ,'match(asm,substitute(v:val,''\[.\]'','''',''''))!=-1')
let keys = (qual!='') ? filteredKeys : keys(dict)
if (keys==[]) && (qual!='')
echoerr qual.'.'.unqual.' not found in imports'
@@ -599,7 +593,7 @@ function! Haddock()
call DocBrowser(dict[keys[0]])
elseif has("gui_running")
for key in keys
- exe 'amenu ]Popup.'.escape(key,'\. ').' :call DocBrowser('''.dict[key].''')<cr>'
+ exe 'amenu ]Popup.'.escape(key,'\.').' :call DocBrowser('''.dict[key].''')<cr>'
endfor
popup ]Popup
else
@@ -791,7 +785,7 @@ function! Qualify()
let prefix = (start<=1 ? '' : getline(line)[0:start-2] )
let dict = HaddockIndexLookup(name)
if dict=={} | return | endif
- let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]\\( (.*)\\)\\?","","")')
+ let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")')
let imports = haskellmode#GatherImports()
let qualifiedImports = []
for qualifiedImport in keys(imports[1])
@@ -829,19 +823,9 @@ function! Qualify()
endif
endfunction
-function! FindImportPosition()
- let save_cursor = getpos(".")
- let line1 = search('\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)','b')
- " jump over possible multiline statements
- let line2 = search('^\(\s*\|\S.*\)$','')
- call setpos('.', save_cursor)
- " insert position is after statement, before any following declarations
- return ( line2 > line1 ? line2-1 : line1 )
-endfunction
-
" create (qualified) import for a (qualified) name
-" TODO: - refine search patterns, to avoid misinterpretation of
-" oddities like import'Neither or not'module
+" TODO: refine search patterns, to avoid misinterpretation of
+" oddities like import'Neither or not'module
map <LocalLeader>i :call Import(0,0)<cr>
map <LocalLeader>im :call Import(1,0)<cr>
map <LocalLeader>iq :call Import(0,1)<cr>
@@ -862,25 +846,26 @@ function! Import(module,qualified)
let qualified = a:qualified ? 'qualified ' : ''
if qual!=''
- exe 'call append(FindImportPosition(),''import '.qualified.qual.importlist.''')'
+ exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.qual.importlist.''')'
return
endif
let line = line('.')
let prefix = getline(line)[0:start-1]
let dict = HaddockIndexLookup(name)
if dict=={} | return | endif
- let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]\\( (.*)\\)\\?","","")')
+ let keylist = map(deepcopy(keys(dict)),'substitute(v:val,"\\[.\\]","","")')
if has("gui_running")
for key in keylist
- exe 'amenu ]Popup.'.escape(key,'\.').' :call append(FindImportPosition(),''import '.qualified.key.escape(importlist,'|').''')<cr>'
+ " exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search("\\%1c\\(import\\\\|module\\\\|{-# OPTIONS\\)","nb"),"import '.key.importlist.'")<cr>'
+ exe 'amenu ]Popup.'.escape(key,'\.').' :call append(search(''\%1c\(\<import\>\\|\<module\>\\|{-# OPTIONS\\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.escape(importlist,'|').''')<cr>'
endfor
popup ]Popup
else
let s:choices = keylist
let key = input('import '.name.' from: ','','customlist,CompleteAux')
if key!=''
- exe 'call append(FindImportPosition(),''import '.qualified.key.importlist.''')'
+ exe 'call append(search(''\%1c\(\<import\>\|\<module\>\|{-# OPTIONS\|{-# LANGUAGE\)'',''nb''),''import '.qualified.key.importlist.''')'
endif
endif
endfunction

0 comments on commit 03f8631

Please sign in to comment.
Something went wrong with that request. Please try again.