]> git.wincent.com - pinnacle.git/blobdiff - autoload/pinnacle.vim
Prefer underline over undercurl
[pinnacle.git] / autoload / pinnacle.vim
index 565bda9ea4a76c2d5819ed329c95f1a9385d2639..620a39aac97888fb26737283fea71f4fbfadd769 100644 (file)
@@ -13,7 +13,7 @@
 " If you don't have a "plug-in management system of choice", I recommend
 " Pathogen (https://github.com/tpope/vim-pathogen) due to its simplicity and
 " robustness. Assuming that you have Pathogen installed and configured, and that
-" you want to install vim-docvim into `~/.vim/bundle`, you can do so with:
+" you want to install Pinnacle into `~/.vim/bundle`, you can do so with:
 "
 " ```
 " git clone https://github.com/wincent/pinnacle.git ~/.vim/bundle/pinnacle
@@ -48,7 +48,7 @@
 "
 " Official releases are listed at:
 "
-"   http://www.vim.org/scripts/script.php?script_id=[TODO]
+"   http://www.vim.org/scripts/script.php?script_id=5360
 "
 "
 " # License
 " - Produce the release archive:
 "
 " ```
-" git archive -o vim-docvim-$VERSION.zip HEAD -- .
+" git archive -o pinnacle-$VERSION.zip HEAD -- .
 " ```
 "
-" - Upload to http://www.vim.org/scripts/script.php?script_id=[TODO]
+" - Upload to http://www.vim.org/scripts/script.php?script_id=5360
 "
 "
 " # Authors
 "
 " Pinnacle is written and maintained by Greg Hurrell <greg@hurrell.net>.
 "
+" Other contributors that have submitted patches include (in alphabetical
+" order):
+"
+" - Kyle Poole
+"
 "
 " # History
 "
+" 0.2 (9 January 2016)
+"
+" - Added `pinnacle#underline`.
+"
 " ## 0.1 (30 March 2016)
 "
 " - Initial release.
@@ -167,6 +176,34 @@ function! pinnacle#extract_highlight(group) abort
   return l:original
 endfunction
 
+let s:prefix=has('gui') || has('termguicolors') ? 'gui' : 'cterm'
+
+function! pinnacle#extract_bg(group) abort
+  return pinnacle#extract_component(a:group, 'bg')
+endfunction
+
+function! pinnacle#extract_fg(group) abort
+  return pinnacle#extract_component(a:group, 'fg')
+endfunction
+
+function! pinnacle#extract_component(group, component) abort
+  return synIDattr(synIDtrans(hlID(a:group)), a:component, s:prefix)
+endfunction
+
+function! pinnacle#highlight(highlight) abort
+  let l:result=[]
+  if has_key(a:highlight, 'bg')
+    call insert(l:result, s:prefix . 'bg=' . a:highlight['bg'])
+  endif
+  if has_key(a:highlight, 'fg')
+    call insert(l:result, s:prefix . 'fg=' . a:highlight['fg'])
+  endif
+  if has_key(a:highlight, 'term')
+    call insert(l:result, s:prefix . '=' . a:highlight['term'])
+  endif
+  return join(l:result, ' ')
+endfunction
+
 " Returns an italicized copy of `group` suitable for passing to `:highlight`.
 function! pinnacle#italicize(group) abort
   return pinnacle#decorate('italic', a:group)
@@ -177,6 +214,11 @@ function! pinnacle#embolden(group) abort
   return pinnacle#decorate('bold', a:group)
 endfunction
 
+" Returns an underlined copy of `group` suitable for passing to `:highlight`.
+function! pinnacle#underline(group) abort
+  return pinnacle#decorate('underline', a:group)
+endfunction
+
 " Returns a copy of `group` decorated with `style` (eg. "bold", "italic" etc)
 " suitable for passing to `:highlight`.
 function! pinnacle#decorate(style, group) abort