-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Larger Vim plugin help file cannot be highlighted #5347
Comments
I don't think this is true. The |
Yes, that's correct. But it's up to user's configuration. For example, when setting the value to And also, putting modeline at line 3~5 is not good in terms of Vim's help file format. Usually table of contents is put at top of the file. Putting mode line just before the table looks weird. |
You are right. I should have said "I don't think this is not always true".
Well yes, I think so too. Anyway, it would be nice to have modeline at bottom recognized on GitHub, regardless of file size. |
🤔 This should work because we look for the modeline in the first and last five lines, regardless of file size: If this is making it though to the heuristics, it means your modeline didn't match the Vim modeline-specific regex at https://github.com/github/linguist/blob/32ec19c013a7f81ffaeead25e6e8f9668c7ed574/lib/linguist/strategy/modeline.rb#L52-L125 The modeline regex is also quite complex compared to the heuristic. Maybe it's missing something or your modeline is relying on old incorrect behaviour that is still accepted by the heuristic regex. I know @Alhadis spent a great deal of time to improve the modeline regex, with a good overview of the shortcomings, recently in #5271, so that might be a good place to start. |
Worked it out. Your modeline isn't matching on the modeline strategy because you're specifying the file type/language as Changing your modeline to "vimhelp" however does work because it now matches the language alias: ... as can be seen in my fork at https://github.com/lildude/vim-lsp/blob/master/doc/vim-lsp.txt (I'll delete this fork at some point). When you move the modeline up into the range of the heuristic limits, the heuristic matches because it explicitly looks for "help" and matches that to "Vim Help File": Scroll all the way to the right and you'll see The final solution here would probably be to add |
This was a deliberate omission on my part. Given the specificity of Vim's help format, I was a little reluctant to add an alias as generic as Also, I completely forgot about the Vim Help heuristic when preparing #5271. 🥵 That'll need to be D.R.Y-ed up. |
Describe the bug
I'm maintainer of vim-lsp. The documentation is not highlighted on GitHub although its mode line description at bottom of the file is correct.
To reproduce this, open https://github.com/prabirshrestha/vim-lsp/blob/master/doc/vim-lsp.txt in your browser and check if highlight is applied.
Expected behaviour
Highlight is applied like this
Related discussion
Today I investigated why the document is not highlighted on GitHub.
The regex for heuristic matched correctly to modeline at the bottom of the document file.
However, the document file is larger than 51200 bytes. And the heuristic detection has 51200 bytes limit on finding the regex pattern. I understood that moving the modeline to top of the document file will make the heuristic detection work, but it's not possible because the format of Vim help file does not allow it. The first line is treated as summary of the document by Vim so modeline cannot be put at the line. On the other hand, Vim's mode line must be put on the first line or the last line of the file (please see
:help modeline
for more details). After all, modeline must be put at the last line in Vim help file. It means that Vim help files larger than 51200 bytes cannot be highlighted currently.Additional notes
I think this issue is important for Vim plugin users because larger document is harder to be read and searched. Highlight would help to do them, but currently highlight is not applied due to this issue for larger documents.
The text was updated successfully, but these errors were encountered: