Permalink
Browse files

add processing syntax

  • Loading branch information...
1 parent 38e2c73 commit 119163c692e3c441de9897ad2fc9596dcf1e0f01 @bleything committed Dec 13, 2011
View
@@ -46,6 +46,7 @@ Aaaaaalso, some syntax definitions:
* {JSON}[http://www.vim.org/scripts/script.php?script_id=1945]
* {Markdown}[http://github.com/ujihisa/vim-markdown]
* {nginx}[http://www.vim.org/scripts/script.php?script_id=1886]
+* {Processing}[https://github.com/sophacles/vim-processing]
* {RDoc}[http://www.vim.org/scripts/script.php?script_id=2878]
* {Scala}[https://github.com/derekwyatt/vim-scala]
* {Slidedown}[http://www.vim.org/scripts/script.php?script_id=3069]
View
@@ -29,6 +29,7 @@ namespace :update do
:fugitive => "git://github.com/tpope/vim-fugitive.git",
:nerdcommenter => "git://github.com/scrooloose/nerdcommenter.git",
:nerdtree => "git://github.com/scrooloose/nerdtree.git",
+ :processing => "git://github.com/sophacles/vim-processing.git",
:rails => "git://github.com/tpope/vim-rails.git",
:surround => "git://github.com/tpope/vim-surround.git",
:tabular => "git://github.com/godlygeek/tabular",
@@ -0,0 +1,14 @@
+
+Installation:
+
+1. Extract the archive into your Vim runtime directory (~/.vim on UNIX)
+2. Set the path to the Processing documentation in your vimrc, e.g.
+
+ let processing_doc_path="c:\\Programs\\Processing\\reference"
+
+3. Enjoy!
+
+If you have a Vim built with Python, the K key can be used to look up
+functions and variables in the documentation. Note that words followed
+by an opening paren "(" are treated as functions, thus K pressed on
+frameRate() and frameRate goes to different documentation pages.
View
@@ -0,0 +1,23 @@
+Vim processing.
+
+This is an extension of vim script #2115. It started simply as an easy git repo
+to bundle and use with pathogen, but has grown as I use processing more.
+
+I have made two sets of modifications so far:
+
+1) Documentiation is now browsable locally or on the web. If you set the
+variable processing_doc_style to "local" it will use a local copy of the
+processing docs (and requires you to set the variable processing_doc_path to
+point to the root of the documents). If you set processing_doc_style to "web"
+it will point your browser at the processing site when you use attempt to use
+the documentation hookup. (normal mode K)
+
+2) For OSX users, I have created a applescript to tell processing to run the
+script in question. For this to properly work, Processing must already be
+running, and it works best if the "use external editor" preference is selected.
+Simply pressing F5 will cause this applescript to select the processing window
+corresponding to the pde we are editing, and presss the 'run' button. This
+is still pretty fragile, but works well enough to significantly increase the
+effectiveness of my workflow. If you know of better ways, please share!
+
+
@@ -0,0 +1,2 @@
+
+au BufRead,BufNewFile *.pde setf processing
@@ -0,0 +1,108 @@
+
+" 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 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") && exists("processing_doc_style")
+
+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
+
+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
+
+if re.match(r"\w+\s*\(", line[col:]):
+ 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>
+
+if has("macunix")
+function! RunProcessing()
+ let sketch = expand("%:h:t")
+ "shell osascript -e 'set sname to "sketch_aug15a"' -e 'tell application "Processing" to activate' -e 'tell application "System Events" to tell process "Processing"' -e 'repeat' -e 'set t to title of every window' -e 'set ta to item 1 of t' -e 'if ta contains sname then' -e 'keystroke "r" using command down' -e 'exit repeat' -e 'else' -e 'keystroke "`" using command down' -e 'end if' -e 'end repeat' -e 'end tell'
+
+ let input = ["set sname to \"" . expand("%:p:h:t") . "\""]
+ let input += ["tell application \"Processing\" to activate" ]
+ let input += ["tell application \"System Events\" to tell process \"Processing\""]
+ let input += ["set l to title of every window"]
+ let input += ["set qt to true"]
+ let input += ["repeat with name in l"]
+ let input += ["if name contains sname then"]
+ let input += ["set qt to false"]
+ let input += ["end if"]
+ let input += ["end repeat"]
+ let input += ["if qt is true"]
+ let input += ["return"]
+ let input += ["end if"]
+ let input += ["repeat"]
+ let input += ["set t to title of every window"]
+ let input += ["set ta to item 1 of t"]
+ let input += ["if ta contains sname then"]
+ let input += ["keystroke \"r\" using {command down}"]
+ let input += ["exit repeat"]
+ let input += ["else"]
+ let input += ["keystroke \"`\" using command down"]
+ let input += ["end if"]
+ let input += ["end repeat"]
+ let input += ["end tell"]
+ let myargs = join(input, "\n") . "\n"
+ call system("osascript", myargs)
+endfunction "RunProcessing
+map <F5> :call RunProcessing()<CR>
+endif "has("macunix")
+
+endif
+
Oops, something went wrong.

0 comments on commit 119163c

Please sign in to comment.