nvim: support different dark and light colorschemes
This commit is contained in:
parent
1513d23ec4
commit
29608ff8c4
@ -1,31 +1,71 @@
|
||||
# Colors (Gruvbox dark)
|
||||
# Nightfox Alacritty Colors
|
||||
## name: nightfox
|
||||
## upstream: https://github.com/edeneast/nightfox.nvim/raw/main/extra/nightfox/alacritty.toml
|
||||
|
||||
# Default colors
|
||||
[colors.primary]
|
||||
# hard contrast background = = '#1d2021'
|
||||
# background = '#282828'
|
||||
# soft contrast background = = '#32302f'
|
||||
background = '#292522'
|
||||
foreground = '#ebdbb2'
|
||||
background = "#2e3440" # changed
|
||||
foreground = "#eceff4" # changed
|
||||
dim_foreground = "#aeafb0"
|
||||
bright_foreground = "#d6d6d7"
|
||||
|
||||
[colors.cursor]
|
||||
text = "#cdcecf"
|
||||
cursor = "#aeafb0"
|
||||
|
||||
[colors.vi_mode_cursor]
|
||||
text = "#cdcecf"
|
||||
cursor = "#63cdcf"
|
||||
|
||||
[colors.search.matches]
|
||||
foreground = "#cdcecf"
|
||||
background = "#3c5372"
|
||||
|
||||
[colors.search.focused_match]
|
||||
foreground = "#cdcecf"
|
||||
background = "#81b29a"
|
||||
|
||||
[colors.footer_bar]
|
||||
foreground = "#cdcecf"
|
||||
background = "#29394f"
|
||||
|
||||
[colors.hints.start]
|
||||
foreground = "#cdcecf"
|
||||
background = "#f4a261"
|
||||
|
||||
[colors.hints.end]
|
||||
foreground = "#cdcecf"
|
||||
background = "#29394f"
|
||||
|
||||
[colors.selection]
|
||||
text = "#cdcecf"
|
||||
background = "#2b3b51"
|
||||
|
||||
# Normal colors
|
||||
[colors.normal]
|
||||
black = '#282828'
|
||||
red = '#cc241d'
|
||||
green = '#98971a'
|
||||
yellow = '#d79921'
|
||||
blue = '#458588'
|
||||
magenta = '#b16286'
|
||||
cyan = '#689d6a'
|
||||
white = '#a89984'
|
||||
black = "#393b44"
|
||||
red = "#c94f6d"
|
||||
green = "#81b29a"
|
||||
yellow = "#dbc074"
|
||||
blue = "#719cd6"
|
||||
magenta = "#9d79d6"
|
||||
cyan = "#63cdcf"
|
||||
white = "#dfdfe0"
|
||||
|
||||
# Bright colors
|
||||
[colors.bright]
|
||||
black = '#928374'
|
||||
red = '#fb4934'
|
||||
green = '#b8bb26'
|
||||
yellow = '#fabd2f'
|
||||
blue = '#83a598'
|
||||
magenta = '#d3869b'
|
||||
cyan = '#8ec07c'
|
||||
white = '#ebdbb2'
|
||||
black = "#575860"
|
||||
red = "#d16983"
|
||||
green = "#8ebaa4"
|
||||
yellow = "#e0c989"
|
||||
blue = "#86abdc"
|
||||
magenta = "#baa1e2"
|
||||
cyan = "#7ad5d6"
|
||||
white = "#e4e4e5"
|
||||
|
||||
[colors.dim]
|
||||
black = "#30323a"
|
||||
red = "#ab435d"
|
||||
green = "#6e9783"
|
||||
yellow = "#baa363"
|
||||
blue = "#6085b6"
|
||||
magenta = "#8567b6"
|
||||
cyan = "#54aeb0"
|
||||
white = "#bebebe"
|
||||
|
@ -2,7 +2,7 @@
|
||||
# author tonsky
|
||||
|
||||
[colors.primary]
|
||||
background = '#F1F1F1' # changed
|
||||
background = '#FFFFFF' # changed
|
||||
foreground = '#434343'
|
||||
|
||||
[colors.cursor]
|
||||
|
@ -32,6 +32,7 @@
|
||||
"melange-nvim": { "branch": "master", "commit": "2db5407f2f6d6d6286f50f2f7365728d66f6f3ae" },
|
||||
"mellifluous.nvim": { "branch": "v1", "commit": "1637e46585435ebda7963248e0e65422effad8d9" },
|
||||
"mini.nvim": { "branch": "main", "commit": "0420076298c4457f200c2de468f65d080597a347" },
|
||||
"nano-theme.nvim": { "branch": "main", "commit": "0b1158c4911f4bd9d5a1e2e7669ebff893435b64" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
|
||||
"neogit": { "branch": "master", "commit": "6d1bd94f7fca92a50a892f494920696b5defa8c8" },
|
||||
"nordic.nvim": { "branch": "main", "commit": "8627750ece357e9670f9e69853091f7fbb8d6523" },
|
||||
|
@ -113,10 +113,4 @@ vim.keymap.set("n", "<leader>ss", "<cmd>source ~/.config/nvim/after/plugin/luasn
|
||||
|
||||
-- colors
|
||||
|
||||
key('n', '<F6>', function()
|
||||
if vim.o.background == "dark" then
|
||||
vim.o.background = "light"
|
||||
else
|
||||
vim.o.background = "dark"
|
||||
end
|
||||
end)
|
||||
key('n', '<F6>', function() require('lupan.utils').toggle_color_scheme() end, { desc = 'Toggle background' })
|
||||
|
@ -2,6 +2,12 @@ local M = {}
|
||||
|
||||
local filename = os.getenv('HOME') .. '/.config/alacritty/alacritty.toml'
|
||||
|
||||
local colorschemes = nil
|
||||
|
||||
function M.set_color_schemes(dark, light)
|
||||
colorschemes = { dark = dark, light = light }
|
||||
end
|
||||
|
||||
function M.terminalbg()
|
||||
local ok, lines = pcall(io.lines, filename)
|
||||
if ok then
|
||||
@ -14,11 +20,29 @@ function M.terminalbg()
|
||||
return "dark"
|
||||
end
|
||||
|
||||
function M.update_color_scheme()
|
||||
vim.o.background = M.terminalbg()
|
||||
if colorschemes then
|
||||
vim.cmd.colorscheme(colorschemes[vim.o.background])
|
||||
end
|
||||
end
|
||||
|
||||
function M.toggle_color_scheme()
|
||||
if vim.o.background == "dark" then
|
||||
vim.o.background = "light"
|
||||
else
|
||||
vim.o.background = "dark"
|
||||
end
|
||||
if colorschemes then
|
||||
vim.cmd.colorscheme(colorschemes[vim.o.background])
|
||||
end
|
||||
end
|
||||
|
||||
local w = vim.uv.new_fs_event()
|
||||
|
||||
local function watch(fname)
|
||||
w:start(filename, {}, vim.schedule_wrap(function(...)
|
||||
vim.o.background = M.terminalbg()
|
||||
M.update_color_scheme()
|
||||
w:stop()
|
||||
watch(fname)
|
||||
end))
|
||||
|
@ -11,9 +11,23 @@ return {
|
||||
},
|
||||
{
|
||||
"savq/melange-nvim",
|
||||
},
|
||||
{
|
||||
'ronisbr/nano-theme.nvim',
|
||||
config = function()
|
||||
vim.o.background = require('lupan.utils').terminalbg()
|
||||
vim.cmd.colorscheme('melange')
|
||||
local nano = require('nano-theme.colors')
|
||||
local nano_get = nano.get
|
||||
function nano.get()
|
||||
local t = nano_get()
|
||||
local light = vim.o.background == 'light'
|
||||
if not light then
|
||||
t.nano_strong.fg = '#ECEFF4'
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
require('lupan.utils').set_color_schemes('nano-theme', 'nano-theme')
|
||||
require('lupan.utils').update_color_scheme()
|
||||
end
|
||||
},
|
||||
{
|
||||
|
@ -18,7 +18,7 @@ return {
|
||||
harpoon = { switch = 'f' },
|
||||
},
|
||||
colors = {
|
||||
file = '#5a418a',
|
||||
file = '#EBCB8B',
|
||||
},
|
||||
},
|
||||
keys = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user