Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Multi-Language highlighting #70

Open
b-per opened this issue Apr 4, 2024 · 5 comments
Open

Support Multi-Language highlighting #70

b-per opened this issue Apr 4, 2024 · 5 comments

Comments

@b-per
Copy link

b-per commented Apr 4, 2024

Is your feature request related to a problem? Please describe.
In my day to day, I write a lot of dbt code which leverages a lot of jinja-sql (e.g. Jinja syntax in conjunction with SQL).

freeze can highlight those either as SQL or Jinja, but not as both (the Jinja code as Jinja and the SQL code as SQL, at the same time)

Describe the solution you'd like
It looks like chroma supports this type of multi-language highlighting already, when we define both a language and a root.

freeze could be updated to add an argument for a second language, or like the Jinja VSCode extension does, provide new languages, like jinja-sql

Describe alternatives you've considered
Not getting both languages highlighting and doing screenshots in VSCode

Additional context
N/A

@bashbunni
Copy link
Member

That would be an awesome improvement to the tool. Thanks for the suggestion!
@Delta456 expressed interest in working on this, so will let him take a stab at solving this 🧑‍🍳

@Delta456
Copy link

Delta456 commented Apr 4, 2024

As @bashbunni said, I will be working on implementing this.

@Delta456
Copy link

Hey @b-per! Can you share code examples used with freeze? It would help to understand the issue better.

@b-per
Copy link
Author

b-per commented Apr 15, 2024

Here is an example of code that combines SQL and Jinja. In the "dbt" world, it would be saved as .sql file.

{{
    config(
        materialized='incremental'
    )
}}

select
    *
    cola,
    colb,
    colc,
    my_slow_function(my_column)

from {{ ref('app_data_events') }}

{% if is_incremental() %}

  where event_time >= (select max(event_time) from {{ this }})

{% endif %}

In VSCode, I can get it formatted as:

  • SQL
    image

  • Jinja
    image

  • or Jinja-SQL
    image

Ideally, freeze would allow Jinja-SQL as well

@Delta456
Copy link

My current implementation highlights the code like this:

Running: ./freeze --language jinja,sql file.sql

freeze

I believe this is the ideal behaviour.

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

No branches or pull requests

3 participants