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
timeout
value (default is0
for 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
result
object, which contents depends on command - Error — have string
error
field anddetails
object with detailed error information - Notification — have
notify
object 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
,fatal
Response:{}
Command: set-log
Args:
level
— log level to set, one oftrace
,debug
,info
,warning
,error
,fatal
Response:{}
Scan sources and installed modules
Command: scan
Args:
projects
— list of projects paths or.cabal
filescabal
— scan global and user package-db (true
orfalse
)sandboxes
— list ofsandbox path
s, where path may be one of:<path>/.cabal-sandbox
— cabal sandbox<path>/.stack-work
— stack sandbox
files
— list ofsource-file
objects to scanbuild-tool
— preferred build tool when scanning projects,cabal
orstack
paths
— 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,cabal
orstack
scan-deps
— also scan dependent package-dbs Response:{}
Scan file
Command scan file
Args:
file
— file pathbuild-tool
— build tool to use,cabal
orstack
scan-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-db
s in reverse order, i.e.global-db
should 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.cabal
files or names to removecabal
— remove global-db and user-dbsandboxes
— list ofsandbox
objects 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
—query
object: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
) orsymbol
objects
Get modules info
Command: module
Args:
query
—query
objectfilters
— list offilter
objectsheader
— return only module header — name and locationinspection
— include inspection data Response: list ofmodule-id
(ifheader
) ormodule
objects
Get project info
Command: project
Args:
name
— name of projectpath
— path to.cabal
Response:project
object
Get sandboxes info
Command: sandbox
Args:
path
— path to search sandbox in Response: list ofsandbox
object
Lookup for symbol, this ignores imports and search in projects dependencies
Command: lookup
Args:
name
— name of symbolfile
— context file Response: list ofsymbol
objects
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 ofsymbol
objects
Get info about symbol under cursor
Command: whoat
Args:
line
— line numbercolumn
— column numberfile
— file name Response: list ofsymbol
objects
Resolve modules in scope of file (which can be imported)
Command: scope modules
Args:
query
—query
objectfile
— context file Response: list ofmodule-id
objects
Resolve declarations in scope of file
Command: scope
Args:
query
—query
objectfile
— context file Response: list ofsymbol-id
objects
Find usages of symbol
Command: usages
Args:
line
— line numbercolumn
— column numberfile
— file name Response: list ofsymbol-usage
objects
Get completions
Command: complete
Args:
prefix
— input prefixwide
— wide completions, ignores importsfile
— context file Response: list ofsymbol
objects
Search in hayoo
Command: hayoo
Args:
query
— hayoo querypage
(default is0
) — start pagepages
(default is1
) — number of pages Response: list ofsymbol
objects
Cabal list
Command: cabal list
Args:
packages
— packages to list Response: list ofcabal-package
objects
List all unresolved symbols in source file
Command: unresolveds
Args:
files
— list of files Response: list ofunresolved-symbol
objects
Lint/check source, infer types
Command: lint
/check
/check-lint
/types
Args:
files
— list ofsource-file
objectsghc-opts
— list of additional ghc options (not applied forlint
command)lint-opts
— list of hlint optionsclear
(exceptlint
) — set to clear targets before running command Response: list ofnote output-message
objects
Show suggestions
Command: autofixes
Args:
messages
— list ofnote output-message
objects, which returned bylint
/check
/check-lint
commands Response: list ofnote refact
objects
Apply some suggestions and return updated locations of rest suggestions
Command: refactor
Args:
messages
— list ofnote refact
objects to applyrest
— list ofnote refact
objects to update locationspure
— just update locations, don't actually modify file, useful when some editor applies suggestions itself Response: list ofnote refact
objects 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 refact
objects
Evaluate expression
Command: ghc eval
Args:
exprs
— list of expressionsfile
— optionalfile-source
context Response: list ofrepl-result
objects
Get type of expression
Command: ghc type
Args:
exprs
— list of expressionsfile
— optionalfile-source
context Response: list ofrepl-result
objects
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-info
object
executables
— executable descriptions, list of objects:name
— executable namepath
— path to executableinfo
— executablebuild-info
object
tests
— tests descriptions, list of objects:name
— test nameenabled
— is enabledmain
— main moduleinfo
— testbuild-info
object
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-id
object
Module info
Fields:
id
—module-id
docs
— module docsexports
— exports, list ofsymbol
sfixities
— list of fixities objects:assoc
— associativity, one ofnone
,left
orright
prior
— priorityname
— name of operator
Symbol info
Fields:
id
—symbol-id
docs
— 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
—symbol
objectqualifier
— 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,location
region
— region of note,region
objectlevel
— severity of note, one oferror
/warning
/hint
note
— 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