From b79c5177caac6810af07cb15e4f6db9324f1f42f Mon Sep 17 00:00:00 2001 From: Matthew Lyon Date: Wed, 3 Sep 2014 22:34:33 -0700 Subject: [PATCH] Disable terminal italics by default, opt-in w/ var Yes, terminal emulation is a ghetto. Why should that surprise you? --- README.markdown | 10 ++++++++++ colors/pencil.vim | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/README.markdown b/README.markdown index 77d9f04..95f2dc9 100644 --- a/README.markdown +++ b/README.markdown @@ -64,6 +64,16 @@ If you’re looking for neutral heading colors, set the following in your let g:pencil_neutral_headings = 1 " 0=blue (def), 1=normal ``` +### Terminal Italics + +If you're using Vim in the terminal and your terminal supports italics, you +can opt-in to italic support for some syntax highlighting, such as comments, +by setting the following in your `.vimrc`: + +``` +let g:pencil_terminal_italics = 1 +``` + ### Airline Theme ![airline-example](http://i.imgur.com/V39pwZq.png) diff --git a/colors/pencil.vim b/colors/pencil.vim index da2c9ba..492c772 100644 --- a/colors/pencil.vim +++ b/colors/pencil.vim @@ -45,6 +45,11 @@ if ! exists("g:pencil_neutral_headings") let g:pencil_neutral_headings = 0 endif +" not all terminals support italics properly. If yours does, opt-in. +if ! exists("g:pencil_terminal_italics") + let g:pencil_terminal_italics = 0 +endif + " Colors let s:black = { "gui": "#212121", "cterm": "0" } let s:medium_gray = { "gui": "#767676", "cterm": "243" } @@ -122,6 +127,10 @@ endif " shamelessly stolen from hemisu: https://github.com/noahfrederick/vim-hemisu/ function! s:h(group, style) + " Not all terminals support italics properly. If yours does, opt-in. + if g:pencil_terminal_italics == 0 && has_key(a:style, "cterm") && a:style["cterm"] == "italic" + unlet a:style.cterm + endif execute "highlight" a:group \ "guifg=" (has_key(a:style, "fg") ? a:style.fg.gui : "NONE") \ "guibg=" (has_key(a:style, "bg") ? a:style.bg.gui : "NONE")