| 1 |
local modules = require('lualine_require').lazy_require { notices = 'lualine.utils.notices' } |
| 2 |
|
| 3 |
local function add_notice(notice) |
| 4 |
modules.notices.add_notice('theme(base16): ' .. notice) |
| 5 |
end |
| 6 |
|
| 7 |
local function setup(colors) |
| 8 |
local theme = { |
| 9 |
normal = { |
| 10 |
a = { fg = colors.bg, bg = colors.normal }, |
| 11 |
b = { fg = colors.light_fg, bg = colors.alt_bg }, |
| 12 |
c = { fg = colors.fg, bg = colors.bg }, |
| 13 |
}, |
| 14 |
replace = { |
| 15 |
a = { fg = colors.bg, bg = colors.replace }, |
| 16 |
b = { fg = colors.light_fg, bg = colors.alt_bg }, |
| 17 |
}, |
| 18 |
insert = { |
| 19 |
a = { fg = colors.bg, bg = colors.insert }, |
| 20 |
b = { fg = colors.light_fg, bg = colors.alt_bg }, |
| 21 |
}, |
| 22 |
visual = { |
| 23 |
a = { fg = colors.bg, bg = colors.visual }, |
| 24 |
b = { fg = colors.light_fg, bg = colors.alt_bg }, |
| 25 |
}, |
| 26 |
inactive = { |
| 27 |
a = { fg = colors.dark_fg, bg = colors.bg }, |
| 28 |
b = { fg = colors.dark_fg, bg = colors.bg }, |
| 29 |
c = { fg = colors.dark_fg, bg = colors.bg }, |
| 30 |
}, |
| 31 |
} |
| 32 |
|
| 33 |
theme.command = theme.normal |
| 34 |
theme.terminal = theme.insert |
| 35 |
|
| 36 |
return theme |
| 37 |
end |
| 38 |
|
| 39 |
local function setup_default() |
| 40 |
return setup { |
| 41 |
bg = '#282a2e', |
| 42 |
alt_bg = '#373b41', |
| 43 |
dark_fg = '#969896', |
| 44 |
fg = '#b4b7b4', |
| 45 |
light_fg = '#c5c8c6', |
| 46 |
normal = '#81a2be', |
| 47 |
insert = '#b5bd68', |
| 48 |
visual = '#b294bb', |
| 49 |
replace = '#de935f', |
| 50 |
} |
| 51 |
end |
| 52 |
|
| 53 |
local function setup_base16_nvim() |
| 54 |
-- Continue to load nvim-base16 |
| 55 |
local loaded, base16 = pcall(require, 'base16-colorscheme') |
| 56 |
|
| 57 |
if not loaded then |
| 58 |
add_notice( |
| 59 |
'nvim-base16 is not currently present in your runtimepath, make sure it is properly installed,' |
| 60 |
.. ' fallback to default colors.' |
| 61 |
) |
| 62 |
|
| 63 |
return nil |
| 64 |
end |
| 65 |
|
| 66 |
if not base16.colors and not vim.env.BASE16_THEME then |
| 67 |
add_notice( |
| 68 |
'nvim-base16 is not loaded yet, you should update your configuration to load it before lualine' |
| 69 |
.. ' so that the colors from your colorscheme can be used, fallback to "tomorrow-night" theme.' |
| 70 |
) |
| 71 |
elseif not base16.colors and not base16.colorschemes[vim.env.BASE16_THEME] then |
| 72 |
add_notice( |
| 73 |
'The colorscheme "%s" defined by the environment variable "BASE16_THEME" is not handled by' |
| 74 |
.. ' nvim-base16, fallback to "tomorrow-night" theme.' |
| 75 |
) |
| 76 |
end |
| 77 |
|
| 78 |
local colors = base16.colors or base16.colorschemes[vim.env.BASE16_THEME or 'tomorrow-night'] |
| 79 |
|
| 80 |
return setup { |
| 81 |
bg = colors.base01, |
| 82 |
alt_bg = colors.base02, |
| 83 |
dark_fg = colors.base03, |
| 84 |
fg = colors.base04, |
| 85 |
light_fg = colors.base05, |
| 86 |
normal = colors.base0D, |
| 87 |
insert = colors.base0B, |
| 88 |
visual = colors.base0E, |
| 89 |
replace = colors.base09, |
| 90 |
} |
| 91 |
end |
| 92 |
|
| 93 |
local function setup_base16_vim() |
| 94 |
-- Check if tinted-theming/base16-vim is already loaded |
| 95 |
if vim.g.base16_gui00 and vim.g.base16_gui0F then |
| 96 |
return setup { |
| 97 |
bg = vim.g.base16_gui01, |
| 98 |
alt_bg = vim.g.base16_gui02, |
| 99 |
dark_fg = vim.g.base16_gui03, |
| 100 |
fg = vim.g.base16_gui04, |
| 101 |
light_fg = vim.g.base16_gui05, |
| 102 |
normal = vim.g.base16_gui0D, |
| 103 |
insert = vim.g.base16_gui0B, |
| 104 |
visual = vim.g.base16_gui0E, |
| 105 |
replace = vim.g.base16_gui09, |
| 106 |
} |
| 107 |
end |
| 108 |
|
| 109 |
-- base16-vim has been renamed to tinted-vim along with colors |
| 110 |
-- context: https://github.com/nvim-lualine/lualine.nvim/pull/1352 |
| 111 |
if vim.g.tinted_gui00 and vim.g.tinted_gui0F then |
| 112 |
return setup { |
| 113 |
bg = vim.g.tinted_gui01, |
| 114 |
alt_bg = vim.g.tinted_gui02, |
| 115 |
dark_fg = vim.g.tinted_gui03, |
| 116 |
fg = vim.g.tinted_gui04, |
| 117 |
light_fg = vim.g.tinted_gui05, |
| 118 |
normal = vim.g.tinted_gui0D, |
| 119 |
insert = vim.g.tinted_gui0B, |
| 120 |
visual = vim.g.tinted_gui0E, |
| 121 |
replace = vim.g.tinted_gui09, |
| 122 |
} |
| 123 |
end |
| 124 |
return nil |
| 125 |
end |
| 126 |
|
| 127 |
return setup_base16_vim() or setup_base16_nvim() or setup_default() |