]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim
Move to vim9script
[dotfiles.git] / vim / .vim / pack / stargrave / start / py-testname / autoload / python / testname.vim
index 66610dc83321bdaeabe46cefb6caf76020865392..921321a54aa933a7a6ffba031c5a228dbb9d65e8 100644 (file)
@@ -1,19 +1,21 @@
-" Nose-compatible test name preparer
-" Maintainer: Sergey Matveev <stargrave@stargrave.org>
-" License: GNU General Public License version 3 of the License or later
-"
-" When standing inside TestCase's test method, type <leader>t and full
-" Python (your.project.tests:TestCaseName.test_method_name) path will be
-" copied to clipboard ("*) register.
+vim9script
 
-function! python#testname#get() abort
-    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
+# Nose-compatible test name preparer
+# Maintainer: Sergey Matveev <stargrave@stargrave.org>
+# License: GNU General Public License version 3 of the License or later
+#
+# When standing inside TestCase's test method, type <leader>t and full
+# Python (your.project.tests:TestCaseName.test_method_name) path will be
+# copied to clipboard ("*) register.
+
+export def Get()
+    var pos = getpos(".")
+    var postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[: -2]
+    postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[: -2] .. "." .. postfix
+    setpos(".", pos)
+    var base = join([""] + split(getcwd(), "/")[: -1], "/")
+    var prefix = substitute(expand("%:p:r")[len(base) + 1 :], "/", ".", "g")
+    var name = prefix .. ":" .. postfix
+    @* = name
+    echomsg name
+enddef