# Languages

Source: https://athas.dev/docs/languages

Set up a language for highlighting, completions, diagnostics, formatting and linting.

Language support in Athas comes in layers. Tree-sitter colors the syntax; a language server adds
completions, hover information, definitions, symbols and diagnostics; a formatter and linter
rewrite and check code. A language integration can provide any of these, and installing one does
not guarantee it provides all of them.

## Syntax highlighting

These languages are highlighted out of the box, with no integration to install: Bash, C, C#, C++,
CSS, D, Dart, Elisp, Elixir, Go, HTML, Java, JavaScript, JSON, Kotlin, Lua, Markdown, Objective-C,
OCaml, PHP, Python, ReScript, Ruby, Rust, Scala, Solidity, Swift, SystemRDL, TLA+, TOML, TSX,
TypeScript, Vue, YAML and Zig. Elm and QL use a grammar from their integration.

If a file is not colored, check the language detected for it and whether its integration is
installed and enabled. The [Integrations catalog](https://athas.dev/integrations) lists the tooling for each language.

## Set up a language server

1. Open the project root, including its build files and dependency manifests.
2. Open **Integrations**, find the language and read its installation requirements.
3. Install or enable its language tooling and any required runtime.
4. Open a source file and wait for the language server to initialize.
5. Run **LSP: Show Status** from the command palette to inspect active workspaces and errors.

Once a server is running, trigger suggestions and parameter hints from the editor or command
palette, and use hover information and definition and reference actions where the server supports
them. [Outline](https://athas.dev/docs/outline) lists the file's symbols and [Diagnostics](https://athas.dev/docs/diagnostics) its
errors and quick fixes.

Run **Language Server: Restart All Servers** after changing the environment or fixing a failed
installation; **Language Server: Stop All Servers** stops them. Java projects also have
**Java: Refresh Project** and **Java: Organize Imports**.

## Format and lint

Run **Format Document** from the command palette (`Shift+Alt+F` in the default keymap), or select
code and run **Format Selection**. A formatter may support whole documents without supporting
selected ranges. Review the result before saving.

Enable **Format on Save** and **Lint on Save** in Settings, and choose the formatter your project
expects when there is a choice. Keep the formatter's configuration in version control so
teammates and CI use the same rules. With Auto Save on, consider how often save-time tooling will
run before turning on both.

## When something is missing

- Check the language selected for the file, the integration's installed and enabled state, and
  its required runtime.
- Install your project's dependencies with its normal package manager, and open the project root
  rather than a sub-folder.
- Inspect **LSP: Show Status** and [the Athas log](https://athas.dev/docs/troubleshooting#collect-a-useful-report).
- For formatting, run **Format Document** by hand and read any error before relying on
  format on save, and check the project's formatter configuration for syntax errors or excluded
  paths.

A server can be running without supporting every action. When asking for help, include the
language, integration, server error and a small reproduction.
