Skip to content

make syntax highlighting colors configurable - #37

Open
mvanhorn wants to merge 1 commit into
elixir-dbvisor:mainfrom
mvanhorn:fix/26-configurable-syntax-colors
Open

mvanhorn wants to merge 1 commit into
elixir-dbvisor:mainfrom
mvanhorn:fix/26-configurable-syntax-colors

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 4, 2026

Copy link
Copy Markdown

SQL.Format.syntax_color/1 reads :syntax_colors from the :sql application environment and turns a color name, or a list of them, into an ANSI fragment with IO.ANSI.format_fragment. Formatted SQL and the compile-time warnings that quote it always highlight keywords, literals, enclosed quotes, and errors with the same ANSI colors.

Tests for this live in test/syntax_colors_test.exs.

Closes #26

@Schultzer

Copy link
Copy Markdown
Member

@mvanhorn thanks for this PR, I think we can simplify this by using Application.get_compile_env in the module attributes instead of introduce new public functions.

Are you currently using this library?

@mvanhorn

mvanhorn commented Oct 5, 2026

Copy link
Copy Markdown
Author

Updated in 5fc9f84: syntax colors are now read with Application.compile_env in module attributes, and the public helper is gone. Defaults are unchanged, and the tests and README now describe the compile-time configuration. The full test suite passes locally.

To answer your question: no, I'm not using the library myself. I picked up #26 to contribute. If compile-time configuration isn't the direction you want, I'm happy to close this.

@Schultzer Schultzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we're almost there. I imagine this feature to be around 13 lines of additions.

Also @mvanhorn can you tell me how you work now a days, obvisouly there is an agent behind this, but I'm not sure if there is a human in this loop.

Comment thread lib/format.ex Resolved
Comment thread lib/format.ex Resolved
Comment thread lib/inspect.ex Resolved
Comment thread test/syntax_colors_test.exs Resolved
Comment thread README.md Resolved
@Schultzer

Schultzer commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

@mvanhorn please do me a favor and just amend the first commit in this PR with all the changes, no need for multiple commits for this feature.

@mvanhorn
mvanhorn force-pushed the fix/26-configurable-syntax-colors branch from e1e54f3 to e260f74 Compare October 6, 2026 17:19
@mvanhorn

mvanhorn commented Oct 6, 2026

Copy link
Copy Markdown
Author

@Schultzer Updated and squashed into the first commit, so the PR is now a single commit.

  • lib/format.ex and lib/inspect.ex use your compile_env suggestions in place (balanced parens), and reset is no longer configurable
  • the hunk at format.ex:78 is back to what it was
  • removed test/syntax_colors_test.exs
  • trimmed the README section to the config example and dropped the last paragraph

The code change is 5 lines now; with the README and CHANGELOG it's 22 additions. mix compile --warnings-as-errors and mix test are clean (397 tests).

On how I work: I use AI coding agents to draft the changes and the replies, and I review and approve every commit and comment before it goes out, including this one. If you'd rather work with me differently on this PR, happy to adjust.

@Schultzer

Copy link
Copy Markdown
Member

@Schultzer Updated and squashed into the first commit, so the PR is now a single commit.

  • lib/format.ex and lib/inspect.ex use your compile_env suggestions in place (balanced parens), and reset is no longer configurable
  • the hunk at format.ex:78 is back to what it was
  • removed test/syntax_colors_test.exs
  • trimmed the README section to the config example and dropped the last paragraph

The code change is 5 lines now; with the README and CHANGELOG it's 22 additions. mix compile --warnings-as-errors and mix test are clean (397 tests).

On how I work: I use AI coding agents to draft the changes and the replies, and I review and approve every commit and comment before it goes out, including this one. If you'd rather work with me differently on this PR, happy to adjust.

Thanks, just a rebase and we should be good to merge this.

Read the keyword, literal, enclosed, and error colors from
config :sql, :syntax_colors with Application.compile_env, falling back
to the current IO.ANSI defaults. The reset sequence stays fixed.

Fixes elixir-dbvisor#26

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019wSaUMZrtm6XSzwEcxavkv
@mvanhorn
mvanhorn force-pushed the fix/26-configurable-syntax-colors branch from e260f74 to 3c23785 Compare October 7, 2026 23:31
@mvanhorn

mvanhorn commented Oct 7, 2026

Copy link
Copy Markdown
Author

Rebased on main (3c23785). The only conflict was CHANGELOG.md, so the entry now sits under a new Unreleased section above v0.6.0. mix test passes locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make syntax highlighting configurable

2 participants