# HG changeset patch # User Ludovic Chabant # Date 1541296673 25200 # Sat Nov 03 18:57:53 2018 -0700 # Node ID 62af332fbf4a75804bda5831768fd11d49dce924 # Parent 4aedee2ce4760c8248894194e5203ec76b82aa01 Add options completion for `Hglog` and `Hglogthis`. diff --git a/autoload/lawrencium/log.vim b/autoload/lawrencium/log.vim --- a/autoload/lawrencium/log.vim +++ b/autoload/lawrencium/log.vim @@ -1,9 +1,9 @@ function! lawrencium#log#init() abort - call lawrencium#add_command("-nargs=* Hglogthis :call lawrencium#log#HgLog(0, '%:p', )") - call lawrencium#add_command("-nargs=* Hgvlogthis :call lawrencium#log#HgLog(1, '%:p', )") - call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#list_repo_files Hglog :call lawrencium#log#HgLog(0, )") - call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#list_repo_files Hgvlog :call lawrencium#log#HgLog(1, )") + call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_logthis_options Hglogthis :call lawrencium#log#HgLog(0, '%:p', )") + call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_logthis_options Hgvlogthis :call lawrencium#log#HgLog(1, '%:p', )") + call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_log_options Hglog :call lawrencium#log#HgLog(0, )") + call lawrencium#add_command("-nargs=* -complete=customlist,lawrencium#log#list_log_options Hgvlog :call lawrencium#log#HgLog(1, )") call lawrencium#add_reader("log", "lawrencium#log#read") call lawrencium#add_reader("logpatch", "lawrencium#log#read_patch") @@ -34,6 +34,24 @@ setlocal filetype=diff endfunction +function! lawrencium#log#list_logthis_options(ArgLead, CmdLine, CursorPos) abort + if exists('g:lawrencium_hg_commands') + let l:log_options = copy(g:lawrencium_hg_commands['log']) + return filter(l:log_options, "v:val[0:strlen(a:ArgLead)-1] ==# a:ArgLead") + else + return [] + endif +endfunction + +function! lawrencium#log#list_log_options(ArgLead, CmdLine, CursorPos) abort + let l:res = lawrencium#list_repo_files(a:ArgLead, a:CmdLine, a:CursorPos) + if exists('g:lawrencium_hg_commands') && strcharpart(a:ArgLead, 0, 1) == '-' + let l:log_options = copy(g:lawrencium_hg_commands['log']) + let l:res += filter(l:log_options, "v:val[0:strlen(a:ArgLead)-1] ==# a:ArgLead") + endif + return l:res +endfunction + function! lawrencium#log#HgLog(vertical, ...) abort " Get the file or directory to get the log from. " (empty string is for the whole repository)