Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 59d02e3e55b19a0730706d25456d94cdc755f83c 0 parents
@jamescarr authored
Showing with 104 additions and 0 deletions.
  1. +9 −0 Readme.md
  2. +3 −0  snippets/javascript/addLis.snippet
  3. +2 −0  snippets/javascript/app.get.snippet
  4. +3 −0  snippets/javascript/app.listen.snippet
  5. +2 −0  snippets/javascript/app.post.snippet
  6. +1 −0  snippets/javascript/assert.notE.snippet
  7. +1 −0  snippets/javascript/assertdeep.snippet
  8. +1 −0  snippets/javascript/asserteq.snippet
  9. +1 −0  snippets/javascript/crypto.createCred.snippet
  10. +1 −0  snippets/javascript/env.snippet
  11. +18 −0 snippets/javascript/express.snippet
  12. +3 −0  snippets/javascript/filt.snippet
  13. +2 −0  snippets/javascript/foreEach.snippet
  14. +3 −0  snippets/javascript/fs.readFile.snippet
  15. +3 −0  snippets/javascript/fs.unlink.snippet
  16. +2 −0  snippets/javascript/fs.watchFile.snippet
  17. +3 −0  snippets/javascript/fs.writeFile.snippet
  18. +1 −0  snippets/javascript/func.snippet
  19. +1 −0  snippets/javascript/http.createClient.snippet
  20. +3 −0  snippets/javascript/http.createServer.snippet
  21. +1 −0  snippets/javascript/json.pa.snippet
  22. +1 −0  snippets/javascript/json.st.snippet
  23. +1 −0  snippets/javascript/log.snippet
  24. +3 −0  snippets/javascript/on.snippet
  25. +1 −0  snippets/javascript/req.snippet
  26. +2 −0  snippets/javascript/reqfs.snippet
  27. +2 −0  snippets/javascript/reqhttp.snippet
  28. +1 −0  snippets/javascript/reqio.snippet
  29. +1 −0  snippets/javascript/reqpath.snippet
  30. +1 −0  snippets/javascript/reqsys.snippet
  31. +9 −0 snippets/javascript/reqvows.snippet
  32. +5 −0 snippets/javascript/res.render.snippet
  33. +1 −0  snippets/javascript/setinterv.snippet
  34. +1 −0  snippets/javascript/settime.snippet
  35. +1 −0  snippets/javascript/sysi.snippet
  36. +10 −0 snippets/javascript/websocket.snippet
9 Readme.md
@@ -0,0 +1,9 @@
+# Vim Snippets for Node.js
+Here be various snippets for use with Vim SnipMate to make node.js development quicker and easier. You'll need snipmate installed, then just dump the contents of snippets/javascript into the directory ~/.vim/snippets/javascript.
+
+## Examples
+fs.readFile
+fs.writeFile
+reqsys
+reqhttp
+etc.
3  snippets/javascript/addLis.snippet
@@ -0,0 +1,3 @@
+addListener('${1:event}', function(${2:}){
+ ${3:}
+});
2  snippets/javascript/app.get.snippet
@@ -0,0 +1,2 @@
+app.get('${1:path}', function(req, res){
+});
3  snippets/javascript/app.listen.snippet
@@ -0,0 +1,3 @@
+app.listen(${1:3000}, ${2:function(){
+ console.log('app started on port 3000');
+}});
2  snippets/javascript/app.post.snippet
@@ -0,0 +1,2 @@
+app.post('${1:path}', function(req, res){
+});
1  snippets/javascript/assert.notE.snippet
@@ -0,0 +1 @@
+assert.notEqual(${1:actual}, ${2:expected});
1  snippets/javascript/assertdeep.snippet
@@ -0,0 +1 @@
+assert.deepEqual(${1:actual}, ${2:expected});
1  snippets/javascript/asserteq.snippet
@@ -0,0 +1 @@
+assert.equal(${1:actual}, ${2:expected});
1  snippets/javascript/crypto.createCred.snippet
@@ -0,0 +1 @@
+crypto.createCredentials({key:${1:key}, cert:${2:cert}${3:, ca:[]});
1  snippets/javascript/env.snippet
@@ -0,0 +1 @@
+process.env.${1:VARIABLE}
18 snippets/javascript/express.snippet
@@ -0,0 +1,18 @@
+var app = express.createServer();
+
+app.configure(function(){
+ app.set('views', __dirname + '${1:/../views}');
+ ${2:app.use(connect.bodyDecoder());}
+ ${3:app.use(connect.methodOverride());}
+ app.use(connect.compiler({ src: __dirname + '/../public', enable: ['less'] }));
+ app.use(app.router);
+ app.use(connect.staticProvider(__dirname + '${4:/../public'}));
+});
+
+app.configure('development', function(){
+ app.use(connect.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ app.use(connect.errorHandler());
+});
3  snippets/javascript/filt.snippet
@@ -0,0 +1,3 @@
+filter(function(item){
+ return ${1:false};
+});
2  snippets/javascript/foreEach.snippet
@@ -0,0 +1,2 @@
+forEach(function(${1:item},${2:index}){
+});
3  snippets/javascript/fs.readFile.snippet
@@ -0,0 +1,3 @@
+fs.readFile('${1:filename}', function(err, data){
+ ${2: }
+});
3  snippets/javascript/fs.unlink.snippet
@@ -0,0 +1,3 @@
+fs.unlink('${1:location}', function(err){
+ ${2: }
+});
2  snippets/javascript/fs.watchFile.snippet
@@ -0,0 +1,2 @@
+fs.watchFile('${1:filename}', function(current, previous){
+});
3  snippets/javascript/fs.writeFile.snippet
@@ -0,0 +1,3 @@
+fs.writeFile('${1:filename}', ${2:data}, ${3:'utf8'}, function(err){
+ ${4: }
+});
1  snippets/javascript/func.snippet
@@ -0,0 +1 @@
+function(${1:}){${2:}}
1  snippets/javascript/http.createClient.snippet
@@ -0,0 +1 @@
+http.createCleint(${1:80}, '${2:www.google.com}');
3  snippets/javascript/http.createServer.snippet
@@ -0,0 +1,3 @@
+http.createServer(function(${1:request}, ${2:response}){
+ ${3:}
+}).listen(${4:8124});
1  snippets/javascript/json.pa.snippet
@@ -0,0 +1 @@
+JSON.parse(${1:'{"string":"of json"}});
1  snippets/javascript/json.st.snippet
@@ -0,0 +1 @@
+JSON.stringify(${1:{some:'object'}});
1  snippets/javascript/log.snippet
@@ -0,0 +1 @@
+console.log('${1:message}')
3  snippets/javascript/on.snippet
@@ -0,0 +1,3 @@
+on('${1:eventname}', function(${2:err, res}){
+ ${3:}
+});
1  snippets/javascript/req.snippet
@@ -0,0 +1 @@
+var ${1:module} = require ('${2:module}')
2  snippets/javascript/reqfs.snippet
@@ -0,0 +1,2 @@
+var fs = require('fs');
+
2  snippets/javascript/reqhttp.snippet
@@ -0,0 +1,2 @@
+var http = require('http');
+
1  snippets/javascript/reqio.snippet
@@ -0,0 +1 @@
+var io = require('socketio');
1  snippets/javascript/reqpath.snippet
@@ -0,0 +1 @@
+require.paths.unshift(${1:__dirname}${2:+'/lib/'});
1  snippets/javascript/reqsys.snippet
@@ -0,0 +1 @@
+var sys = require('sys');
9 snippets/javascript/reqvows.snippet
@@ -0,0 +1,9 @@
+var vows = require('vows');
+var assert = require('assert');
+
+vows.describe('${1:something}').addBatch({
+ '${2:firstthing}':{
+ topic:function(){
+ }
+ }
+}).export(module);
5 snippets/javascript/res.render.snippet
@@ -0,0 +1,5 @@
+res.render('${1:template}', {
+ locals:{
+ ${2:templatevars}
+ }
+});
1  snippets/javascript/setinterv.snippet
@@ -0,0 +1 @@
+setInterval(${1:callback}, ${2:delay})
1  snippets/javascript/settime.snippet
@@ -0,0 +1 @@
+setTimeout(${1:operation}, ${2:miliseconds})
1  snippets/javascript/sysi.snippet
@@ -0,0 +1 @@
+sys.inspect(${1:object})
10 snippets/javascript/websocket.snippet
@@ -0,0 +1,10 @@
+var socket = ${1:io}.listen(${2:app});
+
+socket.on('connection', function(client){
+ client.on('message', function(${3:msg}){
+ ${4:}
+ });
+ client.on('disconnect', function(){
+ ${5:}
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.