Skip to content

config: use struct instead of Dict#282

Merged
aviatesk merged 4 commits intomasterfrom
abap34/config-schema
Oct 23, 2025
Merged

config: use struct instead of Dict#282
aviatesk merged 4 commits intomasterfrom
abap34/config-schema

Conversation

@abap34
Copy link
Copy Markdown
Collaborator

@abap34 abap34 commented Oct 22, 2025

Summary

This PR changes the configuration storage object from a Dict to a struct (JETLSConfig).
This enables:

  • Better compiler understanding of configuration fields, improving LS performance
  • Automatic schema generation for completion and validation

Implementation Details

A new dependency, Configurations.jl, has been introduced.
This package maps TOML-parsed Dicts to structs.
It’s relatively lightweight, so adding it as a dependency should not be a significant issue.

Since Configurations.jl does not currently provide full key paths for nested KeyErrors,
the helper function collect_unmatched_key from the previous implementation remains temporarily for error reporting.
I plan to submit a PR to Configurations.jl to support this feature, so that, this workaround can be removed.

Schema Generation

With JSONSchemaGenerator.jl,
a JSON Schema can be generated simply as follows:

StructTypes.omitempties(::Type{T}) where {T <: ConfigSection} = fieldnames(T)
JSON.json(JSONSchemaGenerator.schema(JETLSConfig), 4)

Using this approach, completion and type checking become available in various editors.
(The example below uses VSCode with even-better-toml.)

config_schema_demo_0

In the long term, it would be convenient to have the schema generated in CI at release time and registered to schemastore.org. This part is not critical for the LS itself, so we can be more liberal in using convenient tools and dependencies to improve the workflow.

I would be happy to discuss this further later on :)

Comment thread src/config.jl Outdated
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 22, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.88%. Comparing base (de2b185) to head (b7aa529).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
src/types.jl 62.50% 9 Missing ⚠️
src/formatting.jl 0.00% 4 Missing ⚠️
src/testrunner/testrunner.jl 0.00% 4 Missing ⚠️
src/config.jl 95.65% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #282      +/-   ##
==========================================
+ Coverage   70.53%   70.88%   +0.34%     
==========================================
  Files          38       38              
  Lines        3662     3647      -15     
==========================================
+ Hits         2583     2585       +2     
+ Misses       1079     1062      -17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@abap34 abap34 force-pushed the abap34/config-schema branch from 64d7eee to 2fc4281 Compare October 23, 2025 15:09
abap34 and others added 2 commits October 24, 2025 00:18
Co-Authored-By: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
@abap34 abap34 force-pushed the abap34/config-schema branch from 2fc4281 to 3667cb2 Compare October 23, 2025 15:19
@abap34 abap34 requested a review from aviatesk October 23, 2025 15:19
Comment thread src/utils/general.jl
Co-Authored-By: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com>
Comment thread src/config.jl
@aviatesk aviatesk merged commit 4c3d84b into master Oct 23, 2025
9 of 10 checks passed
@aviatesk aviatesk deleted the abap34/config-schema branch October 23, 2025 16:06
@aviatesk
Copy link
Copy Markdown
Owner

Thanks so much for working on this, @abap34

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.

2 participants