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

fix interpretation of TOP in syn included file #8104

Closed
wants to merge 2 commits into from

Conversation

tomtomjhj
Copy link
Contributor

When running syn include @NAME FILE, the TOP in the sourced FILE
should be interpreted as @NAME, not the TOP of the caller.

For example, consider markdown fenced code block containing C code. To
highlight the C code in the block, we would write something like this in
syntax/markdown.vim:

syn include @FENCED_C syntax/c.vim
syn region start="```c" end="```" contains=@FENCED_C

In this case, this line in $VIMRUNTIME/syntax/c.vim

syn region cCppOutElse ... contains=TOP,...

should be should be interpreted as

syn region cCppOutElse ... contains=@FENCED_C,...

because we want cCppOutElse to contain the TOP of C syntax, not the
TOP of markdown syntax.

When running `syn include @name FILE`, the `TOP` in the sourced `FILE`
should be interpreted as `@NAME`, not the `TOP` of the caller.

For example, consider markdown fenced code block containing C code. To
highlight the C code in the block, we would write something like this in
syntax/markdown.vim:

    syn include @FENCED_C syntax/c.vim
    syn region start="```c" end="```" contains=@FENCED_C

In this case, this line in $VIMRUNTIME/syntax/c.vim

    syn region cCppOutElse ... contains=TOP,...

should be should be interpreted as

    syn region cCppOutElse ... contains=@FENCED_C,...

because we want `cCppOutElse` to contain the `TOP` of C syntax, not the
`TOP` of markdown syntax.
@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #8104 (4ad84b3) into master (f6a8d42) will decrease coverage by 0.43%.
The diff coverage is 80.00%.

❗ Current head 4ad84b3 differs from pull request most recent head efbe78e. Consider uploading reports for the commit efbe78e to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8104      +/-   ##
==========================================
- Coverage   89.34%   88.90%   -0.44%     
==========================================
  Files         148      144       -4     
  Lines      166205   164947    -1258     
==========================================
- Hits       148488   146647    -1841     
- Misses      17717    18300     +583     
Flag Coverage Δ
huge-clang-none 87.96% <ø> (-0.59%) ⬇️
huge-gcc-none 88.78% <80.00%> (-0.01%) ⬇️
huge-gcc-testgui ?
huge-gcc-unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/syntax.c 86.55% <80.00%> (-0.42%) ⬇️
src/gui_gtk_x11.c 56.77% <0.00%> (-6.05%) ⬇️
src/ui.c 77.38% <0.00%> (-4.49%) ⬇️
src/highlight.c 86.63% <0.00%> (-3.83%) ⬇️
src/gui_gtk.c 27.86% <0.00%> (-3.24%) ⬇️
src/gui.c 59.53% <0.00%> (-2.77%) ⬇️
src/buffer.c 89.78% <0.00%> (-2.41%) ⬇️
src/gui_xim.c 22.00% <0.00%> (-1.75%) ⬇️
src/hardcopy.c 86.15% <0.00%> (-1.62%) ⬇️
src/time.c 93.45% <0.00%> (-1.55%) ⬇️
... and 70 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6a8d42...efbe78e. Read the comment docs.

@brammool
Copy link
Contributor

You have examples, so perhaps you can turn them into a test?

@tomtomjhj tomtomjhj force-pushed the syn-include-TOP branch 2 times, most recently from c40649f to 7d9b812 Compare April 14, 2021 07:25
@brammool brammool closed this in 2e240bd Apr 14, 2021
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 14, 2021
Problem:    Using "syn include" does not work properly.
Solution:   Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung,
            closes vim/vim#8104)
vim/vim@2e240bd

Cherry-pick AssertHighlightGroups from patch v8.2.2068.
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 14, 2021
Problem:    Using "syn include" does not work properly.
Solution:   Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung,
            closes vim/vim#8104)
vim/vim@2e240bd

Cherry-pick AssertHighlightGroups from patch v8.2.2068.
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 15, 2021
Problem:    Using "syn include" does not work properly.
Solution:   Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung,
            closes vim/vim#8104)
vim/vim@2e240bd

Cherry-pick AssertHighlightGroups from patch v8.2.2068.
janlazo added a commit to janlazo/neovim that referenced this pull request Apr 15, 2021
Problem:    Using "syn include" does not work properly.
Solution:   Don't add current_syn_inc_tag to topgrp. (Jaehwang Jerry Jung,
            closes vim/vim#8104)
vim/vim@2e240bd

Cherry-pick AssertHighlightGroups from patch v8.2.2068.
@tomtomjhj tomtomjhj deleted the syn-include-TOP branch April 27, 2024 08:19
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