Skip to content
This repository
tree: 06b5af6b7d
Fetching contributors…

Cannot retrieve contributors at this time

file 124 lines (95 sloc) 4.534 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
if exists('g:dont_load_haskell_scion_interface_simple')
  finish
endif

" r = scion result with error locations
" func : either setqflist or setloclist
if !exists('g:haskell_qf_hook')
  let g:haskell_qf_hook = 'call haskellcomplete#SaneHook()'
endif

" very simple user interface to expose scion functionality
" I'll implement a better interface in tovl.
" (http://github.com/MarcWeber/theonevimlib)

fun! s:BackgroundTypecheckFile(...)
" no file given defaults to current buffer
  let file = a:0 > 0 ? a:1 : expand('%:p')
  let r = haskellcomplete#EvalScion(1, 'background-typecheck-file', {'file' : file})
  if has_key(r,'Right')
    echo haskellcomplete#ScionResultToErrorList('file check', 'setqflist', r['Right'])
  else
    call setqflist([{'text' : r['Left']}])
    cope
" isn't shown because silent is used below.. and silent is used so that
" <cr> need not to be pressed over and over again
    echo "this file could not be checked, reason: ".r['Left']."(-> backgroundTypecheckFile)"
  endif
endf

fun! s:FlagCompletion(A,L,P)
  let beforeC= a:L[:a:P-1]
  let word = matchstr(beforeC, '\zs\S*$')
  let list = haskellcomplete#List("supported-flags")
"allow glob patterns:
  call filter(list, 'v:val =~ '.string('^'.substitute(word,'*','.*','g')))
  return list
endf

fun! s:ListCabalConfigurations(...)
  let params = { 'cabal-file' : haskellcomplete#CabalFile()}
  if a:0 > 0
    let params['type'] = a:1
  endif
  return haskellcomplete#EvalScion(1,'list-cabal-configurations', params)
endf

" intentionally suffixing commands by "Scion"
" This way you have less typing. You can still get a list of Scion commands by
" :*Scion<c-d>

" ===== you don't need any project for these: =============
command! -buffer ConnectionInfoScion
  \ echo haskellcomplete#EvalScion(1,'connection-info',{})

" list supported languages
command! -buffer ListSupportedLanguagesScion
  \ echo haskellcomplete#List('supported-languages')

" list supported pragmas
command! -buffer ListSupportedPragmasScion
  \ echo haskellcomplete#List('supported-pragmas')

command! -buffer ListSupportedFlagsScion
  \ echo haskellcomplete#List('supported-flags')

command! -buffer ListRdrNamesInScopeScion
  \ echo haskellcomplete#List('rdr-names-in-scope')

command! -buffer ListCabalComponentsScion
  \ echo haskellcomplete#EvalScion(1,'list-cabal-components',{'cabal-file': haskellcomplete#CabalFile()})

command! -buffer ListExposedModulesScion
  \ echo haskellcomplete#List('exposed-modules')

command! -nargs=* ListCabalConfigurationsScion
  \ echo s:ListCabalConfigurations(<f-args>)

command! -nargs=1 SetGHCVerbosityScion
  \ echo haskellcomplete#EvalScion(1,'set-ghc-verbosity',{'level': 1*<f-args>})

command! -nargs=1 SetVerbosityScion
  \ echo haskellcomplete#EvalScion(1,'set-verbosity',{'level': 1*<f-args>})

command! -nargs=0 GetVerbosityScion
  \ echo haskellcomplete#EvalScion(1,'get-verbosity',{})

command! -nargs=0 CurrentComponentScion
  \ echo haskellcomplete#EvalScion(1,'current-component',{})

command! -nargs=0 CurrentCabalFileScion
  \ echo haskellcomplete#EvalScion(1,'current-cabal-file',{})

command! -nargs=0 DumpDefinedNamesScion
  \ echo haskellcomplete#EvalScion(1,'dump-defined-names',{})

command! -nargs=0 DefinedNamesScion
  \ echo haskellcomplete#EvalScion(1,'defined-names',{})

command! -nargs=1 NameDefinitions
  \ echo haskellcomplete#EvalScion(1,'name-definitions',{'name' : <f-args>})

command! -buffer -nargs=* -complete=file BackgroundTypecheckFileScion
  \ call s:BackgroundTypecheckFile(<f-args>)

command! -nargs=0 ForceUnloadScion
  \ echo haskellcomplete#EvalScion(1,'force-unload',{})

command! -nargs=0 DumpSourcesScion
  \ echo haskellcomplete#EvalScion(1,'dump-sources',{})

command! -nargs=1 -complete=customlist,s:FlagCompletion -buffer AddCommandLineFlagScion
  \ echo haskellcomplete#EvalScion(1,'add-command-line-flag',{'flags': [<f-args>]})

" ===== 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 OpenCabalProjectScion
  \ echo haskellcomplete#OpenCabalProject('open-cabal-project',<f-args>)
command! -buffer -nargs=* -complete=file ConfigureCabalProjectScion
  \ echo haskellcomplete#OpenCabalProject('configure-cabal-project', <f-args>)

command! -buffer ThingAtPointScion
  \ echo haskellcomplete#EvalScion(1,'thing-at-point', {'file' : expand('%:p'), 'line' : 1*line('.'), 'column' : 1*col('.')})
Something went wrong with that request. Please try again.