This repository has been archived by the owner on Mar 4, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LoadComponent, BackgroundTypecheckFile, ThingAtPoint all seem to work fine.
- Loading branch information
Showing
3 changed files
with
112 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,83 @@ | ||
finish | ||
" old shim stuff : | ||
setlocal omnifunc=haskellcomplete#CompleteIdentifier | ||
setlocal completefunc=haskellcomplete#CompleteModule | ||
command! -nargs=1 GrepScope call haskellcomplete#GrepScope(<f-args>) | ||
command! -nargs=1 FindModulesExporting echo haskellcomplete#FindModulesExporting(<f-args>) | ||
if exists('g:dont_load_haskell_scion_interface_simple') | ||
finish | ||
endif | ||
|
||
let g:haskellModuleImportBehaviour = 'interactive' " one of interactive, automatic | ||
" r = scion result with error locations | ||
" func : either setqflist or setloclist | ||
fun! ScionResultToErrorList(action, func, r) | ||
let compilationResult = has_key(a:r, 'compilationResult') ? a:r['compilationResult'] : a:r | ||
let g:foo = compilationResult | ||
let qflist = compilationResult['compilationErrors'] + compilationResult['compilationWarnings'] | ||
|
||
if !exists('g:modulePreferenceCacheFile') | ||
let g:modulePreferenceCacheFile = expand('$HOME').'/.vim/modulePreferenceCacheFile' | ||
endif | ||
" for debugging | ||
let g:scion_qf_list = qflist | ||
if has_key(a:r, 'inProject') | ||
let inProj = "inProject : ". a:r['inProject'] | ||
else | ||
let inProj = "" | ||
endif | ||
if (has_key(a:r,'compilationSucceeded') && a:r['compilationSucceeded']) | ||
\ || (!has_key(a:r, 'compilationSucceeded') && len(qflist) == 0) | ||
return printf(a:action." success. ".inProj." compilationTime: %s", compilationResult['compilationTime']) | ||
else | ||
call call(a:func, [qflist]) | ||
return printf(a:action." there are errors, ".inProj." compilationTime: %s", compilationResult['compilationTime']) | ||
endif | ||
endfun | ||
|
||
if filereadable(g:modulePreferenceCacheFile) | ||
let g:modulePreferences = eval(readfile(g:modulePreferences, 'b')) | ||
else | ||
let g:modulePreferences = { | ||
\ 'Data.Map' : { 'q' : 'M' } | ||
\ , 'Control.Monad' : { 'fitness' : 10 } | ||
" very simple user interface to expose scion functionality | ||
" I'll implement a better interface in tovl. | ||
" (http://github.com/MarcWeber/theonevimlib) | ||
|
||
\ } | ||
endif | ||
fun! s:BackgroundTypecheckFile(...) | ||
" no file given defaults to current buffer | ||
let file = a:0 > 0 ? a:1 : expand('%:p') | ||
let r = haskellcomplete#EvalScion({'request' : 'cmdBackgroundTypecheckFile', 'file' : file}) | ||
echo ScionResultToErrorList('file check', 'setqflist', r) | ||
endf | ||
|
||
fun! s:OpenCabalProject(...) | ||
let builddir = a:0 > 0 ? a:1 : "dist" | ||
echo haskellcomplete#EvalScion( | ||
\ {'request' : 'cmdOpenCabalProject', 'root_dir' : getcwd(), | ||
\ 'dist_dir' : builddir, 'extra_args' : a:000[1:] } | ||
\) | ||
endf | ||
|
||
" ===== you don't need any project for these: ============= | ||
command! -buffer ConnectionInfo | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdConnectionInfo'}) | ||
|
||
" list supported languages | ||
command! -buffer ListSupportedLanguages | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedLanguages'}) | ||
|
||
" list supported pragmas | ||
command! -buffer ListSupportedPragmas | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedPragmas'}) | ||
|
||
" list supported flags | ||
command! -buffer ListSupportedFlags | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedFlags'}) | ||
|
||
" ===== loading a cabal project: ============================ | ||
|
||
" assuming pwd is current cabal directory containing the .cabal file | ||
" optional argument specifies the cabal build (dist) directory | ||
command! -buffer -nargs=* -complete=file OpenCabalProject | ||
\ call s:OpenCabalProject(<f-args>) | ||
|
||
" returns 0 (= not importet) | ||
" or { 'q' : <opitonal qualifier name> | ||
" , 'functions' : [ list of explicit imported functions ] } | ||
function! ImportInfo(module) | ||
let pos = | ||
endfunction | ||
" arg either "library" or "executable:name" | ||
command! -buffer -nargs=1 LoadComponent | ||
\ echo ScionResultToErrorList('load component finished: ','setqflist',haskellcomplete#EvalScion({'request' : 'cmdLoadComponent', 'component' : <q-args>})) | ||
|
||
" list exposed | ||
command! -buffer ListExposedModules | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdListExposedModules'}) | ||
command! -buffer -nargs=* -complete=file BackgroundTypecheckFile | ||
\ call s:BackgroundTypecheckFile(<f-args>) | ||
command! -buffer ThingAtPoint | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdThingAtPoint', 'file' : expand('%:p'), 'line' : line('.').'', 'col' : col('.').''}) | ||
|
||
" needs g:modulePreferences, g:haskellModuleImportBehaviour | ||
function! HaskellImportIdentifier(id) | ||
let modules = haskellcomplete#FindModulesExporting(a:id) | ||
endfunction | ||
command! -buffer ListRdrNamesInScope | ||
\ echo haskellcomplete#EvalScion({'request' : 'cmdListRdrNamesInScope'}) |