[~] Refactor
This commit is contained in:
parent
445a9b46c3
commit
356c16a009
@ -21,4 +21,56 @@ def f2():
|
|||||||
finally:
|
finally:
|
||||||
for k, v in context.items():
|
for k, v in context.items():
|
||||||
vim.options[k] = v
|
vim.options[k] = v
|
||||||
|
|
||||||
|
def f5_1(pattern, flags, info):
|
||||||
|
import subprocess
|
||||||
|
import io
|
||||||
|
import re
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
#print([pattern, flags, info])
|
||||||
|
t1 = subprocess.check_output([
|
||||||
|
'git', 'grep', '-n', '-P', pattern,
|
||||||
|
], stderr=subprocess.PIPE)
|
||||||
|
def watch(data):
|
||||||
|
with tempfile.NamedTemporaryFile(suffix='.txt') as f:
|
||||||
|
with io.open(f.name, 'wb') as f2:
|
||||||
|
f2.write(data)
|
||||||
|
vim.command('!less %s' % f.name)
|
||||||
|
|
||||||
|
#watch(t1)
|
||||||
|
|
||||||
|
t2 = []
|
||||||
|
for o in t1.splitlines():
|
||||||
|
try:
|
||||||
|
#watch(o.encode('utf-8'))
|
||||||
|
t3 = o.decode('utf-8')
|
||||||
|
t4 = re.compile(r'^([^\:\=]+)[\:\=](\d+)[\:\=](.*)$').match(t3)
|
||||||
|
if not t4 is None:
|
||||||
|
t2.append(
|
||||||
|
dict(
|
||||||
|
name=t4[3].strip(),
|
||||||
|
filename=t4[1],
|
||||||
|
cmd=t4[2],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
#print(t2)
|
||||||
|
|
||||||
|
#return [{'name': 'blah', 'filename': 'docker-compose.yml', 'cmd': '23'}]
|
||||||
|
return t2
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
function F5(pattern, flags, info)
|
||||||
|
let res = py3eval(
|
||||||
|
\'f5_1(
|
||||||
|
\vim.bindeval("a:pattern").decode("utf-8"),
|
||||||
|
\vim.bindeval("a:flags"),
|
||||||
|
\vim.bindeval("a:info")
|
||||||
|
\)'
|
||||||
|
\)
|
||||||
|
return res
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
set tagfunc=F5
|
||||||
|
@ -3,7 +3,6 @@ filetype off
|
|||||||
|
|
||||||
set viminfo+=/1000000,:1000000
|
set viminfo+=/1000000,:1000000
|
||||||
|
|
||||||
|
|
||||||
if has('python3')
|
if has('python3')
|
||||||
source = $HOME . '.py3.vimrmc'
|
source = $HOME . '.py3.vimrmc'
|
||||||
endif
|
endif
|
||||||
@ -46,6 +45,7 @@ map <Leader>i1 :set sw=4 sts=4 ts=4 et ai ci<CR>:retab<CR>
|
|||||||
map <Leader>i2 :set sw=2 sts=2 ts=2 et ai ci<CR>:retab<CR>
|
map <Leader>i2 :set sw=2 sts=2 ts=2 et ai ci<CR>:retab<CR>
|
||||||
map <Leader>i3 :set t_Co=0 so=999<CR>
|
map <Leader>i3 :set t_Co=0 so=999<CR>
|
||||||
map <Leader>i4 :set t_Co=256 so=0<CR>
|
map <Leader>i4 :set t_Co=256 so=0<CR>
|
||||||
|
map <Leader>i5 :set sw=2 sts=2 ts=2 noet ai ci<CR>
|
||||||
set foldmethod=indent
|
set foldmethod=indent
|
||||||
set nofoldenable
|
set nofoldenable
|
||||||
map <Leader>e :e #<cR>
|
map <Leader>e :e #<cR>
|
||||||
|
Loading…
Reference in New Issue
Block a user