commit: a8e4f9297a38b3a0465b29aca32f14ce88720aa9 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Jan 26 09:56:59 2022 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Thu Feb 3 08:36:47 2022 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-syntax.git/commit/?id=a8e4f929
gentoo-common: Support collapsing PYTHON_COMPAT into {x..y} Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> plugin/gentoo-common.vim | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/plugin/gentoo-common.vim b/plugin/gentoo-common.vim index 306542e..bc4da76 100644 --- a/plugin/gentoo-common.vim +++ b/plugin/gentoo-common.vim @@ -80,22 +80,40 @@ fun! GentooGetPythonTargets() endfor let l:impls = [] if len(l:py3s) ==# 1 - let l:impls = l:impls->add("python3.".l:py3s->join()) + let l:impls = l:impls->add("python3_".l:py3s->join()) elseif len(l:py3s) > 1 - let l:impls = l:impls->add("python3.{".l:py3s->sort('N') - \ ->join(",")."}") + let l:min = "" + let l:max = "" + let l:py3s = l:py3s->sort('N') + for l:py in l:py3s + if l:min ==# "" + let l:min = l:py + let l:max = l:py + elseif l:py ==# l:max + 1 + let l:max = l:py + else + let l:max = "" + break + endif + endfor + + if l:max !=# "" + let l:impls = l:impls->add("python3_{".l:min.".." + \ .l:max."}") + else + let l:impls = l:impls->add("python3_{".l:py3s + \ ->join(",")."}") + endif endif let l:py3 = flatten(l:impls->add(l:others))->join() endif if empty(l:py3) let l:py3 = \ system("python -c 'import epython; print(epython.EPYTHON)'") - \ ->substitute("\n", "", "g") + \ ->substitute("\n", "", "g")->substitute("[.]", "_", "g") endif - let l:pythons = substitute(l:py3, "[.]", "_", "g") - - let g:gentoopythontargets = l:pythons + let g:gentoopythontargets = l:py3 return g:gentoopythontargets endif endfun