termcolors.nvim is a Neovim plugin that will automatically set up a colorscheme
that matches your terminal colors. Most people probably do not need this. If you want
a simpler solution, you can set vim.o.termguicolors = false, adjust your
highlight groups with ctermfg and ctermbg, and be on your way.
However, if you want the benefits of termguicolors but you still like to have your
Neovim color scheme automatically follow your terminal colorscheme, then this plugin
may be of use.
You need a modern terminal emulator that supports OSC sequences. I recommend Ghostty, as it is the fastest one I tested when it comes to querying the terminal colors.
{
"https://gitlab.com/kylesower/termcolors.nvim",
priority = 1000,
lazy = false,
opts = {
-- Specifies whether highlight groups can contain colors derived from main
-- 16 terminal colors. With this option disabled, you will have no
-- visible CursorLine (as it might otherwise blend in with the text).
term_colors_only = true,
-- Between 0 and 1. When term_colors_only is false, specifies the amount
-- to adjust colors to distinguish from background/foreground.
color_adjust_amount = 0.01,
},
}Set the colorscheme:
vim.cmd("colorscheme termcolors")