Просмотр исходного кода

Add highlighting for section headers

Marco Hinz 12 лет назад
Родитель
Сommit
b7fe86e492
2 измененных файлов с 24 добавлено и 8 удалено
  1. 23 8
      autoload/startify.vim
  2. 1 0
      syntax/startify.vim

+ 23 - 8
autoload/startify.vim

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