Browse files

vim:

README.markdown updates: all API functions should be callable now

add quickfix hook:
- Jump to first error
* Open Quickfix Window when there is at least one warnings

Recommend a stdin/out scion connection. So that vim can run multiple servers itself
stdin/stdout server mode: add current directory to logfile name

adding vim hack:
The hack mapps true,false,null to 1,0,"" before encoding the json
strings so that vim's eval function can be used because vim doesn't have
true,false,null values hence can't parse that.
json#Encode() is used so that we even can send null to the server
  • Loading branch information...
1 parent 4be6256 commit c7742905c49f5a7f7e23de7d1a3cb3d36dbe6005 @MarcWeber MarcWeber committed Jul 23, 2009
View
33 README.markdown
@@ -167,30 +167,45 @@ Vim:
ensure :echo has('python')
returns 1
- add to your ~/.vimrc (TODO make this lazy so that python is only loaded when required!):
+ add to your ~/.vimrc:
+
+
+ " recommended: vim spawns a scion instance itself:
+ let g:scion_connection_setting = [ 'scion', "path to scion_server executable"]
+
+ " use socket or TCP/IP connection instead:
+ "let g:scion_connection_setting = [ 'socket', ["localhost", 4005] ]
+ "let g:scion_connection_setting = [ 'socket', "socket file " ]
- py scionConnectionSetting = ('socket', ("localhost",4005))
set runtimepath+=<path to scion repo/vim_runtime_path/>
- :e some_hs_file.hs
- :OpenCabalProject
+ use one of
- :LoadComponent library
- or
- :LoadComponent executable:cabal_executable_name
+ :LoadComponentScion library
+ :LoadComponentScion executable:cabal_executable_name
+ :LoadComponentScion file:cabal_executable_name
+ :LoadComponentScion
+
+ The last one is a shortcut for file:<this buf>
+
+ (you can use completion)
At this point you should already get some compilation errors.
use
- :BackgroundTypecheckFile
+ :BackgroundTypecheckFileScion
before
- :ThingAtPoint
+ :ThingAtPointScion
You should see something like:
{'Just': 'print :: [Char] -> IO ()'}
Have a look at vim_runtime_path/ftplugin/haskell.vim to see a list of all
commands which are implemented yet.
+
+ BackgroundTypecheckFileScion should be called automatically after buf write.
+ If you don't like this set g:dont_check_on_buf_write or overwrite g:haskell_qf_hook
+ to change open/close quickfix and jump to first *error* behaviour.
Bug Reports
===========
View
7 lib/Scion/Types.hs
@@ -62,13 +62,16 @@ data SessionState
bgTcCache :: Maybe BgTcCache,
-- ^ Cached state of the background typechecker.
- defSiteDB :: DefSiteDB
+ defSiteDB :: DefSiteDB,
-- ^ Source code locations.
+
+ client :: String
+ -- ^ can be set by the client. Only used by vim to enable special hack
}
mkSessionState :: DynFlags -> IO (IORef SessionState)
mkSessionState dflags =
- newIORef (SessionState normal dflags Nothing Nothing mempty Nothing Nothing mempty)
+ newIORef (SessionState normal dflags Nothing Nothing mempty Nothing Nothing mempty "")
newtype ScionM a
View
6 server/Scion/Server/Commands.hs
@@ -172,6 +172,7 @@ allCommands =
, cmdDumpDefinedNames
, cmdDefinedNames
, cmdNameDefinitions
+ , cmdIdentify
]
------------------------------------------------------------------------------
@@ -575,3 +576,8 @@ cmdNameDefinitions =
db <- gets defSiteDB
let locs = map fst $ lookupDefSite db nm
return locs
+
+cmdIdentify :: Cmd
+cmdIdentify =
+ Cmd "client-identify" $ reqArg' "name" fromJSString $ cmd
+ where cmd c = modifySessionState $ \s -> s { client = c }
View
15 server/Scion/Server/Generic.hs
@@ -5,10 +5,12 @@ module Scion.Server.Generic
import Prelude hiding ( log )
import Scion
+import Scion.Types (gets, SessionState(..))
import Scion.Server.ConnectionIO as CIO
import Scion.Server.Commands
import Text.JSON
+import Text.JSON.Types
import qualified Data.ByteString.Lazy.Char8 as S
import qualified Data.ByteString.Lazy.UTF8 as S
import qualified System.Log.Logger as HL
@@ -36,7 +38,8 @@ handle con 0 = do
<- case mb_req of
Error _ -> return (malformedRequest, True)
Ok req -> handleRequest req
- let resp_str = encodeStrict resp
+ c <- gets client
+ let resp_str = encodeStrict (if (c == "vim") then vimHack resp else resp)
logDebug $ show resp_str
liftIO $ CIO.putLine con (S.fromString resp_str)
--logDebug $ "sent response"
@@ -50,3 +53,13 @@ handle con unknownVersion = do
S.pack $ "failure: Don't know how to talk to client version "
++ (show unknownVersion)
return False
+
+-- vim doesn't know about true,false,null thus can't parse it. this functions
+-- mapps those values to 1,0,""
+vimHack :: JSValue -> JSValue
+vimHack JSNull = JSString (toJSString "")
+vimHack (JSBool True) = JSRational False 1
+vimHack (JSBool False) = JSRational False 0
+vimHack (JSArray l) = JSArray $ map vimHack l
+vimHack (JSObject (JSONObject list)) = JSObject $ JSONObject $ map (\(x,y) -> (x, vimHack y)) list
+vimHack e = e -- JSRational, JSString
View
182 vim_runtime_path/autoload/haskellcomplete.vim
@@ -2,15 +2,15 @@
" -> haskellcomplete#EvalScion )
"
" This implementation requires has('python') support
-"
+
" You can look up some use cases in the ftplugin file.
"
" This code is based on the initial implementation found in shim by Benedikt Schmidt
" The server side code can be found in src-scion-server/Scion/Server/ProtocolVim.hs
if exists('g:tovl')
fun! s:Log(level, msg)
- call tovl#log#Log("haskellcomplete",a:level, a:msg)
+ call tovl#log#Log("haskellcomplete",a:level, type(a:msg) == type("") ? a:msg : string(a:msg))
endf
else
fun! s:Log(level, msg)
@@ -23,8 +23,118 @@ if !has('python') | call s:Log(0, "Error: scion requires vim compiled with +pyth
let g:vim_scion_protocol_version = "0"
+fun! haskellcomplete#LoadComponent(set_cabal_project, component)
+ let result = haskellcomplete#EvalScion(0, 'load-component', { 'component' : a:component})
+ if has_key(result,'error')
+ if result['error']['message'] == "NoCurrentCabalProject" && a:set_cabal_project
+ let cabal_project = haskellcomplete#SetCurrentCabalProject()
+ return haskellcomplete#LoadComponent(0, a:component)
+ else
+ throw "can't handle this failure: ".string(result['error'])
+ endif
+ endif
+ return result['result']
+endf
+
+fun! haskellcomplete#SetCurrentCabalProject()
+ let configs = haskellcomplete#EvalScion(1,'list-cabal-configurations',
+ \ { 'cabal-file' : haskellcomplete#CabalFile()})
+ let config = haskellcomplete#ChooseFromList(configs, 'select a cabal configuration')
+ let result = haskellcomplete#EvalScion(1,'open-cabal-project'
+ \ ,{'root-dir' : getcwd()
+ \ ,'dist-dir' : config['dist-dir']
+ \ ,'extra-args' : config['extra-args'] }
+ \ )
+endf
+
+" if there is item take it, if there are more than one ask user which one to
+" use.. -- don't think cabal allows multiple .cabal files.. At least the user
+" is notified that there are more than one .cabal files
+fun! haskellcomplete#ChooseFromList(list, ...)
+ let msg = a:0 > 0 ? a:1 : "choose from list"
+ if empty(a:list)
+ return
+ elseif len(a:list) == 1
+ return a:list[0]
+ else
+ let l = []
+ let i = 1
+ for line in a:list
+ let line2 = type(line) != type('') ? string(line) : line
+ call add(l, i.': '.line2)
+ let i = i + 1
+ unlet line
+ endfor
+ return a:list[inputlist(l)-1]
+ endif
+endf
+
+fun! haskellcomplete#CabalFile()
+ if !exists('g:cabal_file')
+ let list = split(glob('*.cabal'),"\n")
+ if empty(list)
+ throw "no cabal file found"
+ endif
+ let g:cabal_file = getcwd().'/'.haskellcomplete#ChooseFromList(list)
+ endif
+ return g:cabal_file
+endf
+
+fun! haskellcomplete#List(what)
+ return haskellcomplete#EvalScion(1,'list-'.a:what, {})
+endf
+
+fun! haskellcomplete#OpenCabalProject(method, ...)
+ return haskellcomplete#EvalScion(1,a:method
+ \ ,{'root-dir' : getcwd()
+ \ ,'dist-dir' : a:1
+ \ ,'extra-args' : a:000[1:] }
+ \ )
+endf
+
+fun! haskellcomplete#compToV(...)
+ let component = a:0 > 0 ? a:1 : 'file:'.expand('%:p')
+ let m = matchstr(component, '^executable:\zs.*')
+ if m != '' | return {'executable' : m} | endif
+ let m = matchstr(component, '^library$')
+ if m != '' | return {'library' : json#NULL()} | endif
+ let m = matchstr(component, '^file:\zs.*')
+ if m != '' | return {'file' : m} | endif
+ throw "invalid component".a:component
+endfun
+
+fun! haskellcomplete#WriteSampleConfig(...)
+ let file = a:0 > 0 ? a:1 : ".scion-config"
+ let file = fnamemodify(file, ":p")
+ return haskellcomplete#EvalScion(1, 'write-sample-config', {'file' : file})
+endf
+
+" if there are errors open quickfix and jump to first error (ignoring warning)
+" if not close it
+fun! haskellcomplete#SaneHook()
+ let list = getqflist()
+ let nr = 0
+ let open = 0
+ let firstError = 0
+ for i in getqflist()
+ let nr = nr +1
+ if i['bufnr'] == 0 | continue | endif
+ if i['type'] == "E" && firstError == 0
+ let firstError = nr
+ endif
+ let open = 1
+ endfor
+ if open
+ cope " open
+ " move to first error
+ if firstError > 0 | exec "crewind ".firstError | endif
+ else
+ cclose
+ endif
+endf
+
" use this to connect to a socket
-" py scionConnectionSetting = "/tmp/scion-io"
+" connection settings: see strings in connectscion
" returns string part before and after cursor
function! haskellcomplete#BcAc()
@@ -57,30 +167,48 @@ fun! haskellcomplete#CompletModule(findstart, base)
endif
endf
-" example: echo haskellcomplete#EvalScion({'request' : 'cmdConnectionInfo', 'file' : 'test.hs'})
-function! haskellcomplete#EvalScion(request)
+let g:scion_request_id = 1
+
+" name: method name
+" params: params to method
+" optional argument: continuation function (not yet implemented)
+" returns: nothing when continuation function is given
+" reply else
+function! haskellcomplete#EvalScion(fail_on_error, method, params, ...)
+ if a:0 > 0
+ let continuation a:0
+ endif
+ let g:scion_request_id = g:scion_request_id + 1
+ let request = { 'method' : a:method, 'params' : a:params, 'id' : g:scion_request_id }
" the first string converts the vim object into a string, the second
" converts this string into a python string
- let g:scion_arg = string(a:request)
+ let g:scion_arg = json#Encode(request)
py evalscionAssign(vim.eval('g:scion_arg'))
" warnings
for w in get(g:scion_result, 'warnings', [])
call s:Log(1, w) | echo w
endfor
" errors
+
+ if !a:fail_on_error
+ return g:scion_result
+ endif
+
if has_key(g:scion_result,'error')
call s:Log(0, g:scion_result['error'])
- throw "There was a scion server error :".g:scion_result['error']
+ throw "There was a scion server error :".string(g:scion_result['error'])
else
return g:scion_result['result']
endif
endfunction
function! s:DefPython()
python << PYTHONEOF
-import sys, tokenize, cStringIO, types, socket, string, vim, popen2
+import sys, tokenize, cStringIO, types, socket, string, vim, popen2, os
from subprocess import Popen, PIPE
+scion_log_stdout = vim.eval('exists("g:scion_log_stdout") && g:scion_log_stdout')
+scion_stdout = []
class ScionServerConnection:
"""base of a server connection. They all provide two methods: send and receive bothe sending or receiving a single line separated by \\n"""
@@ -93,8 +221,9 @@ class ScionServerConnection:
class ScionServerConnectionStdinOut(ScionServerConnection):
"""this connection launches the server and connects to its stdin and stdout streams"""
def __init__(self, scion_executable):
- #self.scion_o,self.scion_i,e = popen2.popen3('%s -i -f /tmp/scion-log'%(scion_executable))
- p = Popen([scion_executable,"-i","-f", "/tmp/scion-log"], shell = False, bufsize = 1, stdin = PIPE, stdout = PIPE, stderr = PIPE)
+ #self.scion_o,self.scion_i,e = popen2.popen3('%s -i -f /tmp/scion-log-%s' % (scion_executable, os.getcwd().replace('/','_').replace('\\','_'))
+ p = Popen([scion_executable,"-i","-f", "/tmp/scion-log-%s"%(os.getcwd().replace('/','_').replace('\\','_'))], \
+ shell = False, bufsize = 1, stdin = PIPE, stdout = PIPE, stderr = PIPE)
self.scion_o = p.stdout
self.scion_i = p.stdin
def receive(self):
@@ -106,16 +235,23 @@ class ScionServerConnectionStdinOut(ScionServerConnection):
return s[6:]
else:
# throw away non "scion:" line and try again
+ global scion_log_stdout, scion_stdout
+ if log_stdout:
+ scion_stdout.append(s)
+
return self.receive()
class ScionServerConnectionSocket(ScionServerConnection):
"""connects to the scion server by either TCP/IP or socketfile"""
def __init__(self, connection):
- # connection either (host, port) or (socketfile)
- if type(connection) == type((0,0)):
- # tuple -> host, port
+ if type(connection) == type([]):
+ # array [ host, port ]
+ # vim.eval always returns strings!
+ connection = (connection[0], string.atoi(connection[1]))
+ print "connection is now %s" % connection.__str__()
su = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
else: # must be path -> file socket
+ print "else "
su = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
su.settimeout(10)
su.connect(connection)
@@ -132,28 +268,26 @@ def connectscion():
global told_user_about_missing_configuration
if 0 == told_user_about_missing_configuration:
try:
+ # use connection form vim value so that python is used as lazily as possible
+ scionConnectionSetting = vim.eval('g:scion_connection_setting')
print "connecting to scion %s"%scionConnectionSetting.__str__()
except NameError:
vim.command("sp")
b = vim.current.buffer
- b.append( "you haven't defined scionConnectionSetting")
+ b.append( "you haven't defined g:scion_connection_setting")
b.append( "Do so by adding one of the following lines to your .vimrc:")
b.append( "TCP/IP, socket, stdio")
- b.append( "py scionConnectionSetting = ('socket', \"socket file location\") # socket connection")
- b.append( "py scionConnectionSetting = ('socket', ('localhost', 4005)) # host, port TCIP/IP connection")
- b.append( "py scionConnectionSetting = ('scion', \"scion_server location\") # stdio connection ")
+ b.append( "let g:scion_connection_setting = ['socket', \"socket file location\"] # socket connection")
+ b.append( "let g:scion_connection_setting = ['socket', ['localhost', 4005]] # host, port TCIP/IP connection")
+ b.append( "let g:scion_connection_setting = ['scion', \"scion_server location\"] # stdio connection ")
told_user_about_missing_configuration = 1
if scionConnectionSetting[0] == "socket":
server_connection = ScionServerConnectionSocket(scionConnectionSetting[1])
else:
- server_connection = ScionServerConnectionStdinOut(scionConnectionSetting[1])
-
- # handshake
- server_connection.send("select scion-server protocol:vim %s" % vim.eval('g:vim_scion_protocol_version'))
- res = server_connection.receive()
- if res != "ok":
- raise Exception("failed connecting to scion Reason: `%s'" % res)
+ server_connection = ScionServerConnectionStdinOut(scionConnectionSetting[1])
+ # tell server than vim doesn't like true, false, null
+ vim.command('call haskellcomplete#EvalScion(1, "client-identify", {"name":"vim"})')
# sends a command and returns the returned line
def evalscion(str):
View
31 vim_runtime_path/autoload/json.vim
@@ -0,0 +1,31 @@
+" vim encodes strings using ''. JSON requires ".
+
+" dummy type which is used to encode "null"
+" same could be done for true / false. But we don't use those yet
+fun! json#NULL()
+ return function("json#NULL")
+endf
+
+fun! json#Encode(thing)
+ if type(a:thing) == type("")
+ return '"'.escape(a:thing,'"').'"'
+ elseif type(a:thing) == type({})
+ let pairs = []
+ for [key, value] in items(a:thing)
+ call add(pairs, json#Encode(key).':'.json#Encode(value))
+ unlet key | unlet value
+ endfor
+ return "{".join(pairs, ",")."}"
+ elseif type(a:thing) == type(0)
+ return a:thing
+ elseif type(a:thing) == type([])
+ return '['.join(map(a:thing, "json#Encode(v:val)"),",").']'
+ return
+ elseif string(a:thing) == string(json#NULL())
+ return "null"
+ else
+ throw "unexpected new thing: ".string(a:thing)
+ endif
+endf
+
+" usage example: echo json#Encode({'method': 'connection-info', 'id': 0, 'params': [3]})
View
213 vim_runtime_path/ftplugin/haskell.vim
@@ -4,98 +4,187 @@ endif
" 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']
-
- " for debugging
- let g:scion_qf_list = qflist
- if has_key(a:r, 'inProject')
- let inProj = "inProject : ". a:r['inProject']
- else
- let inProj = ""
+fun! ScionResultToErrorList(action, func, result)
+ let qflist = []
+ for dict in a:result['notes']
+ let loc = dict['location']
+ if has_key(loc, 'no-location')
+ " using no-location so that we have an item to jump to.
+ " ef we don't use that dummy file SaneHook won't see any errors!
+ call add(qflist, { 'filename' : 'no-location'
+ \ ,'lnum' : 0
+ \ ,'col' : 0
+ \ ,'text' : loc['no-location']
+ \ ,'type' : dict['kind'] == "error" ? "E" : "W"
+ \ })
+ else
+ call add(qflist, { 'filename' : loc['file']
+ \ ,'lnum' : loc['region'][0]
+ \ ,'col' : loc['region'][1]
+ \ ,'text' : ''
+ \ ,'type' : dict['kind'] == "error" ? "E" : "W"
+ \ })
+ endif
+ for msgline in split(dict['message'],"\n")
+ call add(qflist, {'text': msgline})
+ endfor
+ endfor
+
+ call call(a:func, [qflist])
+ if exists('g:haskell_qf_hook')
+ exec g:haskell_qf_hook
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'])
+ if (len(qflist) == 0)
+ return printf(a:action." success. compilationTime: %s", string(a:result['duration']))
else
- call call(a:func, [qflist])
- return printf(a:action." there are errors, ".inProj." compilationTime: %s", compilationResult['compilationTime'])
+ return printf(a:action." There are errors. compilationTime: %s", string(a:result['duration']))
endif
endfun
+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({'request' : 'cmdBackgroundTypecheckFile', 'file' : file})
- echo ScionResultToErrorList('file check', 'setqflist', r)
+ let r = haskellcomplete#EvalScion(1, 'background-typecheck-file', {'file' : file})
+ if r[0]
+ echo ScionResultToErrorList('file check', 'setqflist', r[1])
+ else
+ echo "this file could not be checked: See backgroundTypecheckFile"
+ endif
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:] }
- \)
+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:LoadComponentCompletion(A,L,P)
let beforeC= a:L[:a:P-1]
let word = matchstr(beforeC, '\zs\S*$')
- let list = haskellcomplete#EvalScion({'request' : 'cmdListCabalTargets'})
- return filter(list, 'v:val =~ '.string('^'.word))
+ let result = []
+ for item in haskellcomplete#EvalScion(1,'list-cabal-components',{'cabal-file': haskellcomplete#CabalFile()})
+ if has_key(item, 'library')
+ call add(result, 'library') " there can only be one
+ elseif has_key(item, 'executable')
+ call add(result, 'executable:'. item['executable'])
+ else
+ " component type File will never be returned ?
+ throw "unexpected item ".string(item)
+ endif
+ endfor
+ return result
+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 ConnectionInfo
- \ echo haskellcomplete#EvalScion({'request' : 'cmdConnectionInfo'})
+command! -buffer ConnectionInfoScion
+ \ echo haskellcomplete#EvalScion(1,'connection-info',{})
" list supported languages
-command! -buffer ListSupportedLanguages
- \ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedLanguages'})
+command! -buffer ListSupportedLanguagesScion
+ \ echo haskellcomplete#List('spported-languages')
" list supported pragmas
-command! -buffer ListSupportedPragmas
- \ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedPragmas'})
+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=* -complete=file -buffer WriteSampleConfigScion
+ \ echo haskellcomplete#WriteSampleConfig(<f-args>)
-" list supported flags
-command! -buffer ListSupportedFlags
- \ echo haskellcomplete#EvalScion({'request' : 'cmdListSupportedFlags'})
+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 OpenCabalProject
- \ call s:OpenCabalProject(<f-args>)
-
-" arg either "library" or "executable:name"
-command! -buffer -nargs=1 -complete=customlist,s:LoadComponentCompletion
- \ 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('.').''})
-command! -buffer ThingAtPointExportedByHack
- \ echo filter(
- \ split(haskellcomplete#EvalScion({'request' : 'cmdThingAtPointMoreInfo'
- \, 'file' : expand('%:p')
- \, 'line' : line('.').'', 'col' : col('.').''})['Just'],"\n")
- \ , 'v:val =~ '.string(expand('<cword>').' ='))[0]
-
-command! -buffer ListRdrNamesInScope
- \ echo haskellcomplete#EvalScion({'request' : 'cmdListRdrNamesInScope'})
-
-command! -buffer ListCabalTargets
- \ echo haskellcomplete#EvalScion({'request' : 'cmdListCabalTargets'})
+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>)
+
+" arg either "library", "executable:name" or "file:Setup.hs"
+" no args: file:<current file>
+command! -buffer -nargs=? -complete=customlist,s:LoadComponentCompletion
+ \ LoadComponentScion
+ \ echo ScionResultToErrorList('load component finished: ','setqflist',haskellcomplete#LoadComponent(1,haskellcomplete#compToV(<f-args>)))
+
+command! -buffer ThingAtPointScion
+ \ echo haskellcomplete#EvalScion(1,'thing-at-point', {'file' : expand('%:p'), 'line' : 1*line('.'), 'column' : 1*col('.')})
+
+if !exists('g:dont_check_on_buf_write')
+ augroup HaskellScion
+ au BufWritePost <buffer> silent! BackgroundTypecheckFile
+ augroup end
+endif

0 comments on commit c774290

Please sign in to comment.