fixed 16-color detection
This commit is contained in:
1 parent
6b5fb50091
commit
9722813a9d
5 files changed
+36
-2
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user