diff --git a/dotfiles/.py3.vimrc b/dotfiles/.py3.vimrc index 9ce4a8d..2d3b2d5 100644 --- a/dotfiles/.py3.vimrc +++ b/dotfiles/.py3.vimrc @@ -33,10 +33,50 @@ def f5_1(pattern, flags, info): #print([pattern, flags, info]) completed_process = None + options = dict( + recursive=False, + ext=[], + ) + + #print('fuck') + if b'r' in flags: + while True: + ext_m = re.compile('^.([^\,]+),(.*)$').match(pattern) + + if pattern[:3] in [r'\r,']: + options['recursive'] = True + pattern = pattern[3:] + elif not ext_m is None: + options['ext'].append( + ext_m[1] + ) + pattern = ext_m[2] + else: + break + + print([flags, pattern, options,]) + try: - completed_process = subprocess.run([ - 'git', 'grep', '-n', '-P', pattern, - ], capture_output=True,) + git_cmd = [ + 'git', 'grep', + '-n', + ] + + if options['recursive']: + git_cmd.append('--recurse-submodules') + + git_cmd.extend(['-P', pattern]) + + if len(options['ext']) > 0: + git_cmd.extend(['--', *[ + '**/*%s' % o + for o in options['ext'] + ]]) + + completed_process = subprocess.run( + git_cmd, + capture_output=True, + ) assert ( completed_process.returncode == 0 or (