- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfiddler.vim
More file actions
Latest commit
76 lines (60 loc) · 2.05 KB
/
Copy pathfiddler.vim
File metadata and controls
76 lines (60 loc) · 2.05 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
"command! StartSeleniumClient call StartSeleniumClient()
command! -complete=custom,ListFiddles -nargs=1 OpenFiddle callOpenFiddle('<args>')
command! NewFiddle callNewFiddle()
command! JSLint callJSLint()
nmap<F4>:JSLint<CR>
function!JSLint()
! jslint % | tee /tmp/vimfiddler.jslint
setlocalerrorformat=%-P%f,
\%-G/*jslint\ %.%#*/,
\%*[\ ]%n\ %l\\,%c:\ %m,
\%-G\ \ \ \ %.%#,
\%-GNo\ errors\ found.,
\%-Q
cf/tmp/vimfiddler.jslint
endfunction
function!ListFiddles(A,L,P)
returnsystem("ls fiddles")
endfunction
function!ListTemplates(A,L,P)
returnsystem("ls templates")
endfunction
function!OpenFiddle(fiddlename)
let htmlfile ="fiddles/" . a:fiddlename . "/index.html"
let jsfile ="fiddles/" . a:fiddlename . "/code.js"
execute"edit ". jsfile
execute"split " . htmlfile
callOpenFiddleInBrowser(a:fiddlename)
callWatchFile(jsfile)
callWatchFile(htmlfile)
endfunction
function!NewFiddle()
let fiddlename =input("Name: ")
let templatename =input("Use template: ", "default", "custom,ListTemplates")
callmkdir("fiddles/" . fiddlename)
exe"! cp templates/" . templatename . "/* fiddles/" . fiddlename
callOpenFiddle(fiddlename)
endfunction
function!WatchFile(filename)
exe"autocmd VimFiddler BufWritePost " . a:filename . " call Refresh()"
endfunction
function!OpenFiddleInBrowser(fiddlename)
callOpenURL("http://localhost/~" . $USER . "/vimfiddler/fiddles/" . a:fiddlename . "/")
endfunction
function!StartSeleniumClient()
python from selenium import webdriver
python browser = webdriver.Chrome()
endfunction
function!OpenURL(url)
execute":python browser.get('" . a:url ."')"
endfunction
function!Refresh()
python browser.refresh()
endfunction
augroupVimFiddler
au!
augroupEND
pythonimport sys; sys.path.append(".")
echo'Commands: StartSeleniumClient, OpenFiddle, NewFiddle'
echo'Starting selenium webdriver'
callStartSeleniumClient()