folke/lsp-colors.nvim

not kicking in when the colorscheme set by autocmd

Closed this issue ยท 15 comments

hi,

first able, this is wonderful, will allow me to use ariake colorscheme...but I have an issue.

I change colorschemes depending on the file I'm editing:

augroup colors
    au!
    autocmd BufEnter * colorscheme space-nvim | set background=light
    autocmd BufEnter *.py colorscheme ariake | set background=light
augroup END

When I open a python file, the diagnostics are not shown properly. If I just do this (being already in ariake):

:colorscheme ariake

then suddenly it works. Chanign to something else and coming back to ariake also works. I verified if I just set airake in my init.vim and remove the per filetype stuff the plugin works normally.

I'm in master as of today.
thanks!

folke commented

Thanks for letting me know.
If I understand correctly, this happens when opening a file in trouble that was not previously opened? And for those files, after hitting <cr>, the colorscheme autocmd is not triggered?

For the preview, it shouldn't, but when opening the file to edit, it should trigger the command.

sorry maybe I wasn't clear enough...repro is like this:

inti.vim:

augroup colors
    au!
    autocmd BufEnter * colorscheme space-nvim | set background=light
    autocmd BufEnter *.py colorscheme ariake | set background=light
augroup END

Open a py file with issues. It opens in ariake color, lsp shows diagnostics, but they are not in good color. Run commdand:

:colorscheme ariake

And you now have the same color as before, but diagnostics have good colours. Is this better?

folke commented

Oh wait, are you talking about my other plugin lsp-colors? ๐Ÿ™‚

folke commented

To make that work, you'll need to add nested before the colorscheme command in your config. Otherwise the ColorScheme event won't be triggered, meaning lsp-colors can't fix your colorscheme.

lol!!!! my bad
dude, you have some many new plugins that is difficult to keep up. Not sure if the issue can be moved?

folke commented

@jmlucjav no worries, you can keep it here, but i was a bit confused ๐Ÿ˜‚

Did you try adding the nested option? That should fix it.

folke commented

I was able to transfer the issue. Didnt know that was possible :)

@jmlucjav no worries, you can keep it here, but i was a bit confused ๐Ÿ˜‚

Did you try adding the nested option? That should fix it.

I didn't understand what is nested, but I blindly added it, and it works, wonderful. many thanks

folke commented

Haha, perfect.

So what nested does, is allow any other events triggered by your autocmd to fire.

The colorscheme command normally triggers the ColorScheme event, but if you run it from within an autocmd, it won't fire by default.

Adding the nested option allows commands in your autocmd to fire events as well.

Hope this makes more sense now ;)

To make that work, you'll need to add nested before the colorscheme
command in your config. Otherwise the ColorScheme event won't be triggered, meaning lsp-colors can't fix your colorscheme.

Hi, could you explain that more detailed? I don't quite understand how to do it.

I am having the same problem as OP, i call vim.cmd 'set colorscheme nord' in my init.lua and it was all fine. But the plugin doesn't kick in unless i set in manually again.

How exactly do i do this nested config?

folke commented

@hrqmonteiro you should not include the set in your CMD. That syntax is not correct

folke commented

Ops problem was because he changed the colorscheme in an autocmd without nested. If you're not doing that, then this is something different.

@hrqmonteiro you should not include the set in your CMD. That syntax is not correct

My mistake, it's actually not that, just vim.cmd 'colorscheme nord'

And even like this, is not kicking in.

When i open a file:

2021-05-20_08-00

After i manually re-set the color scheme in the cmd:

2021-05-20_08-00_1

folke commented

@hrqmonteiro that's weird. How are you loading lsp-colors? and when do you do colorscheme? Package manager?

folke commented

After opening the file, when it is wrong, what does :verbose hi LspDiagnosticsUnderlineError give?