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

Syntax highlighting broken by Vim 8.2.1703 #6

Open
kempniu opened this issue May 20, 2021 · 16 comments
Open

Syntax highlighting broken by Vim 8.2.1703 #6

kempniu opened this issue May 20, 2021 · 16 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@kempniu
Copy link

kempniu commented May 20, 2021

Hi there!

For some reason, a certain Vim commit (revision 8.2.1703) back from September 2020 prevents this syntax highlighting module from working - the filetype is set to bind-named for a named.conf file as it should be, but no syntax highlighting takes place. Unfortunately, I do not have any specific hints for fixing things, sorry :(

All I can say is that after I manually reverted the aforementioned change on top of Vim 8.2.2859 sources, this syntax highlighting module immediately started working again.

Please let me know if I can help with any further debugging and/or testing.

Thanks!

@adscriven
Copy link

adscriven commented Apr 13, 2022

@kempniu Is this still an issue? If you are able to produce a minimal working example of the problem I'd be interested to take a look.

As the author of 8.2.1703 I would say that though the code is simple, a whole bunch of us spent a great deal of time considering the impact of this change on different Vim configurations, and the effect on backwards-compatibility. It really wasn't trivial. The upshot is that the patch likely fixes a long-standing colorscheme problem for 99% of Vim users, but can't be fully backwards-compatible in every single case. Sorry, but maybe you've hit upon one of those cases.

But if you can produce a minimal code example that demonstrates the problem you are having, and if it's possible for me to refine the patch to take that into account, I would love to do that.

Kind regards, --Antony

@kempniu
Copy link
Author

kempniu commented Apr 14, 2022

@adscriven Thank you for reaching out! Yes, this issue still affects my environment: with Vim 8.2.4747 and the current master branch of this repository, the filetype is set to bind-named for my named.conf files, but the default console color is used for all their contents. hilinks confirms that the syntax stack changes as I move the cursor around in named.conf files.

If by "a minimal working example of the problem" you mean a minimal syntax file triggering this problem (like a heavily stripped down version of bind-named.vim), then I am afraid I have no idea how to prepare it, we would need @egberts here. If I can help in some other way, I am all ears.

For completeness, I am linking the current patch I am using against Vim 8.2.4747 to revert 8.2.1703. This makes the problem go away, i.e. named.conf syntax highlighting using this project works for me again.

@egberts
Copy link
Owner

egberts commented Apr 14, 2022

Interesting. I have not push ahead with the latest VIM (due to many other projects).

@kempniu , can you pare down the named.conf to just

options { };

and see how the latest Vim fared?

Sidenote: You may have to fill in a few missing options statement based on its version of Bind9.

@kempniu
Copy link
Author

kempniu commented Apr 14, 2022

Sure! Let me know if you have any further instructions or requests I can help with.


Vim 8.2.4747 (vanilla)

unpatched


Vim 8.2.4747 with 8.2.1703 reverted

patched

@egberts
Copy link
Owner

egberts commented Apr 14, 2022

Ooooooooooh, That is nasty. This means that the Vim aliasing of highlights has gone awry.

Might take a bit of bisecting of the syntax/bind-named.vim with regard to eliminating the nesting of "hi link": such as eliminating the middle aliases between actual name and Vim-offered highlight keyname; namedStmtKeyword => namedHL_Statement => Type

@egberts
Copy link
Owner

egberts commented Apr 14, 2022

Try this one-line change in hope to be eliminating the highlight aliases bug for the following line in $HOME/.vim/syntax/bind-named.vim:

    hi link namedStmtKeyword namedHL_Statement

with

    hi link namedStmtKeyword Type

in

hi link namedStmtKeyword namedHL_Statement

And restart Vim session then let us know if the colorization of options { }; is back or not.

@kempniu
Copy link
Author

kempniu commented Apr 15, 2022

The change above did not cause the colorization of options { }; to work again in unmodified Vim 8.2.4747. Here is the diff for the record:

diff --git a/.vim/syntax/bind-named.vim b/.vim/syntax/bind-named.vim
index 5c5fc8b..2c9f865 100644
--- a/.vim/syntax/bind-named.vim
+++ b/.vim/syntax/bind-named.vim
@@ -6707,7 +6707,7 @@ syn match namedStmt_ZoneNameIdentifier contained /\S\{1,63}/
 " Top-level statment (formerly clause) keywords
 " 'uncontained' statements are the ones used GLOBALLY
 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
-hi link namedStmtKeyword namedHL_Statement
+hi link namedStmtKeyword Type
 syn match namedStmtKeyword /\_^\s*\<acl\>/ 
 \ skipwhite skipnl skipempty
 \ nextgroup=

I am certain that the change was applied correctly because it changed the highlight color for the options statement in the Vim build containing the revert of 8.2.1703.

@egberts
Copy link
Owner

egberts commented Apr 16, 2022

I got this.

@egberts egberts self-assigned this Apr 16, 2022
@egberts egberts added the good first issue Good for newcomers label Apr 16, 2022
@egberts
Copy link
Owner

egberts commented Apr 16, 2022

Out of curiosity, did ANYTHING get colorized in this unit test text-file?

example-9.18-named.conf

@kempniu
Copy link
Author

kempniu commented Apr 17, 2022

AFAICT, no.

@kempniu
Copy link
Author

kempniu commented Oct 5, 2022

I feel silly for only coming up with this idea now, but I think I got closer to getting the bottom of this issue by stripping my local Vim environment (~/.vim/, ~/.vimrc) down to the bare basics. Specifically, I ran some experiments in a home directory which contains only the files provided by this repository in ~/.vim/ (specifically in its ftdetect and syntax subdirectories) and no .vimrc file at all. Here is what I figured out.

It seems that this syntax plugin has some issue with adjusting to a new color scheme when that gets set. Here are some screenshots to help explain this. (All of the tests below were carried out using Vim 9.0.0354 installed from an Arch Linux package.)


First, to demonstrate proper behavior, let's open a sample Python script in Vim with only the default settings in effect:

python-default

(Syntax highlighting is enabled by default in the Vim package I used.)

Now, let's execute the :colorscheme desert command to change the color scheme:

python-desert

This works as expected.


Let's now open a sample BIND 9 configuration file (the one you provided above) with a ~/.vim/ directory only containing the files provided by this repository and no ~/.vimrc file again:

bind-default

This looks fine. Now, let's execute the :colorscheme desert command:

bind-desert

This does NOT work as expected. It seems that all syntax highlighting is gone.

...or maybe it does work as expected and it's just my expectations that are off? :-)


Anyway, dropping colorscheme solarized from my original ~/.vimrc file seems to have enabled this syntax plugin to work again. Hope this helps!

@egberts
Copy link
Owner

egberts commented Oct 6, 2022

Thats a great narrow down of the problem.

@adscriven
Copy link

adscriven commented Oct 17, 2022 via email

@adscriven
Copy link

basically syntax files should always "hi def link"
looking at the obvious places in the docs this doesn't seem explicit, and the docs would probably benefit from an update
my guess why this hasn't been a bigger issue is because people tend to copy, paste, modify to make syntax files

@bnilz
Copy link

bnilz commented Dec 18, 2022

I am layman to linux/vim and have the same problem on a fresh installation of ubuntu 22.04 with vim 8.2.4919 (shown on startup of vim, or 8.2.3995 in ubuntu softwre)
tried upgrading to 9.0 but still didn't show correct syntax highlighting (there is only one color for the text).
any suggestion how to fix it (at least temporarily)? or there is something else wrong? don't know how to revert to an older version (failed to install vim 8.1 due to missing dependencies).

@egberts
Copy link
Owner

egberts commented Jan 17, 2023

So, should we be doing the def in the hi def link XXX YYY?

hi link namedHL_Statement Keyword

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants