Commits

Ludovic Chabant  committed b7caa66

`Hglog` window improvements:
- Using a better looking Mercurial style file.
- Using syntax highlighting.

  • Participants
  • Parent commits cd0b1ce

Comments (0)

Files changed (4)

File plugin/hglog.vim

+" Vim filetype plugin file
+" Language:     hg log output
+" Maintainer:   Ludovic Chabant <ludovic@chabant.com>
+
+if exists("b:did_ftplugin")
+  finish
+endif
+let b:did_ftplugin = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+let b:undo_ftplugin = "setlocal cole< cocu<"
+
+if has("conceal")
+    setlocal cole=2 cocu=nc
+endif
+
+let &cpo = s:cpo_save
+unlet s:cpo_save

File plugin/lawrencium.vim

     " to it.
     let b:mercurial_dir = l:repo.root_dir
     setlocal buftype=nofile
-    setlocal syntax=hgstatus
+    setlocal filetype=hgstatus
 
     " Make commands available.
     call s:DefineMainCommands()
     let b:mercurial_dir = l:repo.root_dir
     let b:lawrencium_commit_files = l:filenames
     setlocal bufhidden=delete
-    setlocal syntax=hgcommit
+    setlocal filetype=hgcommit
     if a:bang
         autocmd BufDelete <buffer> call s:HgCommit_Execute(expand('<afile>:p'), 0)
     else
 
 " Hglog {{{
 
+let s:log_style_file = expand("<sfile>:h:h") . "/resources/hg_log.style"
+
 function! s:HgLog(...) abort
     let l:filepath = expand('%:p')
     if a:0 == 1
 
     " Get the repo and run the command.
     let l:repo = s:hg_repo()
-    let l:output = l:repo.RunCommand('log', l:filepath, '--template', '"{rev}\t{desc|firstline}\n"')
+    let l:output = l:repo.RunCommand('log', '--style', shellescape(s:log_style_file), l:filepath)
 
     " Open a new temp buffer in the preview window, jump to it,
     " and paste the `hg log` output in there.
     let b:mercurial_logged_file = l:filepath
     setlocal bufhidden=delete
     setlocal buftype=nofile
-    setlocal syntax=hglog
+    setlocal filetype=hglog
 
     " Make commands available.
     call s:DefineMainCommands()
         let l:line = getline('.')
     endif
     " Behold, Vim's look-ahead regex syntax again! WTF.
-    let l:rev = matchstr(l:line, '\v^(\d+)(\s)@=')
+    let l:rev = matchstr(l:line, '\v^(\d+)(\:)@=')
     if l:rev == ''
         call s:throw("Can't parse revision number from line: " . l:line)
     endif

File resources/hg_log.style

+changeset = '{rev}:{node|short}{bookmarks}{tags} {desc|firstline} (by {author|user}, {date|localdate|age})\n'
+
+start_bookmarks = ' '
+bookmark = '+{bookmark}'
+
+start_tags = ' '
+tag = '#{tag}'
+

File syntax/hglog.vim

+" Vim syntax file
+" Language:    hg log output
+" Maintainer:  Ludovic Chabant <ludovic@chabant.com>
+" Filenames:   <none>
+
+if exists("b:current_syntax")
+    finish
+endif
+
+syn case match
+
+syn match hglogRev              '\v^[0-9]+'
+syn match hglogNode             '\v:[a-f0-9]{6,} 'hs=s+1,me=e-1
+syn match hglogBookmark         '\v \+[^ ]+ 'ms=s+1,me=e-1 contains=hglogBookmarkPlus
+syn match hglogTag              '\v #[^ ]+ 'ms=s+1,me=e-1 contains=hglogTagSharp
+syn match hglogAuthorAndAge     '\v\(by .+, .+\)$'
+
+syn match hglogBookmarkPlus     '\v\+' contained conceal
+syn match hglogTagSharp         '\v#'  contained conceal
+
+hi def link hglogRev            Identifier
+hi def link hglogNode           PreProc
+hi def link hglogBookmark       Statement
+hi def link hglogTag            Constant
+hi def link hglogAuthorAndAge   Comment