patch custom>colorscheme>default color priority
local M = {}
M.ping_anwsered=0
+M.custom_highlight=false
-- See https://github.com/tjdevries/rofl.nvim/blob/632c10f2ec7c56882a3f7eda8849904bcac6e8af/lua/rofl.lua
local binary_path = vim.fn.fnamemodify(
@@ -72,6 +73,9 @@ function M.setup(opts)
error(string.format('[Sniprun] Key %s not exist in config values',key))
return
end
+ if key == 'snipruncolors' then
+ M.custom_highlight = true
+ end
M.config_values[key] = value
end
M.configure_keymaps()
@@ -92,13 +96,13 @@ local highlight = function(group, styles)
-- This somehow works for default highlighting. with or even without cterm colors
-- hacky way tho.Still I think better than !hlexists
vim.cmd('highlight '..group..' '..gui..' '..sp..' '..fg..' '..bg..' '..ctermbg..' '..ctermfg)
- -- For configuration file and
vim.api.nvim_command('autocmd ColorScheme * highlight '..group..' '..gui..' '..sp..' '..fg..' '..bg..' '..ctermbg..' '..ctermfg)
end
function M.setup_highlights()
local colors_table = M.config_values["snipruncolors"]
+ if M.custom_highlight then
vim.cmd('augroup snip_highlights')
vim.cmd('autocmd!')
for group, styles in pairs(colors_table) do
@@ -106,6 +110,18 @@ function M.setup_highlights()
highlight(group, styles)
end
vim.cmd('augroup END')
+ else
+ for group, styles in pairs(colors_table) do
+ local gui = styles.gui and 'gui='..styles.gui or 'gui=NONE'
+ local sp = styles.sp and 'guisp='..styles.sp or 'guisp=NONE'
+ local fg = styles.fg and 'guifg='..styles.fg or 'guifg=NONE'
+ local bg = styles.bg and 'guibg='..styles.bg or 'guibg=NONE'
+ local ctermbg = styles.ctermbg and 'ctermbg='..styles.ctermbg or 'ctermbg=NONE'
+ local ctermfg = styles.ctermfg and 'ctermfg='..styles.ctermfg or 'ctermfg=NONE'
+
+ vim.cmd("if !hlexists('"..group.."') \n hi "..group.." "..gui.." "..sp.." "..fg.." "..bg.." "..ctermbg.." "..ctermfg)
+ end
+ end
end
function M.setup_autocommands()
