From bcab4d109662b735fa599d45db8c2da98fd05772 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Mon, 13 Dec 2021 16:08:23 +0300 Subject: [PATCH] Rewrite testname on pure vimscript --- .../py-testname/autoload/python/testname.vim | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim b/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim index 9cc598b..66610dc 100644 --- a/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim +++ b/vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim @@ -7,16 +7,13 @@ " copied to clipboard ("*) register. function! python#testname#get() abort - normal mm - normal ?.*\s*def .*[Tt]est - normal ^f(Byw - let postfix = @" - normal [[f(Byw - let postfix = @" . "." . postfix - normal `m - let base = join([""] + split(getcwd(), "/")[:-1], "/") - let prefix = substitute(expand("%:p:r")[len(base)+1:], "/", ".", "g") - let name = prefix . ":" . postfix - let @* = name - echomsg name + let l:pos = getpos(".") + let l:postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[:-2] + let l:postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[:-2] . "." . l:postfix + call setpos(".", l:pos) + let l:base = join([""] + split(getcwd(), "/")[:-1], "/") + let l:prefix = substitute(expand("%:p:r")[len(l:base)+1:], "/", ".", "g") + let l:name = l:prefix . ":" . l:postfix + let @* = l:name + echomsg l:name endfunction -- 2.44.0