mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
use colorscheme instead of theme
This commit is contained in:
parent
22b33871ef
commit
dee7768162
@ -74,7 +74,7 @@ and how to set up on different platforms (Linux, macOS, and Windows).
|
|||||||
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
+ Asynchronous code execution via [asyncrun.vim](https://github.com/skywind3000/asyncrun.vim).
|
||||||
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
+ Code highlighting via [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter).
|
||||||
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
+ Code editing using true nvim inside browser via [firenvim](https://github.com/glacambre/firenvim).
|
||||||
+ Color theme via [vim-gruvbox8](https://github.com/lifepillar/vim-gruvbox8) and other beautiful themes.
|
+ Beautiful colorscheme via [sainnhe/gruvbox-material](https://github.com/sainnhe/gruvbox-material) and other colorschemes.
|
||||||
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
+ Markdown writing and previewing via [vim-markdown](https://github.com/plasticboy/vim-markdown) and [markdown-preview.nvim](https://github.com/iamcco/markdown-preview.nvim).
|
||||||
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
+ LaTeX editing and previewing via [vimtex](https://github.com/lervag/vimtex) <sup id="a1">[1](#f1)</sup>.
|
||||||
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
+ Animated GUI style notification via [nvim-notify](https://github.com/rcarriga/nvim-notify).
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
|
--- This module will load a random colorscheme on nvim startup process.
|
||||||
|
|
||||||
local utils = require('utils')
|
local utils = require('utils')
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
-- Theme to directory name mapping, because theme repo name is not necessarily
|
-- Colorscheme to its directory name mapping, because colorscheme repo name is not necessarily
|
||||||
-- the same as the theme name itself.
|
-- the same as the colorscheme name itself.
|
||||||
M.theme2dir = {
|
M.colorscheme2dir = {
|
||||||
gruvbox8 = "vim-gruvbox8",
|
gruvbox8 = "vim-gruvbox8",
|
||||||
onedark = 'onedark.nvim',
|
onedark = 'onedark.nvim',
|
||||||
edge = 'edge',
|
edge = 'edge',
|
||||||
@ -89,35 +91,36 @@ M.catppuccin = function()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Use a random theme from the pre-defined list of themes.
|
--- Use a random colorscheme from the pre-defined list of colorschemes.
|
||||||
M.rand_theme = function ()
|
M.rand_colorscheme = function ()
|
||||||
local theme = utils.rand_element(vim.tbl_keys(M.theme2dir))
|
local colorscheme = utils.rand_element(vim.tbl_keys(M.colorscheme2dir))
|
||||||
|
|
||||||
if not vim.tbl_contains(vim.tbl_keys(M), theme) then
|
if not vim.tbl_contains(vim.tbl_keys(M), colorscheme) then
|
||||||
local msg = "Invalid theme: " .. theme
|
local msg = "Invalid colorscheme: " .. colorscheme
|
||||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Load the theme, because all the themes are declared as opt plugins, the theme isn't loaded yet.
|
-- Load the colorscheme, because all the colorschemes are declared as opt plugins, so the colorscheme isn't loaded yet.
|
||||||
local status = utils.add_pack(M.theme2dir[theme])
|
local status = utils.add_pack(M.colorscheme2dir[colorscheme])
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
local msg = string.format("Theme %s is not installed. Run PackerSync to install.", theme)
|
local msg = string.format("Colorscheme %s is not installed. Run PackerSync to install.", colorscheme)
|
||||||
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.ERROR, { title = 'nvim-config' })
|
||||||
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set the theme.
|
-- Load the colorscheme and its settings
|
||||||
M[theme]()
|
M[colorscheme]()
|
||||||
|
|
||||||
if vim.g.logging_level == 'debug' then
|
if vim.g.logging_level == 'debug' then
|
||||||
local msg = "Colorscheme: " .. theme
|
local msg = "Colorscheme: " .. colorscheme
|
||||||
|
|
||||||
vim.notify(msg, vim.log.levels.DEBUG, { title = 'nvim-config' })
|
vim.notify(msg, vim.log.levels.DEBUG, { title = 'nvim-config' })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
M.rand_theme()
|
-- Load a random colorscheme
|
||||||
|
M.rand_colorscheme()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user