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

Color cannot be overwritten #2

Closed
yamatsum opened this issue Jan 26, 2021 · 16 comments
Closed

Color cannot be overwritten #2

yamatsum opened this issue Jan 26, 2021 · 16 comments

Comments

@yamatsum
Copy link
Contributor

yamatsum commented Jan 26, 2021

If want to change the color of a particular highlight group, can't overwrite it in the usual way.
For example, it cannot be changed by the following method

highlight! ALEErrorSign guifg=#E06C75

Onebuddy could change this way.

If want to do the same with one-nvim, have to do the following

autocmd Colorscheme * highlight ALEErrorSign guifg=#E06C75

Can fix it?

@Th3Whit3Wolf
Copy link
Owner

Does it change when you run

highlight ALEErrorSign guifg=#E06C75

highlight! is not a command, I think you're confusing it with hi!

@yamatsum
Copy link
Contributor Author

Does it change when you run

After the plugin is loaded, it will change if run it with vim running.
However, until now, it was described and set in init.lua and it worked, but it does not work with one-nvim.
Works well with plugins for other color schemes.

@Th3Whit3Wolf
Copy link
Owner

Are you calling it after setting the colorscheme?

@yamatsum
Copy link
Contributor Author

Are you calling it after setting the colorscheme?

Yes, give it a try

@Th3Whit3Wolf
Copy link
Owner

I add

vim.api.nvim_command('autocmd Colorscheme * highlight Normal guibg=#FF0000')

to the end of my init.lua and it worked. Try adding your autocmd to the last line of you init.lua.

@yamatsum
Copy link
Contributor Author

Yes i know.
I want to change it without using autocmd.
That's possible with onebuddy and other plugins

@Th3Whit3Wolf
Copy link
Owner

Sorry I misunderstood,

inside nvim/after/colors/one-nvim.vim

highlight ALEErrorSign guifg=#E06C75

where nvim is the root directory of your nvim folder.

@yamatsum
Copy link
Contributor Author

Sorry I misunderstood,

I'm sorry in poor English😅

nvim/after/colors/one-nvim.vim

I tried with this path and all the other syntax broke

@Th3Whit3Wolf
Copy link
Owner

Just to verify, if you are on linux, if you run

cat ~/.config/nvim/after/colors/one-nvim.vim

you get

highlight ALEErrorSign guifg=#E06C75

Is that right?

@yamatsum
Copy link
Contributor Author

yamatsum commented Jan 26, 2021

Initial state
Screen Shot 2021-01-27 at 0 32 30

After setting

❯ cat ~/.config/nvim/after/colors/one-nvim.vim
highlight ALEErrorSign guifg=#E06C75

Screen Shot 2021-01-27 at 0 37 35

reference:
https://github.com/yamatsum/mackup/tree/master/.config/nvim

@Th3Whit3Wolf
Copy link
Owner

I think I have it now

" ~/.config/nvim/after/colors/one-nvim.vim
highlight ALEErrorSign guifg=#E06C75
-- end of init.lua
vim.api.nvim_command("runtime! after/colors/one-nvim.vim")

@yamatsum
Copy link
Contributor Author

After all it did not work.
Thank you for your kind answer.

The original purpose was just to overwrite the highlights with a simple setup.
Why can't one-nvim do what onebuddy can do?🤔

@Th3Whit3Wolf
Copy link
Owner

Th3Whit3Wolf commented Jan 26, 2021

That's strange. It worked on my computer.

I think you're probably best off using the autocmd since you said that worked.
I have no idea why it would work with onebuddy but not one-nvim.

@Th3Whit3Wolf
Copy link
Owner

Th3Whit3Wolf commented Jan 26, 2021

Worked this out with the creator of nvim-highlite

vim.api.nvim_command("augroup Highlight")
vim.api.nvim_command("autocmd!")
vim.api.nvim_command("autocmd ColorScheme one-nvim hi! Normal guifg=#000000 guibg=#FFFFFF")
vim.api.nvim_command("augroup end")
vim.api.nvim_command("colorscheme one-nvim")

@Th3Whit3Wolf
Copy link
Owner

Or you could do

local vim, api, cmd = vim, vim.api, vim.cmd

local function augroups(definitions)
    for group_name, definition in pairs(definitions) do
        api.nvim_command("augroup " .. group_name)
        api.nvim_command("autocmd!")
        for _, def in ipairs(definition) do
            local command = table.concat(vim.tbl_flatten {"autocmd", def}, " ")
            api.nvim_command(command)
        end
        api.nvim_command("augroup END")
    end
end

local autocmds = {
    Highlight = {
        {"ColorScheme", "one-nvim", "hi! Normal guifg=#000000 guibg=#FFFFFF"}
    }
}

augroups(autocmds)
cmd 'colorscheme one-nvim'

It will do the same thing.

@yamatsum
Copy link
Contributor Author

yamatsum commented Jan 27, 2021

I know I can change it with autocmd but I don't want to use autocmd just to overwrite colors.
This ticket will be closed so that I can proceed with the investigation.
Thank you.

nrydanov added a commit to nrydanov/one-nvim that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants