From e5f09746562ef0226d3484a01609ceca41700a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1vio=20Carlos=20Martins=20Costa?= Date: Sat, 23 Oct 2021 14:10:37 -0300 Subject: [PATCH] Add option to set full special attributes support (#267) * add option to set full special attributes support This is useful to inform Dracula that the current UI has full support for special attributes like underlines and undercurls, as by default it assumes no terminal emulator have such support. The default value falls back to the current behavior, assuming only graphical interfaces have full support. Fix #266 * fix grammar issues Co-authored-by: D. Ben Knoble * add documentation for the new option Co-authored-by: D. Ben Knoble --- colors/dracula.vim | 15 ++++++++++++--- doc/dracula.txt | 9 ++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/colors/dracula.vim b/colors/dracula.vim index 8c94110..224d5a6 100644 --- a/colors/dracula.vim +++ b/colors/dracula.vim @@ -85,6 +85,10 @@ if !exists('g:dracula_undercurl') let g:dracula_undercurl = g:dracula_underline endif +if !exists('g:dracula_full_special_attrs_support') + let g:dracula_full_special_attrs_support = has('gui_running') +endif + if !exists('g:dracula_inverse') let g:dracula_inverse = 1 endif @@ -111,10 +115,15 @@ function! s:h(scope, fg, ...) " bg, attr_list, special let l:attr_list = filter(get(a:, 2, ['NONE']), 'type(v:val) == 1') let l:attrs = len(l:attr_list) > 0 ? join(l:attr_list, ',') : 'NONE' - " Falls back to coloring foreground group on terminals because - " nearly all do not support undercurl + " If the UI does not have full support for special attributes (like underline and + " undercurl) and the highlight does not explicitly set the foreground color, + " make the foreground the same as the attribute color to ensure the user will + " get some highlight if the attribute is not supported. The default behavior + " is to assume that terminals do not have full support, but the user can set + " the global variable `g:dracula_full_special_attrs_support` explicitly if the + " default behavior is not desirable. let l:special = get(a:, 3, ['NONE', 'NONE']) - if l:special[0] !=# 'NONE' && l:fg[0] ==# 'NONE' && !has('gui_running') + if l:special[0] !=# 'NONE' && l:fg[0] ==# 'NONE' && !g:dracula_full_special_attrs_support let l:fg[0] = l:special[0] let l:fg[1] = l:special[1] endif diff --git a/doc/dracula.txt b/doc/dracula.txt index b60abb4..9becf93 100644 --- a/doc/dracula.txt +++ b/doc/dracula.txt @@ -1,4 +1,4 @@ -*dracula.txt* For Vim version 8 Last change: 2018 May 08 +*dracula.txt* For Vim version 8 Last change: 2021 Oct 22 *dracula* *vim-dracula* |\ ,, ~ @@ -86,6 +86,13 @@ Include underline attributes in highlighting > Include undercurl attributes in highlighting (only if underline enabled) > let g:dracula_undercurl = 1 +* *g:dracula_full_special_attrs_support* +Explicitly declare full support for special attributes. By default it is 1 +for graphical applications and 0 for terminals and terminal emulators. On +terminal emulators, set to 1 to allow underline/undercurl highlights without +changing the foreground color. > + let g:dracula_full_special_attrs_support = 1 + * *g:dracula_inverse* Include inverse attributes in highlighting > let g:dracula_inverse = 1