forked from sophacles/vim-processing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessing.vim
More file actions
executable file
·116 lines (86 loc) · 2.46 KB
/
Copy pathprocessing.vim
File metadata and controls
executable file
·116 lines (86 loc) · 2.46 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
111
112
113
114
" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
finish
endif
let b:did_ftplugin = 1
" You may want to comment these
setlocal expandtab
setlocal shiftwidth=2
setlocal tabstop=2
setlocal fdm=syntax
setlocal cindent
setlocal cinkeys-=0#
setlocal formatoptions-=t formatoptions+=croql
setlocal suffixesadd=.pde
let b:undo_ftplugin = "set cin< cink< fo< sua< et< sw< ts<"
if has("python")
if !exists("g:processing_doc_style")
let g:processing_doc_style = "web"
endif
if !exists("g:processing_doc_path")
let g:processing_doc_style = "web"
endif
function! ProcessingDoc()
python << ENDPY
import vim
import re
import webbrowser
from os import path
def launchDocFile(filename):
docfile = path.join(basepath, filename)
if path.exists(docfile) and path.isfile(docfile):
webbrowser.open(docfile)
return True
return False
def launchDocWeb(filename):
docfile = "http://processing.org/reference/"
webbrowser.open(docfile+filename)
return True
def wordStart(line, column):
start = column
for i in reversed(range(column)):
if line[i].isalnum():
start = i
else:
break
return start
if vim.eval("g:processing_doc_style") == "local":
basepath = path.abspath(vim.eval("g:processing_doc_path"))
launchDoc = launchDocFile
else:
launchDoc = launchDocWeb
(row, col) = vim.current.window.cursor
line = vim.current.line
col = wordStart(line, col)
if re.match(r"\w+\s*\(", line[col:]):
if col < 4:
fun = True
else:
col -= 4
if re.match(r"new\s*\w+\s*\(", line[col:]):
fun = False
else:
fun = True
else:
fun = False
word = vim.eval('expand("<cword>")')
if word:
if fun:
success = launchDoc(word + "_.html") or launchDoc(word + ".html")
else:
success = launchDoc(word + ".html") or launchDoc(word + "_.html")
if not success:
print "Identifier", '"' + word + '"', "not found in the documentation."
ENDPY
endfunction
nnoremap <silent> <buffer> K :call ProcessingDoc()<CR>
endif "has("python")
if has("macunix")
let s:runner = expand('<sfile>:p:h').'/../bin/runPSketch.scpt'
function! RunProcessing()
let sketch = expand("%:p:h:t")
silent execute "!osascript ".s:runner." ".sketch
endfunction "RunProcessing
map <F5> :call RunProcessing()<CR>
command! RunProcessing call RunProcessing()
endif "has("macunix")