mirror of
https://github.com/rose-pine/neovim.git
synced 2025-10-15 12:38:53 +02:00
refactor: simplify init
This commit is contained in:
parent
da95f1bad5
commit
6bdbe52159
3 changed files with 50 additions and 75 deletions
|
|
@ -1,9 +1,6 @@
|
|||
lua << EOF
|
||||
package.loaded['rose-pine'] = nil
|
||||
package.loaded['rose-pine.functions'] = nil
|
||||
package.loaded['rose-pine.palette'] = nil
|
||||
package.loaded['rose-pine.theme'] = nil
|
||||
package.loaded['rose-pine.util'] = nil
|
||||
lua package.loaded['rose-pine'] = nil
|
||||
lua package.loaded['rose-pine.config'] = nil
|
||||
lua package.loaded['rose-pine.palette'] = nil
|
||||
lua package.loaded['rose-pine.theme'] = nil
|
||||
|
||||
require('rose-pine').set()
|
||||
EOF
|
||||
lua require('rose-pine').colorscheme()
|
||||
|
|
|
|||
|
|
@ -1,9 +1,50 @@
|
|||
local util = require('rose-pine.util')
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.set()
|
||||
util.load()
|
||||
function M.colorscheme()
|
||||
if vim.g.colors_name then
|
||||
vim.cmd('hi clear')
|
||||
end
|
||||
|
||||
vim.opt.termguicolors = true
|
||||
vim.g.colors_name = 'rose-pine'
|
||||
|
||||
-- Match terminal theme if no variant is set
|
||||
if vim.g.rose_pine_variant == nil and vim.o.background == 'light' then
|
||||
vim.g.rose_pine_variant = 'dawn'
|
||||
elseif vim.g.rose_pine_variant == 'dawn' then
|
||||
vim.o.background = 'light'
|
||||
end
|
||||
|
||||
---@param group string
|
||||
---@param color table<string, string>
|
||||
local function highlight(group, color)
|
||||
local style = color.style and 'gui=' .. color.style or 'gui=NONE'
|
||||
local fg = color.fg and 'guifg=' .. color.fg or 'guifg=NONE'
|
||||
local bg = color.bg and 'guibg=' .. color.bg or 'guibg=NONE'
|
||||
local sp = color.sp and 'guisp=' .. color.sp or ''
|
||||
|
||||
local hl = 'highlight '
|
||||
.. group
|
||||
.. ' '
|
||||
.. style
|
||||
.. ' '
|
||||
.. fg
|
||||
.. ' '
|
||||
.. bg
|
||||
.. ' '
|
||||
.. sp
|
||||
|
||||
vim.cmd(hl)
|
||||
if color.link then
|
||||
vim.cmd('highlight! link ' .. group .. ' ' .. color.link)
|
||||
end
|
||||
end
|
||||
|
||||
for group, colors in pairs(require('rose-pine.theme')) do
|
||||
highlight(group, colors)
|
||||
end
|
||||
|
||||
require('rose-pine.galaxyline.theme')
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -1,63 +0,0 @@
|
|||
local util = {}
|
||||
|
||||
util.highlight = function(group, color)
|
||||
local style = color.style and 'gui=' .. color.style or 'gui=NONE'
|
||||
local fg = color.fg and 'guifg=' .. color.fg or 'guifg=NONE'
|
||||
local bg = color.bg and 'guibg=' .. color.bg or 'guibg=NONE'
|
||||
local sp = color.sp and 'guisp=' .. color.sp or ''
|
||||
|
||||
local hl = 'highlight '
|
||||
.. group
|
||||
.. ' '
|
||||
.. style
|
||||
.. ' '
|
||||
.. fg
|
||||
.. ' '
|
||||
.. bg
|
||||
.. ' '
|
||||
.. sp
|
||||
|
||||
vim.cmd(hl)
|
||||
if color.link then
|
||||
vim.cmd('highlight! link ' .. group .. ' ' .. color.link)
|
||||
end
|
||||
end
|
||||
|
||||
function util.load()
|
||||
if vim.g.colors_name then
|
||||
vim.cmd('hi clear')
|
||||
end
|
||||
|
||||
vim.o.termguicolors = true
|
||||
vim.g.colors_name = 'rose-pine'
|
||||
|
||||
if vim.o.background == 'light' and vim.g.rose_pine_variant == nil then
|
||||
vim.g.rose_pine_variant = 'dawn'
|
||||
elseif
|
||||
vim.g.rose_pine_variant == 'dawn'
|
||||
or vim.g.rose_pine_variant == 'rose-pine-dawn'
|
||||
then
|
||||
vim.o.background = 'light'
|
||||
end
|
||||
|
||||
local theme = require('rose-pine.theme')
|
||||
|
||||
theme.load_terminal()
|
||||
|
||||
for group, colors in pairs(theme.base) do
|
||||
util.highlight(group, colors)
|
||||
end
|
||||
|
||||
for group, colors in pairs(theme.treesitter) do
|
||||
util.highlight(group, colors)
|
||||
end
|
||||
|
||||
for group, colors in pairs(theme.plugins) do
|
||||
util.highlight(group, colors)
|
||||
end
|
||||
|
||||
-- Load galaxyline theme
|
||||
require("rose-pine.galaxyline.theme")
|
||||
end
|
||||
|
||||
return util
|
||||
Loading…
Add table
Add a link
Reference in a new issue