nvim-xresources is a colorscheme for Neovim that uses your Xresources colors.
I've never really enjoyed using a colorscheme: for me, the ideal setup is the nvim default with my colors defined in Xresources. However many plugins require the use of true colors with set termguicolors
. The concept of this plugin is to stay faithful to the colors defined in Xresources, but in true colors.
This plugin aims for simplicity, though I have incorporated a few extra choices:
- auto_light feature: useful when Xresources only contains 8 colors
- palette_overrides: change palette colors
- custom_highlight_groups() function: override or add groups
- contrast option: set contrast for colors bg1, bg2, bg3 and fg1
- :ShowPalette cmd: Show palette colors in a floating window
- Supports termux colors.properties
- supports lualine, nvim-treesitter, noice, nvim-telescope...
This plugin is a work in progress, and there are many things missing! I am more than willing to accept pull requests to help improve it.
{
'martineausimon/nvim-xresources',
lazy = false,
priority = 1000,
config = function()
require('nvim-xresources').setup({
-- Optional config:
-- xresources_path = os.getenv("HOME") .. '/.Xresources',
-- auto_light = {
-- enable = true,
-- value = 0.5,
-- exclude = {},
-- },
-- contrast = 1,
-- bold = true,
-- palette_overrides = {},
-- fallback_theme = "nord"
})
--local C = require('nvim-xresources.colors')
--require('nvim-xresources').custom_highlight_groups({ })
vim.cmd('colorscheme xresources')
end
}
Note: This plugin works with
xrdb
(orcolors.properties
in Termux). You need a system configured with this, otherwise, a fallback theme will be used (defaultnord
, availabletokyonight
)
an example setup with Lazy. Pay attention to the order of the elements: require('nvim-xresources.colors')
must be called after the setup()
function
{
'martineausimon/nvim-xresources',
lazy = false,
priority = 1000,
config = function()
require('nvim-xresources').setup({
xresources_path = os.getenv("HOME") .. '/.Xresources',
auto_light = {
enable = true,
value = 0.5,
exclude = {
"light_green",
"light_blue",
}
},
contrast = 0.6,
bold = false,
palette_overrides = {
green = "#3CB371",
},
})
local C = require('nvim-xresources.colors')
require('nvim-xresources').custom_highlight_groups({
-- link to a existing group :
pythonBuiltin = "PreProc",
-- or define highlights :
pythonFunction = { guifg = C.cyan, guibg = nil, gui = C.bold, guisp = nil }, -- use "bold" if you want to bypass bold true/false option
})
vim.cmd('colorscheme xresources')
end
}
-
The
:ShowPalette
command opens a floating window displaying the palette colors, listed in ascending order of brightness -
You can use colors from
nvim-xresources
in other parts of your config. In the following example, I usenvim-xresources
colors in nvim-lilypond-suite config :
local C = require('nvim-xresources.colors')
require('nvls').setup({
lilypond = {
highlights = {
lilyVar = {
fg = C.blue
}
},
},
})