This repository was archived by the owner on Aug 6, 2021. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathpython_support.vim
More file actions
111 lines (93 loc) · 4.07 KB
/
Copy pathpython_support.vim
File metadata and controls
111 lines (93 loc) · 4.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
if !has('nvim')
finish
endif
" command PythonSupport
let s:python2_require = get(g:,'python_support_python2_require',1)
let s:python3_require = get(g:,'python_support_python3_require',1)
let g:python_support_python2_venv = get(g:,'python_support_python2_venv', 1)
let g:python_support_python3_venv = get(g:,'python_support_python3_venv', 1)
let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'pynvim')
let g:python_support_python2_requirements = add(get(g:,'python_support_python2_requirements',[]),'pynvim')
" let g:python_support_python3_requirements = add(get(g:,'python_support_python3_requirements',[]),'flake8')
" let g:python_support_python2_requirements = add(get(g:,'python_support_python2_requirements',[]),'flake8')
com! PythonSupportInitPython2 call s:python_support_init(2)
com! PythonSupportInitPython3 call s:python_support_init(3)
func! s:python_support_init(v)
split
enew
if a:v==2
let l:cmd = [split(globpath(&rtp,'autoload/python2_support.sh'),'\n')[0]] + [g:python_host_prog, g:python_support_python2_venv] + g:python_support_python2_requirements
else
let l:cmd = [split(globpath(&rtp,'autoload/python3_support.sh'),'\n')[0]] + [g:python3_host_prog, g:python_support_python3_venv] + g:python_support_python3_requirements
endif
exec '! ' . join(l:cmd, ' ')
call s:init()
endfunc
func! s:init()
let l:python2 = ""
let l:python3 = ""
if s:python2_require
if g:python_support_python2_venv
silent! let l:python2 = split(globpath(&rtp,'autoload/nvim_py2/bin/python'),'\n')[0]
if l:python2 != ''
let g:python_host_prog = l:python2
else
echom 'python2 venv not initialized by python-support.nvim. Please execute PythonSupportInitPython2'
endif
elseif executable('python2') && get(g:,'python_host_prog','') == ''
let g:python_host_prog = "python2"
elseif get(g:, 'python_host_prog', '') == ''
echom 'python2 executable not found for python_support.vim'
endif
if get(g:, 'python_host_prog', '') != ''
" spawn python process to check requirements 1 second later
call timer_start(1000,function('s:py2requirements'))
endif
endif
if s:python3_require
if g:python_support_python3_venv
silent! let l:python3 = split(globpath(&rtp,'autoload/nvim_py3/bin/python'),'\n')[0]
if l:python3 != ''
let g:python3_host_prog = l:python3
else
echom 'python3 venv not initialized by python-support.nvim. Please execute PythonSupportInitPython3'
endif
elseif executable('python3') && get(g:, 'python3_host_prog', '') == ''
let g:python3_host_prog = 'python3'
elseif get(g:, 'python3_host_prog', '') == ''
echom 'python3 executable not found for python_support.vim'
endif
if get(g:, 'python3_host_prog', '') != ''
" spawn python process to check requirements 1 second later
call timer_start(1000,function('s:py3requirements'))
endif
endif
endfunc
func! s:py2requirements(timer)
if empty(g:python_support_python2_requirements)
" no requirements
return
endif
let l:python = g:python_host_prog
if l:python == ''
let l:python = 'python2'
endif
let l:cmd = [l:python, split(globpath(&rtp,'autoload/python2_check.py'),'\n')[0]] + g:python_support_python2_requirements
call jobstart(l:cmd,{'on_stdout':function('s:on_stdout'), 'on_stderr':function('s:on_stdout')})
endfunc
func! s:py3requirements(timer)
if empty(g:python_support_python3_requirements)
" no requirements
return
endif
let l:python = g:python3_host_prog
if l:python == ''
let l:python = 'python3'
endif
let l:cmd = [l:python, split(globpath(&rtp,'autoload/python3_check.py'),'\n')[0]] + g:python_support_python3_requirements
call jobstart(l:cmd,{'on_stdout':function('s:on_stdout'), 'on_stderr':function('s:on_stdout')})
endfunc
func! s:on_stdout(job_id, data, event)
echom join(a:data,"\n")
endfunc
call s:init()