Client sends request, server sends zero or more notifications and then response. All notification and response has same id as request.
Message is JSON object with string id or null.
Request also specifies:
- String
command— name of command - Optional string
current-directory(default is.) — clients current directory, all file arguments can be relative. - Optional flag
no-file(default isfalse) — don't use memory mapped file (on Windows) - Optional
timeoutvalue (default is0for infinite) — timeout for command response - Optional flag
silent(default isfalse) — don't send notifications
Response on request specifies same id and can be one of:
- Result — have
resultobject, which contents depends on command - Error — have string
errorfield anddetailsobject with detailed error information - Notification — have
notifyobject with some notification
There are may be zero or many notifications and then result or error.
For example:
⋙ {"id":"0","command":"ping"}
⋘ {"id":"0","result":{"message":"pong"}}
⋙ {"id":"1","command":"pyng"}
⋘ {"id":"1","error":"Invalid request","details":{"request":...}}
⋙ {"id":"2","command":"scan","sandboxes":["cabal"]}
⋘ {"id":"2","notify":[{"name":"cabal","task":"scanning","type":"cabal","status":"working","progress":null}]}
⋘ {"id":"2","notify":[{"name":"cabal","task":"scanning","type":"cabal","status":"ok","progress":null}]}
⋘ {"id":"2","result":[]}
Ping server
Command: ping
Response: {"message":"pong"}
Listen to server's log
Command: listen
Args:
level— optional log level to listen with, one oftrace,debug,info,warning,error,fatalResponse:{}
Command: set-log
Args:
level— log level to set, one oftrace,debug,info,warning,error,fatalResponse:{}
Scan sources and installed modules
Command: scan
Args:
projects— list of projects paths or.cabalfilescabal— scan global and user package-db (trueorfalse)sandboxes— list ofsandbox paths, where path may be one of:<path>/.cabal-sandbox— cabal sandbox<path>/.stack-work— stack sandbox
files— list ofsource-fileobjects to scanbuild-tool— preferred build tool when scanning projects,cabalorstackpaths— list of directories to scanghc-opts— additional ghc optionsdocs— also get docs for sources (may be slow, you can do this by separate command)infer— infer types for sources (slow, prefer separate command) Response:{}
Scan project
Command scan project
Args:
project— path to projectbuild-tool— build tool to use,cabalorstackscan-deps— also scan dependent package-dbs Response:{}
Scan file
Command scan file
Args:
file— file pathbuild-tool— build tool to use,cabalorstackscan-project— scan related project (if any)scan-deps— also scan dependent package-dbs Response:{}
Scan list of package-db
Command scan package-dbs
Args:
package-db-stack— list ofpackage-dbs in reverse order, i.e.global-dbshould be last Response:{}
Set source string to use instead of file contents. Calls update. All commands will use this source instead of file. Can be used to perform actions on unsaved file data
Command: set-file-contents
Args:
file— file to set contentscontents— optional contents, if omitted, source will be dropped Response:{}
Scan docs or infer types for sources
Command: docs/infer
Args:
projects— list of project paths or namesfiles— list of sources Response:{}
Command: remove
Args:
projects— list of project.cabalfiles or names to removecabal— remove global-db and user-dbsandboxes— list ofsandboxobjects to remove (see above)files— list of sources Response:{}
Command: remove-all
Response: {}
Command: packages/projects/sandboxes
Response: list of package/project/package-db objects
Get symbols info
Command: symbol
Args:
query—queryobject:input— input stringtype— query type, one of:exact— exact matchprefix— prefix matchinfix— infix matchsuffix— suffix match
filters— list offilter-objects:{"project":<project .cabal or name>}{"file":<source file>}{"module":<module name>}{"package":<package name>}"installed"— search for installed modules"sources"— search for sourced"standalone"— search for standalone (project-free)
locals— search in local declarations (default isfalse)header— return only header — name and module Response: list ofsymbol-id(ifheader) orsymbolobjects
Get modules info
Command: module
Args:
query—queryobjectfilters— list offilterobjectsheader— return only module header — name and locationinspection— include inspection data Response: list ofmodule-id(ifheader) ormoduleobjects
Get project info
Command: project
Args:
name— name of projectpath— path to.cabalResponse:projectobject
Get sandboxes info
Command: sandbox
Args:
path— path to search sandbox in Response: list ofsandboxobject
Lookup for symbol, this ignores imports and search in projects dependencies
Command: lookup
Args:
name— name of symbolfile— context file Response: list ofsymbolobjects
Get info about symbol in scope of file
Command: whois
Args:
name— name of symbol, can be qualified (Data.List.foldr), qualified with synonym (T.pack)file— context file Response: list ofsymbolobjects
Get info about symbol under cursor
Command: whoat
Args:
line— line numbercolumn— column numberfile— file name Response: list ofsymbolobjects
Resolve modules in scope of file (which can be imported)
Command: scope modules
Args:
query—queryobjectfile— context file Response: list ofmodule-idobjects
Resolve declarations in scope of file
Command: scope
Args:
query—queryobjectfile— context file Response: list ofsymbol-idobjects
Find usages of symbol
Command: usages
Args:
line— line numbercolumn— column numberfile— file name Response: list ofsymbol-usageobjects
Get completions
Command: complete
Args:
prefix— input prefixwide— wide completions, ignores importsfile— context file Response: list ofsymbolobjects
Search in hayoo
Command: hayoo
Args:
query— hayoo querypage(default is0) — start pagepages(default is1) — number of pages Response: list ofsymbolobjects
Cabal list
Command: cabal list
Args:
packages— packages to list Response: list ofcabal-packageobjects
List all unresolved symbols in source file
Command: unresolveds
Args:
files— list of files Response: list ofunresolved-symbolobjects
Lint/check source, infer types
Command: lint/check/check-lint/types
Args:
files— list ofsource-fileobjectsghc-opts— list of additional ghc options (not applied forlintcommand)lint-opts— list of hlint optionsclear(exceptlint) — set to clear targets before running command Response: list ofnote output-messageobjects
Show suggestions
Command: autofixes
Args:
messages— list ofnote output-messageobjects, which returned bylint/check/check-lintcommands Response: list ofnote refactobjects
Apply some suggestions and return updated locations of rest suggestions
Command: refactor
Args:
messages— list ofnote refactobjects to applyrest— list ofnote refactobjects to update locationspure— just update locations, don't actually modify file, useful when some editor applies suggestions itself Response: list ofnote refactobjects with updated locations
Get corrections to rename symbol, applied with refactor
Command: rename
Args:
name— symbol to renamenew-name— new nameline— line of definition, required if symbol is local, otherwise optionalcolumn— column of definition, required if symbol is local, otherwise optionalfile— symbol definition file Response: list ofnote refactobjects
Evaluate expression
Command: ghc eval
Args:
exprs— list of expressionsfile— optionalfile-sourcecontext Response: list ofrepl-resultobjects
Get type of expression
Command: ghc type
Args:
exprs— list of expressionsfile— optionalfile-sourcecontext Response: list ofrepl-resultobjects
List language extensions
Command: langs
Response: list of language extensions as strings
List compiler flags
Command: flags
Response: list of flags as strings
Link to server, so that it will exit after client disconnects
Command: link
Args:
hold— don't send response to this command Response:{}
Stop server
Command: exit
Response: {}
Package object
Fields:
name— name of packageversion— stringized version of package
Project object
Fields:
name— name of projectpath— path to project (directory)cabal— path to cabal filedescription— object:version— project versionlibrary— library description, object:modules— list of exposed modulesinfo— librarybuild-infoobject
executables— executable descriptions, list of objects:name— executable namepath— path to executableinfo— executablebuild-infoobject
tests— tests descriptions, list of objects:name— test nameenabled— is enabledmain— main moduleinfo— testbuild-infoobject
Build info object
Fields:
build-depends— list of dependencieslanguage— languageextensions— list of extensionsghc-options— list of ghc optionssource-dirs— list of source directoriesother-modules— list of other modules
Package db
One of:
"global-db"— global package-db"user-db"— user package-db"package-db:<path>"— custom package-db
Just string with path to sandbox
Module id
Fields:
name— module namelocation— location object, one of:- source file:
file— path to source fileproject— path to cabal file (ornull)
- installed module:
dirs— list of installed dirspackage— package in form<package>-<version>name— name of module
- other:
source— some ident for module
- no location: empty object
{}
- source file:
Symbol id
Fields:
name— symbol namemodule—module-idobject
Module info
Fields:
id—module-iddocs— module docsexports— exports, list ofsymbolsfixities— list of fixities objects:assoc— associativity, one ofnone,leftorrightprior— priorityname— name of operator
Symbol info
Fields:
id—symbol-iddocs— symbol docspos— symbol position, object:line— linecolumn— column
info— symbol info, object:what— symbol kind, one of:"function"— function"method"— class method"selector"— record selector"ctor"— constructor"type"— type"newtype"— newtype"data"— data"class"— class"type-family"— type family"data-family"— data family"pat-ctor"— pattern constructor"pat-selector"— pattern selector
args— list of arguments (type symbols)associate— ? (type-family/data-family)class— class name (method)constructor— constructor name (pat-selector)constructors— constructors names (selector)ctx— list of contexts (type symbols)parent— record name (selector)pat-type— pattern type (pat-type/pat-selector)type— function type (function/method/selector/ctor/pat-selector)
Symbol usage
Fields:
symbol—symbolobjectqualifier— qualifeir symbol used with (optional)in—module-id, where symbol usedat—region, where symbol used
Cabal package info: Fields:
name— package namesynopsis— package descriptiondefault-version— default cabal versioninstalled-versions— list of installed versionshomepage— url of homepagelicense— name of license
Unresolved symbol
Fields:
qualified— qualifiername— nameline— linecolumn— column
Source file Fields:
file— path to filecontents— optional contents of file
Note object with some additional info
Fields:
source— module location of note,locationregion— region of note,regionobjectlevel— severity of note, one oferror/warning/hintnote— additional note info
Lint / Check / etc. output message
Fields:
message— message textsuggestion— suggestion message
Refact object
Fields:
message— refact messageaction— refact action object:region— region to replacecontents— replace with
Region object
Fields:
from— start of region:line— linecolumn— column
to— end of region
Result of some interactive evaluations Object with only one field:
ok— evaluation resulterror— error message