fixed 16-color detection

This commit is contained in:
2026-08-09 11:39:56 -05:00
parent 6b5fb50091
commit 9722813a9d
5 changed files with 36 additions and 2 deletions
+2
View File
@@ -22,6 +22,8 @@ local utils = require("darcula.utils")
NV_DARCULA_COLOR_COLUMN = utils.parse_env("NV_DARCULA_COLOR_COLUMN", "80")
NV_DARCULA_COLOR_SCHEME =
utils.parse_env("NV_DARCULA_COLOR_SCHEME", "darcula_lush")
NV_DARCULA_TERMGUI_COLORS =
utils.parse_env("NV_DARCULA_TERMGUI_COLORS", utils.detect_termguicolors())
NV_DARCULA_ENABLE_COC = utils.parse_env("NV_DARCULA_ENABLE_COC", true)
NV_DARCULA_ENABLE_CODE_LENS =
utils.parse_env("NV_DARCULA_ENABLE_CODE_LENS", false)
+1 -1
View File
@@ -101,7 +101,7 @@ vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.syntax = "enable"
vim.opt.tabstop = 2
vim.opt.termguicolors = true
vim.opt.termguicolors = NV_DARCULA_TERMGUI_COLORS
vim.opt.undodir = vim.fs.joinpath(vim.fn.stdpath("data"), ".undo")
vim.opt.undofile = true
vim.opt.updatetime = 250
+3
View File
@@ -19,6 +19,9 @@
--
require("darcula.config")
-- The colorscheme is loaded from this module, before darcula.options.
vim.opt.termguicolors = NV_DARCULA_TERMGUI_COLORS
vim.api.nvim_create_autocmd(
"PackChanged",
{
-1
View File
@@ -69,7 +69,6 @@ require("telescope").setup {
borderchars = {" ", " ", " ", " ", " ", " ", " ", " "},
color_devicons = true,
use_less = true,
set_env = {["COLORTERM"] = "truecolor"}, -- default = nil,
file_previewer = require "telescope.previewers".vim_buffer_cat.new,
grep_previewer = require "telescope.previewers".vim_buffer_vimgrep.new,
qflist_previewer = require "telescope.previewers".vim_buffer_qflist.new,
+30
View File
@@ -156,6 +156,35 @@ local function iff(b, l, r)
return r
end
local detect_termguicolors = function()
local term = (vim.env.TERM or ""):lower()
if term == "ansi" or
term == "cons25" or
term == "dumb" or
term == "linux" or
term:match("^vt%d+$") or
term:find("16color", 1, true) then
return false
end
local colorterm = (vim.env.COLORTERM or ""):lower()
if colorterm == "24bit" or colorterm == "truecolor" then
return true
end
if vim.fn.executable("tput") == 1 then
local output = vim.fn.system({"tput", "colors"})
if vim.v.shell_error == 0 then
local color_count = tonumber(output:match("%d+"))
if color_count and color_count <= 16 then
return false
end
end
end
return true
end
local parse_env = function(var, def)
if vim.env[var] ~= nil then
if type(def) == "boolean" then
@@ -222,6 +251,7 @@ return {
copy_file = copy_file,
create_vert_display = create_vert_display,
cword = cword,
detect_termguicolors = detect_termguicolors,
file_exists = file_exists,
get_current_filename = get_current_filename,
get_files_sorted_without_extension = get_files_sorted_without_extension,