]> git.wincent.com - pinnacle.git/commitdiff
feat: teach pinnacle#decorate() to accept a comma-separated list
authorGreg Hurrell <greg.hurrell@liferay.com>
Wed, 6 May 2020 18:10:50 +0000 (20:10 +0200)
committerGreg Hurrell <greg.hurrell@liferay.com>
Wed, 6 May 2020 18:10:50 +0000 (20:10 +0200)
Incidentally, first time I've tried running docvim on this machine, and
I couldn't get any of the old build or install methods working, due to
bit rot:

    git clone ...
    cd docvim
    brew install stack # didn't have stack on this machine
    stack build # build fails
    stack install docvim # install fails
    cabal install docvim # install fails
    cabal v2-build # victory!

After that I could do the actual doc-gen with:

    ./dist-newstyle/build/x86_64-osx/ghc-8.4.4/docvim-0.3.2.1/x/docvim/build/docvim/docvim \
      -c ~/code/pinnacle \
      -v \
      ~/code/pinnacle/doc/pinnacle.txt \
      ~/code/pinnacle/README.md

README.md
autoload/pinnacle.vim
doc/pinnacle.txt

index db658fefcf675d591bd63d6dbacd79ea189aeac4..850f88faa69d8e5e3fe1490f35cf7f6de39deda9 100644 (file)
--- a/README.md
+++ b/README.md
@@ -113,6 +113,8 @@ Returns an underlined copy of `group` suitable for passing to `:highlight`.
 
 Returns a copy of `group` decorated with `style` (eg. &quot;bold&quot;, &quot;italic&quot; etc) suitable for passing to `:highlight`.
 
+To decorate with multiple styles, `style` should be a comma-separated list.
+
 
 ## Website<a name="pinnacle-website" href="#user-content-pinnacle-website"></a>
 
@@ -197,6 +199,11 @@ Other contributors that have submitted patches include (in alphabetical order):
 ## History<a name="pinnacle-history" href="#user-content-pinnacle-history"></a>
 
 
+### master (not yet released)<a name="pinnacle-master-not-yet-released" href="#user-content-pinnacle-master-not-yet-released"></a>
+
+- Teach `pinnacle#decorate()` to accept a comma-separated list of styles.
+
+
 ### 1.0 (6 March 2019)<a name="pinnacle-10-6-march-2019" href="#user-content-pinnacle-10-6-march-2019"></a>
 
 - Added `pinnacle#dump()`.
index 0a0c9625300ba54dc18abe335aa0218b89071ad2..8031ce8d9bc974cca3d899be360bad920da9bdf4 100644 (file)
 "
 " # History
 "
+" ## master (not yet released)
+"
+" - Teach `pinnacle#decorate()` to accept a comma-separated list of styles.
+"
 " ## 1.0 (6 March 2019)
 "
 " - Added `pinnacle#dump()`.
@@ -328,6 +332,8 @@ endfunction
 " Returns a copy of `group` decorated with `style` (eg. "bold", "italic" etc)
 " suitable for passing to `:highlight`.
 "
+" To decorate with multiple styles, `style` should be a comma-separated list.
+"
 function! pinnacle#decorate(style, group) abort
   let l:original = pinnacle#extract_highlight(a:group)
 
@@ -347,11 +353,15 @@ function! pinnacle#decorate(style, group) abort
       let l:start = l:matches[1]
       let l:value = l:matches[2]
       let l:end = l:matches[3]
-      if l:value =~# '.*' . a:style . '.*'
-        continue
-      else
-        let l:original = l:start . l:value . ',' . a:style . l:end
-      endif
+      for l:style in split(a:style, ',')
+        let l:trimmed=trim(l:style)
+        if l:value =~# '\<' . l:trimmed . '\>'
+          continue
+        else
+          let l:value .= ',' . l:trimmed
+        endif
+      endfor
+      let l:original = l:start . l:value . l:end
     endif
   endfor
 
index 915323bc532e721cca77a257924b127628173de3..3497661491737d0af09e1ace2cf3fb21887f5c67 100644 (file)
@@ -110,6 +110,8 @@ pinnacle#decorate() ~
 Returns a copy of `group` decorated with `style` (eg. "bold", "italic" etc)
 suitable for passing to `:highlight`.
 
+To decorate with multiple styles, `style` should be a comma-separated list.
+
 WEBSITE                                                       *pinnacle-website*
 
 The official Pinnacle source code repo is at:
@@ -192,6 +194,10 @@ order):
 
 HISTORY                                                       *pinnacle-history*
 
+master (not yet released) ~
+
+- Teach `pinnacle#decorate()` to accept a comma-separated list of styles.
+
 1.0 (6 March 2019) ~
 
 - Added `pinnacle#dump()`.