diff --git a/nvim/.config/nvim/lua/look.lua b/nvim/.config/nvim/lua/look.lua index 88c94fb..801980e 100644 --- a/nvim/.config/nvim/lua/look.lua +++ b/nvim/.config/nvim/lua/look.lua @@ -7,10 +7,28 @@ vim.api.nvim_set_var('gruvbox_italic', 1) vim.api.nvim_set_var('one_allow_italics', 1) vim.api.nvim_set_var('pencil_terminal_italics', 1) -function B16theme(theme) - local base16scheme = b.themes[theme] - b(base16scheme, true) +local colorsfile = vim.fn.stdpath('state') .. '/colorscheme.lua' +local function source_colors() + if vim.fn.filereadable(colorsfile) == 1 then + vim.cmd("source " .. colorsfile) + end end --- set the default colorscheme -B16theme('eighties') +-- source colors automatically from colorscheme file on change +local w = vim.loop.new_fs_event() +local function on_change(err, fname, status) + source_colors() + w:stop() + Watch_file(fname) +end +function Watch_file(fname) + local fullpath = vim.api.nvim_call_function('fnamemodify', { fname, ':p' }) + w:start(fullpath, {}, vim.schedule_wrap(function(...) + on_change(...) + end)) +end + +-- set on startup +source_colors() +-- and watch continuously +Watch_file(colorsfile)