nvim: Improve dynamic colorscheme sourcing

This commit is contained in:
Marty Oehme 2023-03-07 10:41:10 +01:00
parent 09af447747
commit 954ccf5e89
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 12 additions and 29 deletions

View file

@ -19,6 +19,7 @@
"dressing.nvim": { "branch": "master", "commit": "5f44f829481640be0f96759c965ae22a3bcaf7ce" },
"formatter.nvim": { "branch": "master", "commit": "ed949c13e1a942db29ababa35e8c7864ced90eb6" },
"friendly-snippets": { "branch": "main", "commit": "009887b76f15d16f69ae1341f86a7862f61cf2a1" },
"fwatch.nvim": { "branch": "main", "commit": "a691f7349dc66285cd75a1a698dd28bca45f2bf8" },
"gitsigns.nvim": { "branch": "main", "commit": "bb808fc7376ed7bac0fbe8f47b83d4bf01738167" },
"jupyter-kernel.nvim": { "branch": "main", "commit": "92eee2a9fcff65aedaba8f0544b87db44981673b" },
"lazy.nvim": { "branch": "main", "commit": "8d18ef44e769e98a8dc974ca85275de1d8cc7c04" },
@ -34,8 +35,8 @@
"mini.nvim": { "branch": "main", "commit": "427751024313e2270ca723eb16af7b218c83a7fc" },
"neural": { "branch": "main", "commit": "155618730b87a67655bdde373ee27bfce8b07ac9" },
"nui.nvim": { "branch": "main", "commit": "0dc148c6ec06577fcf06cbab3b7dac96d48ba6be" },
"nvim-base16.lua": { "branch": "master", "commit": "b336f40462b3ca1ad16a17c195b83731a2942d9a" },
"nvim-cmp": { "branch": "main", "commit": "983453e32cb35533a119725883c04436d16c0120" },
"nvim-base16": { "branch": "master", "commit": "0cab02bac9ca02a70db9e1d07e25fdb630b18a21" },
"nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" },
"nvim-lspconfig": { "branch": "master", "commit": "e0926b6abc84578f44fb8917d61cdee22188639e" },
"nvim-notify": { "branch": "master", "commit": "bdd647f61a05c9b8a57c83b78341a0690e9c29d7" },

View file

@ -1,12 +1,3 @@
local b = require('base16')
-- italic comments if supported
local set_hl = require("util.highlight")
set_hl("Comment", { gui = "italic" })
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)
local colorsfile = vim.fn.stdpath('state') .. '/colorscheme.lua'
local function source_colors()
if vim.fn.filereadable(colorsfile) == 1 then
@ -14,21 +5,11 @@ local function source_colors()
end
end
-- 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)
-- continuously watch colors file for changes
local fwatch = require('fwatch')
fwatch.watch(colorsfile, {
on_event = vim.schedule_wrap(function() source_colors() end)
})

View file

@ -14,6 +14,9 @@ return {
opts = { numhl = true, signcolumn = false },
event = "BufRead"
}, {
},
{ 'RRethy/nvim-base16', event = "BufWinEnter",
dependencies = { 'rktjmp/fwatch.nvim' } }, {
'norcalli/nvim-colorizer.lua', -- color hex, named colors in the correct preview scheme
config = true,
event = "VeryLazy"
@ -59,9 +62,7 @@ return {
}, {
'junegunn/vim-easy-align', -- Align tables and other alignable things
event = "VeryLazy"
}, -- colorschemes
{ 'norcalli/nvim-base16.lua' }, --
-- statusline
}, -- statusline
{
'nvim-lualine/lualine.nvim',
requires = { 'kyazdani42/nvim-web-devicons', opt = true },