comparison autoload/lawrencium/log.vim @ 144:62af332fbf4a

Add options completion for `Hglog` and `Hglogthis`.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 03 Nov 2018 18:57:53 -0700
parents 4aedee2ce476
children
comparison
equal deleted inserted replaced
143:4aedee2ce476 144:62af332fbf4a
1 1
2 function! lawrencium#log#init() abort 2 function! lawrencium#log#init() abort
3 call lawrencium#add_command("-nargs=* Hglogthis :call lawrencium#log#HgLog(0, '%:p', <f-args>)") 3 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_logthis_options Hglogthis :call lawrencium#log#HgLog(0, '%:p', <f-args>)")
4 call lawrencium#add_command("-nargs=* Hgvlogthis :call lawrencium#log#HgLog(1, '%:p', <f-args>)") 4 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_logthis_options Hgvlogthis :call lawrencium#log#HgLog(1, '%:p', <f-args>)")
5 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#list_repo_files Hglog :call lawrencium#log#HgLog(0, <f-args>)") 5 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_log_options Hglog :call lawrencium#log#HgLog(0, <f-args>)")
6 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#list_repo_files Hgvlog :call lawrencium#log#HgLog(1, <f-args>)") 6 call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_log_options Hgvlog :call lawrencium#log#HgLog(1, <f-args>)")
7 7
8 call lawrencium#add_reader("log", "lawrencium#log#read") 8 call lawrencium#add_reader("log", "lawrencium#log#read")
9 call lawrencium#add_reader("logpatch", "lawrencium#log#read_patch") 9 call lawrencium#add_reader("logpatch", "lawrencium#log#read_patch")
10 endfunction 10 endfunction
11 11
30 call a:repo.ReadCommandOutput(l:log_cmd) 30 call a:repo.ReadCommandOutput(l:log_cmd)
31 else 31 else
32 call a:repo.ReadCommandOutput(l:log_cmd, a:full_path) 32 call a:repo.ReadCommandOutput(l:log_cmd, a:full_path)
33 endif 33 endif
34 setlocal filetype=diff 34 setlocal filetype=diff
35 endfunction
36
37 function! lawrencium#log#list_logthis_options(ArgLead, CmdLine, CursorPos) abort
38 if exists('g:lawrencium_hg_commands')
39 let l:log_options = copy(g:lawrencium_hg_commands['log'])
40 return filter(l:log_options, "v:val[0:strlen(a:ArgLead)-1] ==# a:ArgLead")
41 else
42 return []
43 endif
44 endfunction
45
46 function! lawrencium#log#list_log_options(ArgLead, CmdLine, CursorPos) abort
47 let l:res = lawrencium#list_repo_files(a:ArgLead, a:CmdLine, a:CursorPos)
48 if exists('g:lawrencium_hg_commands') && strcharpart(a:ArgLead, 0, 1) == '-'
49 let l:log_options = copy(g:lawrencium_hg_commands['log'])
50 let l:res += filter(l:log_options, "v:val[0:strlen(a:ArgLead)-1] ==# a:ArgLead")
51 endif
52 return l:res
35 endfunction 53 endfunction
36 54
37 function! lawrencium#log#HgLog(vertical, ...) abort 55 function! lawrencium#log#HgLog(vertical, ...) abort
38 " Get the file or directory to get the log from. 56 " Get the file or directory to get the log from.
39 " (empty string is for the whole repository) 57 " (empty string is for the whole repository)