Closed Th3Whit3Wolf closed 3 years ago
I'll take a look and see what the issue might be. Currently I know that after Neovim loads I can run hi!
and either link or override what was set by nvim-highlite
. I'll try embedding the command into a minimal RC so I can replicate the issue.
I can get the bug to happen with this minimal config:
packadd nvim-highlite
set termguicolors "optional
colorscheme highlite
hi! Error guifg=#000000 guibg=#FFFFFF
I'll keep investigating.
Adding this to the top of the file:
augroup Highlite
autocmd!
autocmd ColorScheme * call getchar()
autocmd ColorScheme * echom "loaded '".expand("<amatch>")."' from '".expand("<afile>")."'"
augroup end
…reveals that the colorscheme is loaded twice. That's probably why the bug is occuring— maybe.
The above examples don't work with default colorschemes either:
augroup Highlite
autocmd!
autocmd ColorScheme * call getchar()
autocmd ColorScheme * echom "loaded '".expand("<amatch>")."' from '".expand("<afile>")."'"
augroup end
set termguicolors
colorscheme slate
hi! Error guifg=#000000 guibg=#FFFFFF
Seems like it could be something with Neovim in general that Colorbuddy has a workaround for, since I can confirm the following works:
augroup Highlite
autocmd!
autocmd ColorScheme * call getchar()
autocmd ColorScheme * echom "loaded '".expand("<amatch>")."' from '".expand("<afile>")."'"
autocmd ColorScheme * hi! Error guifg=#000000 guibg=#FFFFFF
augroup end
set termguicolors
colorscheme slate
Perhaps there should be a similar workaround for nvim-highlite
? Something like highlite.highlight_always()
which performs highlite.highlight()
with the arguments on ColorScheme
events. It would look like this:
packadd nvim-highlite
set termguicolors "optional
colorscheme highlite
lua << EOF
local highlight = require('highlite').highlight_always
highlight('Error', {fg="#000000", bg="#FFFFFF"})
-- other highlights below
EOF
I think mentioning how to do it on the README or in a wiki would be fine. It puts whatever the cost of the function is onto the minority of the people that want it.
Does the referencing commit add instructions which seem clear enough?
Yeah I think so
In the future I see lua being more commonplace in neovim configs and with people using init.lua
s more I am curious how you would write this in lua. I found two ways.
The ugly way
vim.api.nvim_command("augroup Highlight")
vim.api.nvim_command("autocmd!")
vim.api.nvim_command("autocmd ColorScheme highlite hi! Normal guifg=#000000 guibg=#FFFFFF")
vim.api.nvim_command("augroup end")
vim.api.nvim_command("colorscheme highlite")
The prettier way
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", "highlite", "hi! Normal guifg=#000000 guibg=#FFFFFF"}
}
}
augroups(autocmds)
cmd 'colorscheme highlite'
The second way also blends in more with the config if you use the augroups
function for generating all of your autocmds.
I'm not very experienced with lua thought so I'm curious if you have a nice way of doing it.
I definitely see Lua being the way to go in the future too. If you use multiline strings and nvim_exec
it's a little prettier:
vim.api.nvim_exec[[
augroup Highlight
autocmd!
autocmd ColorScheme highlite hi! Normal guifg=#000000 guibg=#FFFFFF
augroup end
"more vimscript
]]
I believe the Neovim team is working on a wrapper for autocommands in Lua. After that is complete you'll be able to do this even more easily (although we don't know what it looks like yet).
Sorry to bug you, I have an issue where the user can not change the highlight in one-nvim but can in onebuddy.
I was able to change highlights by either
or
nvim/after/colors/one-nvim.vim
and adding it to the runtime.The user was unable to change the highlighting using either of these methods. Do you know if there are anything that colorbuddy does that would allow this where nvim-highlite may not? I am pretty puzzled why this won't work.