neorg
neorg copied to clipboard
Regex highlighting for code blocks can fail in some situations if the syntax file only does 'hi link'
Prerequisites
- [X] I have read contribution guidelines
- [X] I am using the latest version of the plugin
- [X] I am using either 0.6 stable or the latest compiled neovim version
Neovim Version
NVIM v0.6.1
Neorg setup
{:load {:core.defaults {}
:core.norg.concealer {:config {:markup_preset :safe
}}
:core.keybinds {:config {:neorg_leader :<Leader>n}}
:core.norg.dirman {:config {:workspaces {:main "~/Documents/neorg"}
:autodetect true
:autochdir true}}
:core.gtd.base {}
:core.norg.qol.toc {}
:core.norg.journal {:config {:workspace :main
:journal_folder "journal"
:use_folders false
}}
:core.norg.completion {:config {:engine :nvim-cmp}}
}
Actual behavior
With syntax files that use the hi link groupA groupB
method instead of hi def link groupA groupB
method, whenever the regex highlight needs to update (like changing color schemes or modifying the code block), the code block will cease to highlight.
Expected behavior
This doesn't happen
Steps to reproduce
NeoVim's built in Scala syntax file uses hi link
format. Simply add an example block like below and change color scheme and the highlighting should go away:
object Hello {
def main(args: Array[String]) = {
println("Hello, world")
}
}
Potentially conflicting plugins
No response
Other information
No response
Help
Yes
Implementation help
I'm mostly making this issue to remind myself since I'm the one that implemented this, but if anyone else wants to take a stab at it go ahead
Took some time to look through this, and honestly I can't come up with a solution. The hi link
format for linking highlight groups behaves in a way that simply defeats the performance improvements I built into this feature. In order to fix this issue, I would have to remove them which would essentially lead to importing syntax files on every function schedule
Hm yeah this seems to be a problem. I couldn't find any real way to do it either without breakages. I believe we'll just have to live with this and hope that treesitter starts prevailing slowly but surely.
I wish I had the time but I'd love for someone to just go on a language adding spree and add as many languages as they can to nvim-treesitter so we no longer have to worry about regex so much :P
NeoVim and out-of-spec syntax file issue. This issue can be closed if either of the following are met:
- NeoVim overhauls the syntax system, allowing the true removal of syntax groups like
syntax reset
achieves - Syntax files that falsely use
highlight link syntaxGroup sourceGroup
are rewritten to usehighlight default syntaxGroup sourceGroup
. The latter method allows these groups to fall back when a "reset" happens