Composer.LSP (composer v0.2.0)

Copy Markdown View Source

composer-ls, the language server for recipe group files, started by mix composer.lsp. See the Composer LSP guide.

The server runs beside the Elixir language server and handles recipe references only: diagnostics on open and save (in the saved file and the files that include it), hover, goto-definition, document links for hex: refs, completion and quick fixes. It is a thin adapter over Composer.Lint, Composer.Recipe.Locator and Composer.Resolver.

The host project is the working directory the editor starts the server in. GenLSP is an optional dependency: only Composer.LSP.Server uses it, and everything else here compiles without it.

Startup

Before anything owns stdio, the project is compiled and its cookbooks discovered with a quiet Mix shell. Then the Mix shell stays quiet, Logger writes to stderr, and the server is started with stdout reserved for protocol messages (Composer.LSP.Server.run/1). The call blocks.

Summary

Functions

True when GenLSP, and so the server, is available.

The code cookbooks, without local: the language server builds local from its directory, as mix composer.cookbook.lint --file does.

The completion entries of cookbooks.

Recompiles the project, as IEx.Helpers.recompile/0 does, and rediscovers its cookbooks. Returns {:error, message} on failure.

Starts the language server on stdio and blocks.

Functions

available?()

@spec available?() :: boolean()

True when GenLSP, and so the server, is available.

discover()

@spec discover() :: {:ok, [Composer.Cookbook.t()]} | {:error, term()}

The code cookbooks, without local: the language server builds local from its directory, as mix composer.cookbook.lint --file does.

entries(cookbooks)

@spec entries([Composer.Cookbook.t()]) :: [{String.t(), String.t(), String.t() | nil}]

The completion entries of cookbooks.

reload_cookbooks()

@spec reload_cookbooks() :: {:ok, [Composer.Cookbook.t()]} | {:error, String.t()}

Recompiles the project, as IEx.Helpers.recompile/0 does, and rediscovers its cookbooks. Returns {:error, message} on failure.

start(opts \\ [])

@spec start(keyword()) :: no_return()

Starts the language server on stdio and blocks.