|DEPRECATION| enhance(themes): Auto colorscheme detection and more
- `auto` theme now auto loads available theme for colorschme based on g:color_name . If that fails then it generates a theme for that colorschme like before. - Theme from external source is preferred over bundled version in lualine . This means if user has a colorschme that provided the same theme as lualine the one from colorschme will be loaded. - Default value of theme is changed to `auto` from `gruvbox`. - Now when users theme from config fails lualine will fallbavk to `auto`. If `auto` fails then lualine will fallback to `gruvbox` - Some themes have been renamed to their actual name (g:color_name). older names have been deprecated. [DEPRECATION] oceanicnext -> OceanicNext papercolor -> PaperColor tomorrow -> Tomorrow gruvbox_material -> gruvbox-material modus_vivendi -> modus-vivendi - A few more adaptive themes added (aye, gruvbox, iceberg) - Updated THEMES.md to reflect changes in theme name
This commit is contained in:
parent
570e68095e
commit
32727039a9
26
THEMES.md
26
THEMES.md
|
@ -37,6 +37,10 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648541-cbb0cc80-74bb-11eb-843f-19c4c58b1d91.png'/>
|
||||
</p>
|
||||
|
||||
### ayu
|
||||
It's a combination of ayu_light, ayu_dark & ayu_mirage. It loads one of these
|
||||
them based you your `g:ayucolor` option.
|
||||
|
||||
### codedark
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648568-dff4c980-74bb-11eb-9d16-b68ac68f2ab2.png'/>
|
||||
|
@ -61,7 +65,7 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648675-22b6a180-74bc-11eb-9b8e-45e64a03e062.png'/>
|
||||
</p>
|
||||
|
||||
### gruvbox
|
||||
### gruvbox_dark
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648685-2b0edc80-74bc-11eb-9ec9-9aac3677df43.png'/>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648693-2ea26380-74bc-11eb-831a-9ebbe4f3dd83.png'/>
|
||||
|
@ -77,7 +81,11 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/34294427/118757020-5ffdb600-b896-11eb-95e7-dbf1f08e063d.png'/>
|
||||
</p>
|
||||
|
||||
### gruvbox_material
|
||||
### gruvbox
|
||||
It's a combination of gruvbox_light and gruvbox_dark. It loads either of
|
||||
them based you your `background` option.
|
||||
|
||||
### gruvbox-material
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648725-3f52d980-74bc-11eb-8fa5-a77b0a21cdea.png'/>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648728-41b53380-74bc-11eb-99cf-001eab6cc51b.png'/>
|
||||
|
@ -109,6 +117,10 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648862-7aeda380-74bc-11eb-808c-1b12dde45f3d.png'/>
|
||||
</p>
|
||||
|
||||
### iceberg
|
||||
It's a combination of icrberg_light and icrberg_dark. It loads either of
|
||||
them based you your `background` option.
|
||||
|
||||
### jellybeans
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648882-82ad4800-74bc-11eb-91e8-4d38fcdec134.png'/>
|
||||
|
@ -125,7 +137,7 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108648935-a2dd0700-74bc-11eb-9a4b-72eb1e2ab79e.png'/>
|
||||
</p>
|
||||
|
||||
### modus_vivendi
|
||||
### modus-vivendi
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/9327361/114389966-58176b80-9b9e-11eb-944e-1e0079527d74.png'/>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/9327361/114390000-606fa680-9b9e-11eb-97dd-ef5bbc23049a.png'/>
|
||||
|
@ -157,7 +169,7 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649021-cf911e80-74bc-11eb-8b4a-9f9eb61c7973.png'/>
|
||||
</p>
|
||||
|
||||
### oceanicnext
|
||||
### OceanicNext
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649039-d7e95980-74bc-11eb-9a33-df413936c645.png'/>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649043-d91a8680-74bc-11eb-9b1b-9c2e88ede3aa.png'/>
|
||||
|
@ -205,6 +217,10 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649137-0cf5ac00-74bd-11eb-8764-765bead5de6e.png'/>
|
||||
</p>
|
||||
|
||||
### PaperColor
|
||||
It's a combination of papercolor_light and papercolor_dark. It loads either of
|
||||
them based you your `background` option.
|
||||
|
||||
### powerline
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649147-14b55080-74bd-11eb-9670-713185342eb2.png'/>
|
||||
|
@ -237,7 +253,7 @@ lualine try to match your colorscheme.
|
|||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649258-48907600-74bd-11eb-9bba-8e82b56777d9.png'/>
|
||||
</p>
|
||||
|
||||
### tomorrow
|
||||
### Tomorrow
|
||||
<p>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649275-51814780-74bd-11eb-881b-1e137a0cbfe0.png'/>
|
||||
<img width='700' src='https://user-images.githubusercontent.com/41551030/108649297-59d98280-74bd-11eb-92a5-a8c4af150106.png'/>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
local config = {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'gruvbox',
|
||||
theme = 'auto',
|
||||
component_separators = {'', ''},
|
||||
section_separators = {'', ''},
|
||||
disabled_filetypes = {}
|
||||
|
|
|
@ -171,20 +171,74 @@ end
|
|||
|
||||
local function tabline() return statusline(config.tabline, true) end
|
||||
|
||||
local function check_theme_name_deprecation(theme_name)
|
||||
local deprection_table = {
|
||||
oceanicnext = 'OceanicNext',
|
||||
papercolor = 'PaperColor',
|
||||
tomorrow = 'Tomorrow',
|
||||
gruvbox_material = 'gruvbox-material',
|
||||
modus_vivendi = 'modus-vivendi',
|
||||
}
|
||||
if deprection_table[theme_name] then
|
||||
local correct_name = deprection_table[theme_name]
|
||||
utils_notices.add_notice(string.format([[
|
||||
### options.theme
|
||||
You're using `%s` as theme name .
|
||||
It has recently been renamed to `%s`.
|
||||
Please update your config to follow that.
|
||||
|
||||
You have something like this in your config.
|
||||
```lua
|
||||
options = {
|
||||
theme = '%s'
|
||||
}
|
||||
```
|
||||
|
||||
You'll have to change it to something like this.
|
||||
```lua
|
||||
options = {
|
||||
theme = '%s'
|
||||
}
|
||||
```
|
||||
|
||||
]], theme_name, correct_name, theme_name, correct_name))
|
||||
return correct_name
|
||||
end
|
||||
return theme_name
|
||||
end
|
||||
|
||||
local function notify_theme_error(theme_name)
|
||||
local message_template = theme_name ~= 'auto' and [[
|
||||
### options.theme
|
||||
Theme `%s` not found, falling back to `auto`. Check if spelling is right.
|
||||
]] or [[
|
||||
### options.theme
|
||||
Theme `%s` failed, falling back to `gruvbox`.
|
||||
This shouldn't happen.
|
||||
Please report the issue at https://github.com/shadmansaleh/lualine.nvim/issues .
|
||||
Also provide what colorscheme you're using.
|
||||
]]
|
||||
utils_notices.add_notice(string.format(message_template, theme_name))
|
||||
end
|
||||
|
||||
local function setup_theme()
|
||||
local function get_theme_from_config()
|
||||
local theme_name = config.options.theme
|
||||
if type(theme_name) == 'string' then
|
||||
package.loaded['lualine.themes.'..theme_name] = nil
|
||||
local ok, theme = pcall(require, 'lualine.themes.' .. theme_name)
|
||||
if ok then return theme end
|
||||
theme_name = check_theme_name_deprecation(theme_name)
|
||||
local ok, theme = pcall(loader.load_theme, theme_name)
|
||||
if ok and theme then return theme end
|
||||
elseif type(theme_name) == 'table' then
|
||||
-- use the provided theme as-is
|
||||
return config.options.theme
|
||||
end
|
||||
vim.api.nvim_err_writeln('theme ' .. tostring(theme_name) ..
|
||||
' not found, defaulting to gruvbox')
|
||||
return require 'lualine.themes.gruvbox'
|
||||
if theme_name ~= 'auto' then
|
||||
notify_theme_error(theme_name)
|
||||
local ok, theme = pcall(loader.load_theme, 'auto')
|
||||
if ok and theme then return theme end
|
||||
end
|
||||
notify_theme_error('auto')
|
||||
return loader.load_theme('gruvbox')
|
||||
end
|
||||
local theme = get_theme_from_config()
|
||||
highlight.create_highlight_groups(theme)
|
||||
|
|
|
@ -1,4 +1,13 @@
|
|||
local utils = require 'lualine.utils.utils'
|
||||
local loader = require 'lualine.utils.loader'
|
||||
|
||||
local color_name = vim.g.colors_name
|
||||
if color_name then
|
||||
-- Check if there's a theme for current colorscheme
|
||||
-- If there is load that instead of genarating a new one
|
||||
local ok, theme = pcall(loader.load_theme, color_name)
|
||||
if ok and theme then return theme end
|
||||
end
|
||||
|
||||
---------------
|
||||
-- Constents --
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
-- Copyright (c) 2020-2021 shadmansaleh
|
||||
-- MIT license, see LICENSE for more details.
|
||||
-- Credit: itchyny(lightline)
|
||||
-- License: MIT License
|
||||
local style = vim.g.ayucolor or 'dark'
|
||||
|
||||
return require('lualine.themes.ayu_' .. style)
|
|
@ -1,48 +1,7 @@
|
|||
-- Copyright (c) 2020-2021 hoob3rt
|
||||
-- Copyright (c) 2020-2021 shadmansaleh
|
||||
-- MIT license, see LICENSE for more details.
|
||||
-- LuaFormatter off
|
||||
local colors = {
|
||||
black = '#282828',
|
||||
white = '#ebdbb2',
|
||||
red = '#fb4934',
|
||||
green = '#b8bb26',
|
||||
blue = '#83a598',
|
||||
yellow = '#fe8019',
|
||||
gray = '#a89984',
|
||||
darkgray = '#3c3836',
|
||||
lightgray = '#504945',
|
||||
inactivegray = '#7c6f64',
|
||||
}
|
||||
-- LuaFormatter on
|
||||
return {
|
||||
normal = {
|
||||
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.darkgray, fg = colors.gray}
|
||||
},
|
||||
insert = {
|
||||
a = {bg = colors.blue, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.lightgray, fg = colors.white}
|
||||
},
|
||||
visual = {
|
||||
a = {bg = colors.yellow, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.inactivegray, fg = colors.black}
|
||||
},
|
||||
replace = {
|
||||
a = {bg = colors.red, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.black, fg = colors.white}
|
||||
},
|
||||
command = {
|
||||
a = {bg = colors.green, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.inactivegray, fg = colors.black}
|
||||
},
|
||||
inactive = {
|
||||
a = {bg = colors.darkgray, fg = colors.gray, gui = 'bold'},
|
||||
b = {bg = colors.darkgray, fg = colors.gray},
|
||||
c = {bg = colors.darkgray, fg = colors.gray}
|
||||
}
|
||||
}
|
||||
-- Credit: itchyny(lightline)
|
||||
-- License: MIT License
|
||||
local background = vim.opt.background:get()
|
||||
|
||||
return require('lualine.themes.gruvbox_' .. background)
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
-- Copyright (c) 2020-2021 hoob3rt
|
||||
-- MIT license, see LICENSE for more details.
|
||||
-- LuaFormatter off
|
||||
local colors = {
|
||||
black = '#282828',
|
||||
white = '#ebdbb2',
|
||||
red = '#fb4934',
|
||||
green = '#b8bb26',
|
||||
blue = '#83a598',
|
||||
yellow = '#fe8019',
|
||||
gray = '#a89984',
|
||||
darkgray = '#3c3836',
|
||||
lightgray = '#504945',
|
||||
inactivegray = '#7c6f64',
|
||||
}
|
||||
-- LuaFormatter on
|
||||
return {
|
||||
normal = {
|
||||
a = {bg = colors.gray, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.darkgray, fg = colors.gray}
|
||||
},
|
||||
insert = {
|
||||
a = {bg = colors.blue, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.lightgray, fg = colors.white}
|
||||
},
|
||||
visual = {
|
||||
a = {bg = colors.yellow, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.inactivegray, fg = colors.black}
|
||||
},
|
||||
replace = {
|
||||
a = {bg = colors.red, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.black, fg = colors.white}
|
||||
},
|
||||
command = {
|
||||
a = {bg = colors.green, fg = colors.black, gui = 'bold'},
|
||||
b = {bg = colors.lightgray, fg = colors.white},
|
||||
c = {bg = colors.inactivegray, fg = colors.black}
|
||||
},
|
||||
inactive = {
|
||||
a = {bg = colors.darkgray, fg = colors.gray, gui = 'bold'},
|
||||
b = {bg = colors.darkgray, fg = colors.gray},
|
||||
c = {bg = colors.darkgray, fg = colors.gray}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
-- Copyright (c) 2020-2021 shadmansaleh
|
||||
-- MIT license, see LICENSE for more details.
|
||||
-- Credit: itchyny(lightline)
|
||||
-- License: MIT License
|
||||
local background = vim.opt.background:get()
|
||||
|
||||
return require('lualine.themes.iceberg_' .. background)
|
|
@ -75,4 +75,24 @@ local function load_all(config)
|
|||
load_extensions(config)
|
||||
end
|
||||
|
||||
return {load_all = load_all}
|
||||
local function load(patern)
|
||||
local files = vim.fn.uniq(vim.api.nvim_get_runtime_file(patern, true))
|
||||
local n_files = #files
|
||||
if n_files == 0 then return nil
|
||||
elseif n_files == 1 then return dofile(files[1])
|
||||
else
|
||||
for _, file in ipairs(files) do
|
||||
if not file:find('lualine.nvim') then return dofile(file) end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function load_theme(theme_name)
|
||||
return load(table.concat(
|
||||
{'lua', 'lualine', 'themes', theme_name..'.lua'}, package.config:sub(1, 1)))
|
||||
end
|
||||
|
||||
return {
|
||||
load_all = load_all,
|
||||
load_theme = load_theme
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ describe('config parsing', function()
|
|||
describe('theme', function()
|
||||
it('default', function()
|
||||
local config = config_module.apply_configuration({})
|
||||
eq(config.options.theme, 'gruvbox')
|
||||
eq(config.options.theme, 'auto')
|
||||
end)
|
||||
it('custom', function()
|
||||
local config = {options = {theme = 'nord'}}
|
||||
|
|
Loading…
Reference in New Issue