aboutsummaryrefslogtreecommitdiff
path: root/runtime/plugin/osc52.lua
diff options
context:
space:
mode:
authorGregory Anders <greg@gpanders.com>2023-12-05 10:01:32 -0800
committerGregory Anders <greg@gpanders.com>2023-12-06 07:57:09 -0800
commit2613ba5000d4c0d9b15e2eec2d2b97615575925e (patch)
tree7fde88589dbf7e5e30130ae65cdb6a9df2e61ccb /runtime/plugin/osc52.lua
parent5b40a1c09dda83275784053b325ad16626fc55f2 (diff)
downloadrneovim-2613ba5000d4c0d9b15e2eec2d2b97615575925e.tar.gz
rneovim-2613ba5000d4c0d9b15e2eec2d2b97615575925e.tar.bz2
rneovim-2613ba5000d4c0d9b15e2eec2d2b97615575925e.zip
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.
Diffstat (limited to 'runtime/plugin/osc52.lua')
-rw-r--r--runtime/plugin/osc52.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/runtime/plugin/osc52.lua b/runtime/plugin/osc52.lua
index 374b70066f..7a90518966 100644
--- a/runtime/plugin/osc52.lua
+++ b/runtime/plugin/osc52.lua
@@ -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