ExAthena.Lsp.ServerRegistry (ExAthena v0.7.1)

Copy Markdown View Source

Maps file extensions to language atoms and language atoms to LSP server spawn specifications.

Language detection

language_for_path/1 inspects the file extension and returns a language atom, or nil for unknown types.

Spawn specs

spawn_spec/1 resolves the server binary via System.find_executable/1 (injectable for tests via the optional second argument) and returns {:ok, %{binary: path, args: [...]}} or {:error, :unsupported}.

Application-env override

Set Application.put_env(:ex_athena, :lsp_servers, overrides) where overrides is a map of language_atom => %{binary: path, args: [...]} to replace or disable default servers without editing source. Overridden specs skip find_executable lookup — the binary path is used as-is.

Summary

Functions

Return the language atom for the given file path based on its extension, or nil if the extension is not recognized.

Return the spawn spec for language, resolving the binary via find_executable (defaults to System.find_executable/1).

Functions

language_for_path(path)

@spec language_for_path(Path.t()) :: atom() | nil

Return the language atom for the given file path based on its extension, or nil if the extension is not recognized.

spawn_spec(language, find_executable \\ &System.find_executable/1)

@spec spawn_spec(atom(), (String.t() -> String.t() | nil)) ::
  {:ok, %{binary: String.t(), args: [String.t()]}} | {:error, :unsupported}

Return the spawn spec for language, resolving the binary via find_executable (defaults to System.find_executable/1).

Returns {:ok, %{binary: path, args: [...]}} or {:error, :unsupported}.