Mercurial > vim-lawrencium
changeset 53:b7caa6693c39
`Hglog` window improvements:
- Using a better looking Mercurial style file.
- Using syntax highlighting.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 10 Nov 2012 22:53:46 -0800 |
parents | cd0b1cea326c |
children | ec0368535216 |
files | plugin/hglog.vim plugin/lawrencium.vim resources/hg_log.style syntax/hglog.vim |
diffstat | 4 files changed, 60 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugin/hglog.vim Sat Nov 10 22:53:46 2012 -0800 @@ -0,0 +1,20 @@ +" 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
--- a/plugin/lawrencium.vim Sat Nov 10 18:45:44 2012 -0800 +++ b/plugin/lawrencium.vim Sat Nov 10 22:53:46 2012 -0800 @@ -480,7 +480,7 @@ " 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() @@ -866,7 +866,7 @@ 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 @@ -973,6 +973,8 @@ " 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 @@ -981,7 +983,7 @@ " 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. @@ -997,7 +999,7 @@ 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() @@ -1094,7 +1096,7 @@ 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/hg_log.style Sat Nov 10 22:53:46 2012 -0800 @@ -0,0 +1,8 @@ +changeset = '{rev}:{node|short}{bookmarks}{tags} {desc|firstline} (by {author|user}, {date|localdate|age})\n' + +start_bookmarks = ' ' +bookmark = '+{bookmark}' + +start_tags = ' ' +tag = '#{tag}' +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/syntax/hglog.vim Sat Nov 10 22:53:46 2012 -0800 @@ -0,0 +1,25 @@ +" 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