-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftp.vim
78 lines (66 loc) · 1.83 KB
/
ftp.vim
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
" Vim script
" Author: Aliao
" Last Change: April 25, 2013
" URL:
" Don't load the plug-in when &compatible is set or it was already loaded.
if &cp || exists('g:ftp_plugin')
finish
endif
map <S-A-d> :call UploadFile()<CR>
let g:plugin_dir = expand("<sfile>")
function! UploadFile()
let g:cur_file = CurFile()
let g:cur_dir = getcwd()
python << EOF
import vim
cur_file = vim.eval("g:cur_file")
cur_dir= vim.eval("g:cur_dir")
#print cur_file
#print cur_dir
import os
import sys
plugin_dir = os.path.dirname(vim.eval("g:plugin_dir"))
plugin_dir_old = os.getcwd()
path = cur_dir #"E:/work/freemerce/project/python/crawler/lfy/ftp/"
path = os.path.abspath(os.path.join("./", path))
fname = cur_file # "E:/work/freemerce/project/python/crawler/lfy/ftp/1.txt"
fname = os.path.abspath(os.path.join("./", fname))
os.chdir(plugin_dir)
sys.path.append(plugin_dir + "/ftp")
from manager import Manager
mgr = Manager(path)
mgr.uploadfile(fname)
os.chdir(plugin_dir_old)
EOF
endfunction
function! DownloadFile()
let g:cur_file = CurFile()
let g:cur_dir = getcwd()
python << EOF
import vim
cur_file = vim.eval("g:cur_file")
cur_dir= vim.eval("g:cur_dir")
#print cur_file
#print cur_dir
import os
import sys
plugin_dir = os.path.dirname(vim.eval("g:plugin_dir"))
plugin_dir_old = os.getcwd()
path = cur_dir #"E:/work/freemerce/project/python/crawler/lfy/ftp/"
path = os.path.abspath(os.path.join("./", path))
fname = cur_file # "E:/work/freemerce/project/python/crawler/lfy/ftp/1.txt"
fname = os.path.abspath(os.path.join("./", fname))
os.chdir(plugin_dir)
sys.path.append(plugin_dir + "/ftp")
from manager import Manager
mgr = Manager(path)
mgr.downloadfile(fname)
os.chdir(plugin_dir_old)
EOF
endfunction
function! CurFile()
let curfile = bufname("%")
let curdir = getcwd()
return curdir .'/'. curfile
endfunction
let g:ftp_plugin = 1