Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

# Changelog

## Unreleased

### Enhancement
- Syntax highlighting colors are configurable with `config :sql, :syntax_colors`.

## v0.6.0 (2026-10-06)

### Enhancement
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ end
[%User{id: 1, email: "john@example.com"}, %User{id: 2, email: "jane@example.com"}]
```

## Syntax highlighting

Override keyword, literal, enclosed, and error colors in `config.exs`:

```elixir
config :sql, :syntax_colors,
keyword: IO.ANSI.magenta(),
literal: IO.ANSI.yellow(),
enclosed: IO.ANSI.green(),
error: IO.ANSI.red()
```

## Compile time warning
Run `mix sql.get` to generate your `sql.lock` file for error reporting.

Expand Down
8 changes: 4 additions & 4 deletions lib/format.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ defmodule SQL.Format do
@moduledoc false
@moduledoc since: "0.4.0"

@error IO.ANSI.red()
@error Application.compile_env(:sql, [:syntax_colors, :error], IO.ANSI.red())
@reset IO.ANSI.reset()
@keyword IO.ANSI.magenta()
@literal IO.ANSI.yellow()
@enclosed IO.ANSI.green()
@keyword Application.compile_env(:sql, [:syntax_colors, :keyword], IO.ANSI.magenta())
@literal Application.compile_env(:sql, [:syntax_colors, :literal], IO.ANSI.yellow())
@enclosed Application.compile_env(:sql, [:syntax_colors, :enclosed], IO.ANSI.green())

@compile {:inline, indention: 3, newline: 2, pad: 1, keyword: 2, color: 3}

Expand Down
2 changes: 1 addition & 1 deletion lib/inspect.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
defmodule SQL.Inspect do
@moduledoc false

@error IO.ANSI.red()
@error Application.compile_env(:sql, [:syntax_colors, :error], IO.ANSI.red())
@reset IO.ANSI.reset()

defimpl Inspect, for: SQL do
Expand Down