Skip to content

Add support for the schema tag #22

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

eloyesp
Copy link

@eloyesp eloyesp commented Nov 9, 2021

Implement the changes from #16 to have syntax highlighting on section schema.

@tpope
Copy link
Owner

tpope commented Nov 10, 2021

Been on the fence about this proprietary extension but I guess it's been requested enough that I'll go for it. Let's rename the group to @liquidJson.

@eloyesp
Copy link
Author

eloyesp commented Nov 10, 2021 via email

@tpope
Copy link
Owner

tpope commented Nov 10, 2021

Wrap those in a if b:liquid_subtype ==# 'html' and it's probably fine, as CSS and JavaScript syntax highlighting already gets indirectly loaded in that case anyways. Are they also Shopify specific?

@eloyesp
Copy link
Author

eloyesp commented Nov 23, 2021

Just wanted to note that I've not forgot about this, but have problems finding the time... will work on this ASAP :)

@eloyesp
Copy link
Author

eloyesp commented Nov 27, 2021

Ok it is working.

I were trying to make matchit work, but it seems that I'm missing something, it does work with if, for, etc, but not with capture or style or schema.

Also, the indentation of JSON or CSS sections does not work and could not make it work as expected (using =).

@tpope
Copy link
Owner

tpope commented Nov 28, 2021

Is this what you're missing?

let b:match_words .= '\<\%(if\w*\|unless\|case\)\>:\<\%(elsif\|else\|when\)\>:\<end\%(if\w*\|unless\|case\)\>,\<\%(for\|tablerow\)\>:\%({%\s*\)\@<=empty\>:\<end\%(for\|tablerow\)\>,<\(capture\|comment\|highlight\)\>:\<end\1\>'

@eloyesp
Copy link
Author

eloyesp commented Nov 28, 2021 via email

@tpope
Copy link
Owner

tpope commented Nov 28, 2021

Looks like a \ was missing. I fixed it.

@@ -73,6 +73,15 @@ syn region liquidExpression matchgroup=liquidDelimiter start="{{-\=" end="-\=}}
syn region liquidComment matchgroup=liquidDelimiter start="{%-\=\s*comment\s*-\=%}" end="{%-\=\s*endcomment\s*-\=%}" contains=liquidTodo,@Spell containedin=ALLBUT,@liquidExempt keepend
syn region liquidRaw matchgroup=liquidDelimiter start="{%-\=\s*raw\s*-\=%}" end="{%-\=\s*endraw\s*-\=%}" contains=TOP,@liquidExempt containedin=ALLBUT,@liquidExempt keepend

if b:liquid_subtype ==# 'html'
Copy link
Owner

Choose a reason for hiding this comment

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

This variable is not guaranteed to be defined. Use if get(b:, 'liquid_subtype', 'html') ==# 'html'.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I've added a exists('b:liquid_subtype') check instead mainly because it is already on the code (but also because it's easier to understand). I can correct if it is wrong.

Copy link
Owner

Choose a reason for hiding this comment

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

That's a behavior change: My version is true when b:liquid_subtype is undefined and yours is false. But I think your behavior is probably the more sensible one? Leave what you have for now.

Use a single file-pattern to match multiple folders.
@eloyesp eloyesp force-pushed the patch-1 branch 2 times, most recently from 93e8f4c to aa0efe1 Compare November 29, 2021 02:31
@tpope
Copy link
Owner

tpope commented Nov 30, 2021

I think keywords like schema should be highlighted. This can be implemented the same way as highlight, although untangling how that works might take a bit of doing thanks to the use of :execute.

(Notably, raw and comment are not currently highlighted. I believe my rationale was that these commands don't actually "do" anything, which is a dubious justification and was probably a mistake.)

@eloyesp
Copy link
Author

eloyesp commented Dec 1, 2021

I could not make the schema, endschema, style and endstyle keywords to be highlighted as liquidKeywords, using matchgroup makes the highlight use a single color for the {%- and for the keyword itself, and I cannot make the region skip the start and end itself. Using offsets and crazy patterns should do the trick, but I could not make it work.

Any help is appreciated, I've been fighting with this a lot.

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