aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorVadim Misbakh-Soloviov <mva@gentoo.org>2021-12-09 16:12:18 +0700
committerVadim Misbakh-Soloviov <mva@gentoo.org>2021-12-10 18:27:34 +0700
commit2455886f7fde605f081bc5fa95c5735ca89afd2d (patch)
tree0db78b74d44c1c786b829d40bc0d510406341d33 /plugin
parentgentoo-common: Call python instead of eselect-python (diff)
downloadgentoo-syntax-2455886f7fde605f081bc5fa95c5735ca89afd2d.tar.gz
gentoo-syntax-2455886f7fde605f081bc5fa95c5735ca89afd2d.tar.bz2
gentoo-syntax-2455886f7fde605f081bc5fa95c5735ca89afd2d.zip
gentoo-common: try to load pythons from python-exec.conf
Signed-off-by: Vadim Misbakh-Soloviov <mva@gentoo.org>
Diffstat (limited to 'plugin')
-rw-r--r--plugin/gentoo-common.vim28
1 files changed, 26 insertions, 2 deletions
diff --git a/plugin/gentoo-common.vim b/plugin/gentoo-common.vim
index 42b2451..50478ba 100644
--- a/plugin/gentoo-common.vim
+++ b/plugin/gentoo-common.vim
@@ -56,8 +56,32 @@ fun! GentooGetPythonTargets()
if exists("g:gentoopythontargets") && g:gentoopythontargets != ""
return g:gentoopythontargets
else
- let l:py3 = system("python -c 'import epython; print(epython.EPYTHON)'")
- let l:py3 = substitute(l:py3, "\n", "", "g")
+ let l:pyexec_path = "/etc/python-exec/python-exec.conf"
+
+ if filereadable(l:pyexec_path)
+ let l:pys = readfile(l:pyexec_path)->filter("v:val =~ '^[^#-]'")->sort()
+ let l:py3s = []
+ let l:others = []
+ for l:py in l:pys
+ let l:m = l:py->matchstr("^python3.*")->matchstr("\\d*$")
+ if !empty(l:m)
+ eval l:py3s->add(l:m)
+ continue
+ else
+ eval l:others->add(l:py)
+ endif
+ endfor
+ let l:impls = []
+ if len(l:py3s) ==# 1
+ 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(",")."}")
+ 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")
+ endif
let l:pythons = substitute(l:py3, "[.]", "_", "g")