Skip to content

Commit 1624d8d

Browse files
committed
add: themer configuration with initial nordfox colorscheme
1 parent 66b2a01 commit 1624d8d

File tree

5 files changed

+82
-1
lines changed

5 files changed

+82
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ tags
103103
# My ignores
104104
plugin/packer_compiled.lua
105105
notes.md
106-
106+
examples/*

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ RUN rm -rf /root/temp
1313
# Copy the curren neovim config
1414
COPY . /root/.config/nvim
1515

16+
CMD ["nvim"]

lua/core/utils/init.lua

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
local utils = {}
2+
3+
utils.table_has_value = function (tab, val)
4+
for _, tab_val in pairs(tab) do
5+
if tab_val == val then
6+
return true
7+
end
8+
end
9+
10+
return false
11+
end
12+
13+
return utils

lua/plugins/configs/init.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ M.plugins_init = function (packer_boostrap)
5858
end
5959
}
6060

61+
use {
62+
"themercorp/themer.lua",
63+
config = function ()
64+
require "plugins.configs.themer"
65+
end
66+
}
67+
6168
-- Sync the plugins if it is a boostrap
6269
if packer_boostrap then
6370
require("packer").sync()

lua/plugins/configs/themer.lua

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
local status, themer = pcall(require, "themer")
2+
if (not status) then return end
3+
4+
themer.setup({
5+
-- colorscheme = "nord",
6+
transparent = false,
7+
styles = {
8+
comment = { style = "italic" },
9+
keyword = { style = "italic,bold" },
10+
},
11+
enable_installer = true,
12+
})
13+
14+
-- Configure initial theme - nordfox (this is not in Themer)
15+
local utils = require "core.utils"
16+
local cmd = vim.cmd
17+
local fn = vim.fn
18+
local nightfox_themer_path = fn.stdpath("data") .. "/themer/nightfox.nvim"
19+
local group_name = "ThemerInit"
20+
local nightfox_theme = "EdenEast/nightfox.nvim"
21+
22+
local create_themer_autocmd = function ()
23+
vim.api.nvim_create_autocmd("ChanOpen", {
24+
group = vim.api.nvim_create_augroup(group_name, {}),
25+
callback = function ()
26+
local chans = vim.api.nvim_list_chans()
27+
local themer_job_id
28+
29+
for _, value in ipairs(chans) do
30+
local correct_job_argv = "https://github.com/" .. nightfox_theme
31+
local is_themer_job = value.argv ~= nil and utils.table_has_value(value.argv, correct_job_argv)
32+
33+
if is_themer_job then
34+
themer_job_id = value.id
35+
break
36+
end
37+
end
38+
39+
if themer_job_id ~= nil then
40+
fn.jobwait({ themer_job_id })
41+
vim.api.nvim_del_augroup_by_name(group_name)
42+
require("themer.modules.installer.load_installed").load_installed_themes()
43+
vim.schedule(function ()
44+
cmd [[colorscheme nordfox]]
45+
cmd [[colorscheme nordfox]]
46+
end)
47+
end
48+
end,
49+
once = true,
50+
})
51+
end
52+
53+
if fn.empty(fn.glob(nightfox_themer_path)) > 0 then
54+
create_themer_autocmd()
55+
56+
local themer_installer_utils = require "themer.modules.installer.utils"
57+
themer_installer_utils.install(nightfox_theme)
58+
else
59+
cmd [[colorscheme nordfox]]
60+
end

0 commit comments

Comments
 (0)