Syntax Reference

Main

LanguageServer.get_line_offsetsMethod
get_line_offsets(doc::Document)

Updates the doc.lineoffsets field, an n length Array each entry of which gives the byte offset position of the start of each line. This always starts with 0 for the first line (even if empty).

source
LanguageServer.get_offsetMethod
get_offset(doc, line, char)

Returns the 0 based byte offset position corresponding to a line/character position. This takes 0 based line/char inputs. Corresponding functions are available for Position and Range arguments, the latter returning a UnitRange{Int}.

source
LanguageServer.index_atFunction
index_at(doc::TextDocument, p::Position, forgiving_mode=false)

Converts a 0-based Position that is UTF-16 encoded to a 1-based UTF-8 encoded Julia string index.

source
LanguageServer.LanguageServerInstanceType
LanguageServerInstance(pipe_in, pipe_out, env="", depot="", err_handler=nothing, symserver_store_path=nothing)

Construct an instance of the language server.

Once the instance is run, it will read JSON-RPC from pipe_out and write JSON-RPC from pipe_in according to the language server specification. For normal usage, the language server can be instantiated with LanguageServerInstance(stdin, stdout, false, "/path/to/environment").

Arguments

  • pipe_in::IO: Pipe to read JSON-RPC from.
  • pipe_out::IO: Pipe to write JSON-RPC to.
  • env::String: Path to the environment for which the language server is running. An empty string uses julia's default environment.
  • depot::String: Sets the JULIA_DEPOT_PATH where the language server looks for packages required in env.
  • err_handler::Union{Nothing,Function}: If not nothing, catch all errors and pass them to an error handler function with signature err_handler(err, bt). Mostly used for the VS Code crash reporting implementation.
  • symserver_store_path::Union{Nothing,String}: if nothing is passed, the symbol server cash is stored in a folder in the package. If an absolute path is passed, the symbol server will store the cache files in that path. The path must exist on disc before this is called.
source
Base.runMethod
run(server::LanguageServerInstance)

Run the language server.

source
LanguageServer.runserverFunction
runserver(pipe_in=stdin, pipe_out=stdout[, env_path])

Run a LanguageServerInstance reading from pipe_in and writing to pipe_out.

The same options can be passed to runserver as to LanguageServerInstance. If env_path is not specified, attempt to pick an environment by considering in order of priority:

  1. ARGS[1]: the first command-line argument passed to the invocation of julia.
  2. The Julia project containing pwd().
  3. The default Julia environment withing .julia/environments/v#.#.

Examples

The following invocation of Julia would set env_path to /home/example/repos/Example.jl:

julia --project=/path/to/LanguageServer.jl \
  -e "using LanguageServer; runserver()" \
  /home/example/repos/Example.jl

If there was a Project.toml or JuliaProject.toml in /home/example/repos/Example.jl/, the following invocation would set env_path to /home/example/repos/Example.jl/; otherwise it would be set to .julia/environments/v#.# where v#.# is the major/minor version of Julia being invoked.

julia --project=/path/to/LanguageServer.jl \
  -e "using LanguageServer; runserver()"
source

Requests

LanguageServer.is_completion_matchFunction
is_completion_match(s::AbstractString, prefix::AbstractString, cutoff=3)

Returns true if s starts with prefix or has a sufficiently high fuzzy score.

source

Protocol