Open BitInByte opened 1 year ago
Hmmm...I've seen this issue before, but it was fixed a while ago. The problem before was related to when the filetype got set; if it was set during another autocmd then the FileType autocmd wouldn't be processed the same and syntax highlighting wouldn't kick in.
The fact that it breaks sometimes when you <C-c>
out of oil is extremely weird because at that point we're not even entering a new buffer, we're just switching back to a previously visible buffer.
I tried out the config you provided, but I haven't been able to get the issue to reproduce. Do you have any ideas what specific situations might cause it to happen?
Have been testing and debugging as well but it’s a bit strange. It seems to be random files but the files that previously failed the highlight have a big chance to not show the highlight anymore on following neovim sessions. It’s really strange
It looks like you are using treesitter for syntax highlighting, correct? I've tried looking around for other clues on what could cause the syntax highlighting to be cleared, and I found this thread which looks similar but seems like the issue may have been a timeout with the typescript regex syntax highlighting. Do you see anything in :messages
when this happens?
I read up more on treesitter highlighting and I don't see any obvious way for this to happen. If you manage to get a more solid repro let me know, otherwise I don't think there's much I can do.
There's nothing on :messages
unfortunately. Do you think that this typescript timeout can also be triggering on lua highlighting? Because, the image that I used on the example is lua.
It's so strange this because, I really love this plugin but it get's me really annoyed since I don't have highlighting in there :(
Update: Now, in another file that doesn't have the correct highlight, I have found this error which is from Comment.nvim but seems that is caused by oil:
Update: Looks like I may have found the reason. Inside of my plugin, at directory, after/plugin/functions.lua:
I have a mkview
as you can see:
If I comment out this autocmd
it works just fine.
Interesting. I still don't know how that could cause the highlighting issue, and I still wasn't able to repro the issue. Some things you could try:
vim.schedule
mkview
/loadview
if vim.bo.buftype == ""
<C-c>
behavior for oil just calls oil.close()
. The source for that is here
https://github.com/stevearc/oil.nvim/blob/4088efb8ff664b6f1624aab5dac6c3fe11d3962c/lua/oil/init.lua#L396-L402You could try to get a minimal repro using those autocmds, winsaveview, winrestview, and buffer switching. If you can get that minimal repro, it's probably something we can file as an issue upstream
I've run into this issue specifically when working with norg files. A simple :e
fixes the problem.
I was curious, so I commented out the ft = "norg"
line in my neorg config (using Lazy as my package manager) and now the highlighting works as expected upon opening a file. I'm not smart enough to further explain this, but hopefully it provides some understanding to those who are.
For me, the reason was really the event to read and store the folds that I have (views) that was breaking it. I had problems in the past with this thing but in the last year, I haven't any problem. I love to always keep the foldings and cursor position but to use oil.nvim, I can't have this event so I just disabled.
I wanted to investigate further but, haven't had time to do it yet but most probably, if there's an error on an event, since some are silence, oil.nvim just breaks highlight for some reason, that's my opinion as far as I investigated it.
If anyone can get a repro that would be super helpful, but in the meantime you could also try out the change in #214. That PR is intending to fix behavior on Windows, but it also changes how oil opens files in general so there's a chance that it will have some effect on this bug.
@stevearc don't know if will be useful or not but, I was trying to find out why sometimes loadview
breaks the highlight and I found this issue on telescope: https://github.com/nvim-telescope/telescope.nvim/issues/559 seems to be a bit similar with what happens with oil but they still have the issue open.
Most of the people just use :e
as a quick workaround but seems to be a more complex issue.
Did you check the docs and existing issues?
Neovim version (nvim -v)
0.9.4
Operating system/version
MacOS Sonoma 14.0
Describe the bug
Hello, first of all, Thank you so much @stevearc, this file explorer was the plugin that I really needed to manage all of my files and directories in a project.
I'm just experiencing a strange bug. Sometimes, when I open a file, the highlights are just broke.
I can't really get a pattern out of here, it's seems to be random on the files that that happens.
I also found out that, sometimes, when I open the file with some other plugin, or even manually with
:e
for example and the highlights work well, if I open oil and I hit<C-c>
to close oil, it breaks the highlights again.I use treesitter to manage the highlights.
Using neotree or telescope it works and always worked correctly but somehow, oil is not on this aspect and it's maybe the last piece of the cake to use this plugin on 90% of the times.
Gonna also be talking about this plugin on an upcoming YouTube video as well for all of the amazing work you did :D
Steps To Reproduce
Expected Behavior
This is how it shows the file whenever it's opened with either neotree or telescope.
Directory structure
No response
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.