mirror of
https://github.com/neovim/neovim.git
synced 2026-01-04 02:17:09 +10:00
feat(defaults): enable 'termguicolors' by default when supported by terminal
Enable 'termguicolors' automatically when Nvim can detect that truecolor is supported by the host terminal. If $COLORTERM is set to "truecolor" or "24bit", or the terminal's terminfo entry contains capabilities for Tc, RGB, or setrgbf and setrgbb, then we assume that the terminal supports truecolor. Otherwise, the terminal is queried (using both XTGETTCAP and SGR + DECRQSS). If the terminal's response to these queries (if any) indicates that it supports truecolor, then 'termguicolors' is enabled.
This commit is contained in:
@@ -6,7 +6,11 @@ if not tty or vim.g.clipboard ~= nil or vim.o.clipboard ~= '' or not os.getenv('
|
||||
return
|
||||
end
|
||||
|
||||
require('vim.termcap').query('Ms', function(cap, seq)
|
||||
require('vim.termcap').query('Ms', function(cap, found, seq)
|
||||
if not found then
|
||||
return
|
||||
end
|
||||
|
||||
assert(cap == 'Ms')
|
||||
|
||||
-- Check 'clipboard' and g:clipboard again to avoid a race condition
|
||||
@@ -16,7 +20,7 @@ require('vim.termcap').query('Ms', function(cap, seq)
|
||||
|
||||
-- If the terminal reports a sequence other than OSC 52 for the Ms capability
|
||||
-- then ignore it. We only support OSC 52 (for now)
|
||||
if not seq:match('^\027%]52') then
|
||||
if not seq or not seq:match('^\027%]52') then
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user