| 1 |
-- Copyright (c) 2020-2021 shadmansaleh |
| 2 |
-- MIT license, see LICENSE for more details. |
| 3 |
|
| 4 |
local lualine_require = require('lualine_require') |
| 5 |
local modules = lualine_require.lazy_require { |
| 6 |
utils_notices = 'lualine.utils.notices', |
| 7 |
} |
| 8 |
local sep = package.config:sub(1, 1) |
| 9 |
local wal_colors_path = table.concat({ os.getenv('HOME'), '.cache', 'wal', 'colors.sh' }, sep) |
| 10 |
local wal_colors_file = io.open(wal_colors_path, 'r') |
| 11 |
|
| 12 |
if wal_colors_file == nil then |
| 13 |
modules.utils_notices.add_notice('lualine.nvim: ' .. wal_colors_path .. ' not found') |
| 14 |
error('') |
| 15 |
end |
| 16 |
|
| 17 |
local ok, wal_colors_text = pcall(wal_colors_file.read, wal_colors_file, '*a') |
| 18 |
wal_colors_file:close() |
| 19 |
|
| 20 |
if not ok then |
| 21 |
modules.utils_notices.add_notice('lualine.nvim: ' .. wal_colors_path .. ' could not be read: ' .. wal_colors_text) |
| 22 |
error('') |
| 23 |
end |
| 24 |
|
| 25 |
local colors = {} |
| 26 |
|
| 27 |
for line in vim.gsplit(wal_colors_text, '\n') do |
| 28 |
if line:match("^[a-z0-9]+='#[a-fA-F0-9]+'$") ~= nil then |
| 29 |
local i = line:find('=') |
| 30 |
local key = line:sub(0, i - 1) |
| 31 |
local value = line:sub(i + 2, #line - 1) |
| 32 |
colors[key] = value |
| 33 |
end |
| 34 |
end |
| 35 |
|
| 36 |
return { |
| 37 |
normal = { |
| 38 |
a = { fg = colors.background, bg = colors.color4, gui = 'bold' }, |
| 39 |
b = { fg = colors.foreground, bg = colors.color8 }, |
| 40 |
c = { fg = colors.foreground, bg = colors.background }, |
| 41 |
}, |
| 42 |
insert = { a = { fg = colors.background, bg = colors.color2, gui = 'bold' } }, |
| 43 |
visual = { a = { fg = colors.background, bg = colors.color3, gui = 'bold' } }, |
| 44 |
replace = { a = { fg = colors.background, bg = colors.color1, gui = 'bold' } }, |
| 45 |
inactive = { |
| 46 |
a = { fg = colors.foreground, bg = colors.background, gui = 'bold' }, |
| 47 |
b = { fg = colors.foreground, bg = colors.background }, |
| 48 |
c = { fg = colors.foreground, bg = colors.background }, |
| 49 |
}, |
| 50 |
} |