Ver código fonte

Add highlighting for section headers

Marco Hinz 12 anos atrás
pai
commit
b7fe86e492
2 arquivos alterados com 24 adições e 8 exclusões
  1. 23 8
      autoload/startify.vim
  2. 1 0
      syntax/startify.vim

+ 23 - 8
autoload/startify.vim

@@ -32,6 +32,8 @@ else
         \ ]
         \ ]
 endif
 endif
 
 
+let s:section_header_lines = []
+
 " Init: autocmds {{{1
 " Init: autocmds {{{1
 
 
 if get(g:, 'startify_session_persistence')
 if get(g:, 'startify_session_persistence')
@@ -92,7 +94,6 @@ function! startify#insane_in_the_membrane() abort
   for item in s:lists
   for item in s:lists
     if type(item) == 1
     if type(item) == 1
       let cnt = s:show_{item}(cnt)
       let cnt = s:show_{item}(cnt)
-      "unlet s:
     else
     else
       let s:last_message = item
       let s:last_message = item
     endif
     endif
@@ -101,6 +102,10 @@ function! startify#insane_in_the_membrane() abort
 
 
   silent $delete
   silent $delete
 
 
+  for item in s:section_header_lines
+    call matchadd('StartifySection', '\%'. item .'l', -1)
+  endfor
+
   if s:show_special
   if s:show_special
     call append('$', ['', '   [q]  <quit>'])
     call append('$', ['', '   [q]  <quit>'])
   endif
   endif
@@ -256,8 +261,7 @@ function! s:show_dir(cnt) abort
 
 
   if !empty(files)
   if !empty(files)
     if exists('s:last_message')
     if exists('s:last_message')
-      call append('$', s:last_message)
-      unlet s:last_message
+      call s:print_section_header()
     endif
     endif
 
 
     function! l:compare(x, y)
     function! l:compare(x, y)
@@ -295,8 +299,7 @@ function! s:show_files(cnt) abort
 
 
   if !empty(v:oldfiles)
   if !empty(v:oldfiles)
     if exists('s:last_message')
     if exists('s:last_message')
-      call append('$', s:last_message)
-      unlet s:last_message
+      call s:print_section_header()
     endif
     endif
 
 
     for fname in v:oldfiles
     for fname in v:oldfiles
@@ -344,7 +347,7 @@ function! s:show_sessions(cnt) abort
   let cnt = a:cnt
   let cnt = a:cnt
 
 
   if exists('s:last_message')
   if exists('s:last_message')
-    call append('$', s:last_message)
+    call s:print_section_header()
   endif
   endif
 
 
   for i in range(slen)
   for i in range(slen)
@@ -366,8 +369,7 @@ function! s:show_bookmarks(cnt) abort
 
 
   if exists('g:startify_bookmarks')
   if exists('g:startify_bookmarks')
     if exists('s:last_message')
     if exists('s:last_message')
-      call append('$', s:last_message)
-      unlet s:last_message
+      call s:print_section_header()
     endif
     endif
 
 
     for fname in g:startify_bookmarks
     for fname in g:startify_bookmarks
@@ -578,3 +580,16 @@ function! s:session_write(spath)
     silent hide
     silent hide
   endif
   endif
 endfunction
 endfunction
+
+" Function: s:print_section_header {{{1
+function! s:print_section_header() abort
+  $
+  let curline = line('.')
+
+  for lnum in range(curline, curline + len(s:last_message))
+    call add(s:section_header_lines, lnum)
+  endfor
+
+  call append('$', s:last_message)
+  unlet s:last_message
+endfunction

+ 1 - 0
syntax/startify.vim

@@ -34,5 +34,6 @@ endif
 highlight default link StartifyHeader  Normal
 highlight default link StartifyHeader  Normal
 highlight default link StartifyBracket Delimiter
 highlight default link StartifyBracket Delimiter
 highlight default link StartifyNumber  Number
 highlight default link StartifyNumber  Number
+highlight default link StartifySection Special
 
 
 let b:current_syntax = 'startify'
 let b:current_syntax = 'startify'