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
·139 lines (118 loc) · 3.92 KB
/
Copy pathprocessing.vim
File metadata and controls
executable file
·139 lines (118 loc) · 3.92 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
" Only do this when not done yet for this buffer
if (exists("b:did_ftplugin"))
finish
endif
let b:did_ftplugin = 1
" Make sure the continuation lines below do not cause problems in
" compatibility mode.
let s:save_cpo = &cpo
set cpo-=C
" You may want to comment these
setlocal expandtab
setlocal shiftwidth=2
setlocal tabstop=2
if has("folding") && exists("g:processing_fold")
setlocal fdm=syntax
endif
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 !exists("g:processing_doc_style")
let g:processing_doc_style = "web"
endif
" TODO: have a sane default doc path
if !exists("g:processing_doc_path")
let g:processing_doc_style = "web"
endif
if g:processing_doc_style == 'web'
let g:processing_doc_path="http://processing.org/reference"
endif
" fn to open documentation in a web browser
"
" note: other functions for processing#docopen can be put here
" note: if running on Linux (or other non Mac/Win), xdg-utils is required
function! processing#docopen(docuri)
if has("mac") " Mac (duh)
execute "silent !open " . shellescape(a:docuri)
elseif has("win32") " Windows (both 32 and 64-bit)
echohl ErrorMsg
echo "Error opening documentation: Windows is not currently supported"
echohl None
" FIXME needs testing. absolutely no clue if this works lmfao
" execute "silent !cmd /c start " . shellescape(filepath, 1)
else " other os (mainly Linux but possibly other Unices if xdg-open is supported)
" note: requires that xdg-utils be installed.
" not sure if there's a better way to do this
if executable("xdg-open")
execute "silent !xdg-open " . shellescape(a:docuri)
else
echohl ErrorMsg
echo "Error opening documentation: 'xdg-open' not found"
echohl None
endif
endif
endfunction
if exists("*processing#docopen")
function! ProcessingDoc()
let list_of_no_suffix_syntypes = [
\ "processingType",
\ "processingVariable",
\ "processingConstant",
\ "javaConditional",
\ "javaRepeat",
\ "javaBoolean",
\ "javaConstant",
\ "javaTypedef",
\ "javaOperator",
\ "javaType",
\ "javaType",
\ "javaStatement"]
let word = expand("<cword>")
let syntype = synIDattr(synID(line('.'), col('.'), 1), "name")
if syntype == "processingFunction"
let ending = "_.html"
elseif index(list_of_no_suffix_syntypes,syntype) >= 0
if word == "color"
let ending = "_datatype.html"
else
let ending = ".html"
endif " word == color
endif
if exists("ending")
call processing#docopen(g:processing_doc_path ."/" . word . ending)
else
echo "No known documentation for " . word
endif
endfunction "ProcessingDoc
nnoremap <silent> <buffer> <Plug>(processing-keyword) :<C-u>call ProcessingDoc()<CR>
vnoremap <silent> <buffer> <Plug>(processing-keyword) :<C-u>call ProcessingDoc()<CR>
if !exists('g:processing_no_default_mappings')
silent! nmap <silent> <buffer> K <Plug>(processing-keyword)
silent! vmap <silent> <buffer> K <Plug>(processing-keyword)
endif
endif "processing#docopen
" AppleScript for running sketches on OS X pre Processing 2.0b5
let s:runner = expand('<sfile>:p:h').'/../bin/runPSketch.scpt'
if !exists("g:use_processing_applescript")
compiler processing
endif
" RunProcessing - Run the current sketch in Processing
function! RunProcessing()
let sketch_name = expand("%:p:h:t")
if has("macunix") && exists("g:use_processing_applescript")
let command = "!osascript ".s:runner." ".sketch_name
silent execute command
else
make
endif " has("macunix")...
endfunction "RunProcessing
nnoremap <silent> <buffer> <Plug>(processing-run) :<C-u>call RunProcessing()<CR>
if !exists('g:processing_no_default_mappings')
silent! nmap <silent> <buffer> <F5> <Plug>(processing-run)
endif
command! RunProcessing call RunProcessing()
" Restore the saved compatibility options.
let &cpo = s:save_cpo
unlet s:save_cpo