mirror of
				https://github.com/amix/vimrc
				synced 2025-10-31 14:43:35 +08:00 
			
		
		
		
	Updated all the plugins. Removed powerline. Added vim-airline (replacement for powerline). Added vim-fugitive.
This commit is contained in:
		| @ -1,54 +1,54 @@ | ||||
| snippet <? | ||||
| 	<?php | ||||
|  | ||||
| 	${1} | ||||
| 	${0} | ||||
| snippet ec | ||||
| 	echo ${1}; | ||||
| 	echo ${0}; | ||||
| snippet <?e | ||||
| 	<?php echo ${1} ?> | ||||
| 	<?php echo ${0} ?> | ||||
| # this one is for php5.4 | ||||
| snippet <?= | ||||
| 	<?=${1}?> | ||||
| 	<?=${0}?> | ||||
| snippet ?= | ||||
| 	<?= ${1} ?> | ||||
| 	<?= ${0} ?> | ||||
| snippet ? | ||||
| 	<?php ${1} ?> | ||||
| 	<?php ${0} ?> | ||||
| snippet ?f | ||||
| 	<?php foreach ($${1:vars} as $${2:$var}): ?> | ||||
| 		${3} | ||||
| 		${0} | ||||
| 	<?php endforeach ?> | ||||
| snippet ?i | ||||
| 	<?php if ($${1:var}): ?> | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	<?php endif ?> | ||||
| snippet ns | ||||
| 	namespace ${1:Foo\Bar\Baz}; | ||||
| 	${2} | ||||
| 	${0} | ||||
| snippet use | ||||
| 	use ${1:Foo\Bar\Baz}; | ||||
| 	${2} | ||||
| 	${0} | ||||
| snippet	c | ||||
| 	class ${1:`vim_snippets#Filename()`} | ||||
| 	{ | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet i | ||||
| 	interface ${1:`vim_snippets#Filename()`} | ||||
| 	{ | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet t. | ||||
| 	$this->${1} | ||||
| 	$this-> | ||||
| snippet f | ||||
| 	function ${1:foo}(${2:array }${3:$bar}) | ||||
| 	{ | ||||
| 		${4} | ||||
| 		${0} | ||||
| 	} | ||||
| # method | ||||
| snippet m | ||||
| 	${1:protected} function ${2:foo}() | ||||
| 	{ | ||||
| 		${3} | ||||
| 		${0} | ||||
| 	} | ||||
| # setter method | ||||
| snippet sm | ||||
| @ -63,7 +63,7 @@ snippet sm | ||||
| 	{ | ||||
| 		$this->${8:$1} = $$1; | ||||
| 		return $this; | ||||
| 	}${9} | ||||
| 	} | ||||
| # getter method | ||||
| snippet gm | ||||
| 	/** | ||||
| @ -74,50 +74,50 @@ snippet gm | ||||
| 	${3:public} function get${4:$2}() | ||||
| 	{ | ||||
| 		return $this->${5:$1}; | ||||
| 	}${6} | ||||
| 	} | ||||
| #setter | ||||
| snippet $s | ||||
| 	${1:$foo}->set${2:Bar}(${3}); | ||||
| 	${1:$foo}->set${2:Bar}(${0}); | ||||
| #getter | ||||
| snippet $g | ||||
| 	${1:$foo}->get${2:Bar}(); | ||||
| 	${1:$foo}->get${0:Bar}(); | ||||
|  | ||||
| # Tertiary conditional | ||||
| snippet =?: | ||||
| 	$${1:foo} = ${2:true} ? ${3:a} : ${4}; | ||||
| 	$${1:foo} = ${2:true} ? ${3:a} : ${0}; | ||||
| snippet ?: | ||||
| 	${1:true} ? ${2:a} : ${3} | ||||
| 	${1:true} ? ${2:a} : ${0} | ||||
|  | ||||
| snippet C | ||||
| 	$_COOKIE['${1:variable}']${2} | ||||
| 	$_COOKIE['${1:variable}'] | ||||
| snippet E | ||||
| 	$_ENV['${1:variable}']${2} | ||||
| 	$_ENV['${1:variable}'] | ||||
| snippet F | ||||
| 	$_FILES['${1:variable}']${2} | ||||
| 	$_FILES['${1:variable}'] | ||||
| snippet G | ||||
| 	$_GET['${1:variable}']${2} | ||||
| 	$_GET['${1:variable}'] | ||||
| snippet P | ||||
| 	$_POST['${1:variable}']${2} | ||||
| 	$_POST['${1:variable}'] | ||||
| snippet R | ||||
| 	$_REQUEST['${1:variable}']${2} | ||||
| 	$_REQUEST['${1:variable}'] | ||||
| snippet S | ||||
| 	$_SERVER['${1:variable}']${2} | ||||
| 	$_SERVER['${1:variable}'] | ||||
| snippet SS | ||||
| 	$_SESSION['${1:variable}']${2} | ||||
| 	$_SESSION['${1:variable}'] | ||||
|  | ||||
| # the following are old ones | ||||
| snippet inc | ||||
| 	include '${1:file}';${2} | ||||
| 	include '${1:file}'; | ||||
| snippet inc1 | ||||
| 	include_once '${1:file}';${2} | ||||
| 	include_once '${1:file}'; | ||||
| snippet req | ||||
| 	require '${1:file}';${2} | ||||
| 	require '${1:file}'; | ||||
| snippet req1 | ||||
| 	require_once '${1:file}';${2} | ||||
| 	require_once '${1:file}'; | ||||
| # Start Docblock | ||||
| snippet /* | ||||
| 	/** | ||||
| 	 * ${1} | ||||
| 	 * ${0} | ||||
| 	 */ | ||||
| # Class - post doc | ||||
| snippet doc_cp | ||||
| @ -127,14 +127,14 @@ snippet doc_cp | ||||
| 	 * @package ${2:default} | ||||
| 	 * @subpackage ${3:default} | ||||
| 	 * @author ${4:`g:snips_author`} | ||||
| 	 */${5} | ||||
| 	 */ | ||||
| # Class Variable - post doc | ||||
| snippet doc_vp | ||||
| 	/** | ||||
| 	 * ${1:undocumented class variable} | ||||
| 	 * | ||||
| 	 * @var ${2:string} | ||||
| 	 */${3} | ||||
| 	 */ | ||||
| # Class Variable | ||||
| snippet doc_v | ||||
| 	/** | ||||
| @ -142,7 +142,7 @@ snippet doc_v | ||||
| 	 * | ||||
| 	 * @var ${4:string} | ||||
| 	 */ | ||||
| 	${1:var} $${2};${5} | ||||
| 	${1:var} $${2}; | ||||
| # Class | ||||
| snippet doc_c | ||||
| 	/** | ||||
| @ -154,19 +154,19 @@ snippet doc_c | ||||
| 	 */ | ||||
| 	${1:}class ${2:} | ||||
| 	{ | ||||
| 		${7} | ||||
| 		${0} | ||||
| 	} // END $1class $2 | ||||
| # Constant Definition - post doc | ||||
| snippet doc_dp | ||||
| 	/** | ||||
| 	 * ${1:undocumented constant} | ||||
| 	 */${2} | ||||
| 	 */ | ||||
| # Constant Definition | ||||
| snippet doc_d | ||||
| 	/** | ||||
| 	 * ${3:undocumented constant} | ||||
| 	 */ | ||||
| 	define(${1}, ${2});${4} | ||||
| 	define(${1}, ${2}); | ||||
| # Function - post doc | ||||
| snippet doc_fp | ||||
| 	/** | ||||
| @ -174,7 +174,7 @@ snippet doc_fp | ||||
| 	 * | ||||
| 	 * @return ${2:void} | ||||
| 	 * @author ${3:`g:snips_author`} | ||||
| 	 */${4} | ||||
| 	 */ | ||||
| # Function signature | ||||
| snippet doc_s | ||||
| 	/** | ||||
| @ -183,7 +183,7 @@ snippet doc_s | ||||
| 	 * @return ${5:void} | ||||
| 	 * @author ${6:`g:snips_author`} | ||||
| 	 */ | ||||
| 	${1}function ${2}(${3});${7} | ||||
| 	${1}function ${2}(${3}); | ||||
| # Function | ||||
| snippet doc_f | ||||
| 	/** | ||||
| @ -193,7 +193,7 @@ snippet doc_f | ||||
| 	 * @author ${6:`g:snips_author`} | ||||
| 	 */ | ||||
| 	${1}function ${2}(${3}) | ||||
| 	{${7} | ||||
| 	{${0} | ||||
| 	} | ||||
| # Header | ||||
| snippet doc_h | ||||
| @ -203,7 +203,7 @@ snippet doc_h | ||||
| 	 * @author ${2:`g:snips_author`} | ||||
| 	 * @version ${3:$Id$} | ||||
| 	 * @copyright ${4:$2}, `strftime('%d %B, %Y')` | ||||
| 	 * @package ${5:default} | ||||
| 	 * @package ${0:default} | ||||
| 	 */ | ||||
|  | ||||
| # Interface | ||||
| @ -216,7 +216,7 @@ snippet interface | ||||
| 	 */ | ||||
| 	interface ${1:`vim_snippets#Filename()`} | ||||
| 	{ | ||||
| 		${5} | ||||
| 		${0} | ||||
| 	} | ||||
| # class ... | ||||
| snippet class | ||||
| @ -231,7 +231,7 @@ snippet class | ||||
| 		 */ | ||||
| 		${5:public} function ${6:__construct}(${7:argument}) | ||||
| 		{ | ||||
| 			${8} | ||||
| 			${0} | ||||
| 		} | ||||
| 	} | ||||
| snippet nc | ||||
| @ -239,30 +239,34 @@ snippet nc | ||||
|  | ||||
| 	${2:abstract }class ${3:`vim_snippets#Filename()`} | ||||
| 	{ | ||||
| 		${4} | ||||
| 		${0} | ||||
| 	} | ||||
| # define(...) | ||||
| snippet def | ||||
| 	define('${1}'${2});${3} | ||||
| 	define('${1}'${2}); | ||||
| # defined(...) | ||||
| snippet def? | ||||
| 	${1}defined('${2}')${3} | ||||
| 	${1}defined('${2}') | ||||
| snippet wh | ||||
| 	while (${1:/* condition */}) { | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} | ||||
| # do ... while | ||||
| snippet do | ||||
| 	do { | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} while (${1:/* condition */}); | ||||
| snippet if | ||||
| 	if (${1:/* condition */}) { | ||||
| 		${0} | ||||
| 	} | ||||
| snippet ifn | ||||
| 	if (!${1:/* condition */}) { | ||||
| 		${2} | ||||
| 	} | ||||
| snippet ifil | ||||
| 	<?php if (${1:/* condition */}): ?> | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	<?php endif; ?> | ||||
| snippet ife | ||||
| 	if (${1:/* condition */}) { | ||||
| @ -270,28 +274,28 @@ snippet ife | ||||
| 	} else { | ||||
| 		${3} | ||||
| 	} | ||||
| 	${4} | ||||
| 	${0} | ||||
| snippet ifeil | ||||
| 	<?php if (${1:/* condition */}): ?> | ||||
| 		${2:<!-- html... -->} | ||||
| 	<?php else: ?> | ||||
| 		${3:<!-- html... -->} | ||||
| 	<?php endif; ?> | ||||
| 	${4} | ||||
| 	${0} | ||||
| snippet el | ||||
| 	else { | ||||
| 		${1} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet eif | ||||
| 	elseif (${1:/* condition */}) { | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet switch | ||||
| 	switch ($${1:variable}) { | ||||
| 		case '${2:value}': | ||||
| 			${3} | ||||
| 			break; | ||||
| 		${5} | ||||
| 		${0} | ||||
| 		default: | ||||
| 			${4} | ||||
| 			break; | ||||
| @ -299,52 +303,52 @@ snippet switch | ||||
| snippet case | ||||
| 	case '${1:value}': | ||||
| 		${2} | ||||
| 		break;${3} | ||||
| 		break; | ||||
| snippet for | ||||
| 	for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) { | ||||
| 		${4} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet foreach | ||||
| 	foreach ($${1:variable} as $${2:value}) { | ||||
| 		${3} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet foreachil | ||||
| 	<?php foreach ($${1:variable} as $${2:value}): ?> | ||||
| 		${3:<!-- html... -->} | ||||
| 		${0:<!-- html... -->} | ||||
| 	<?php endforeach; ?> | ||||
| snippet foreachk | ||||
| 	foreach ($${1:variable} as $${2:key} => $${3:value}) { | ||||
| 		${4} | ||||
| 		${0} | ||||
| 	} | ||||
| snippet foreachkil | ||||
| 	<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?> | ||||
| 		${4:<!-- html... -->} | ||||
| 		${0:<!-- html... -->} | ||||
| 	<?php endforeach; ?> | ||||
| # $... = array (...) | ||||
| snippet array | ||||
| 	$${1:arrayName} = array('${2}' => ${3});${4} | ||||
| 	$${1:arrayName} = array('${2}' => ${3}); | ||||
| snippet try | ||||
| 	try { | ||||
| 		${2} | ||||
| 		${0} | ||||
| 	} catch (${1:Exception} $e) { | ||||
| 	} | ||||
| # lambda with closure | ||||
| snippet lambda | ||||
| 	${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) { | ||||
| 		${4} | ||||
| 		${0} | ||||
| 	}; | ||||
| # pre_dump(); | ||||
| snippet pd | ||||
| 	echo '<pre>'; var_dump(${1}); echo '</pre>'; | ||||
| 	echo '<pre>'; var_dump(${0}); echo '</pre>'; | ||||
| # pre_dump(); die(); | ||||
| snippet pdd | ||||
| 	echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${2:}); | ||||
| 	echo '<pre>'; var_dump(${1}); echo '</pre>'; die(${0:}); | ||||
| snippet vd | ||||
| 	var_dump(${1}); | ||||
| 	var_dump(${0}); | ||||
| snippet vdd | ||||
| 	var_dump(${1}); die(${2:}); | ||||
| 	var_dump(${1}); die(${0:}); | ||||
| snippet vdf | ||||
| 	error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}');${3} | ||||
| 	error_log(print_r($${1:foo}, true), 3, '${2:/tmp/debug.log}'); | ||||
| snippet http_redirect | ||||
| 	header ("HTTP/1.1 301 Moved Permanently"); | ||||
| 	header ("Location: ".URL); | ||||
| @ -372,13 +376,13 @@ snippet gs | ||||
| 	{ | ||||
| 		$this->$4 = $$1; | ||||
| 		return $this; | ||||
| 	}${8} | ||||
| 	} | ||||
| # anotation, get, and set, useful for doctrine | ||||
| snippet ags | ||||
| 	/** | ||||
| 	 * ${1:description} | ||||
| 	 * | ||||
| 	 * @${7} | ||||
| 	 * @${0} | ||||
| 	 */ | ||||
| 	${2:protected} $${3:foo}; | ||||
|  | ||||
| @ -398,10 +402,158 @@ snippet retf | ||||
| 	return false; | ||||
| snippet am | ||||
| 	$${1:foo} = array_map(function($${2:v}) { | ||||
| 		${3} | ||||
| 		${0} | ||||
| 		return $$2; | ||||
| 	}, $$1); | ||||
| snippet aw | ||||
| 	array_walk($${1:foo}, function(&$${2:v}, $${3:k}) { | ||||
| 		$$2 = ${4}; | ||||
| 		$$2 = ${0}; | ||||
| 	}); | ||||
|  | ||||
| # static var assign once | ||||
| snippet static_var | ||||
| 	static $${1} = null; | ||||
| 	if (is_null($$1)){ | ||||
| 		$$1 = ${2}; | ||||
| 	} | ||||
|  | ||||
| snippet CSVWriter | ||||
| 	<?php | ||||
| 	 | ||||
| 	class CSVWriter { | ||||
| 		public function __construct($file_or_handle, $sep = "\t", $quot = '"'){ | ||||
| 			$args = func_get_args(); | ||||
| 			$mode = isset($opts['mode']) ? $opts['mode'] : 'w'; | ||||
| 	 | ||||
| 			$this->f = | ||||
| 				is_string($file_or_handle) | ||||
| 				? fopen($file_or_handle, $mode) | ||||
| 				: $file_or_handle; | ||||
| 	 | ||||
| 			$this->fputcsv_args = array($this->f, null, $sep, $quot); | ||||
| 	 | ||||
| 			if (!$this->f) throw new Exception('bad file descriptor'); | ||||
| 		} | ||||
| 	 | ||||
| 		public function write($row){ | ||||
| 			$this->fputcsv_args[1] =& $row; | ||||
| 			call_user_func_array('fputcsv', $this->fputcsv_args); | ||||
| 		} | ||||
| 	 | ||||
| 		public function close(){ | ||||
| 			if (!is_null($this->f)) | ||||
| 				fclose($this->f); | ||||
| 			$this->f = null; | ||||
| 		} | ||||
| 	 | ||||
| 		public function __destruct(){ | ||||
| 			$this->close(); | ||||
| 		} | ||||
| 	 | ||||
| 	} | ||||
|  | ||||
| snippet CSVIterator | ||||
| 	 | ||||
| 	// http://snipplr.com/view.php?codeview&id=1986 // modified | ||||
| 	class CSVIterator implements Iterator | ||||
| 	{	 | ||||
| 		private $f; | ||||
| 		private $curr; | ||||
| 		private $rowCounter; | ||||
| 	 | ||||
| 		 /* opts keys: | ||||
| 			* row_size | ||||
| 			* escape | ||||
| 			* enclosure | ||||
| 			* delimiter | ||||
| 			*/ | ||||
| 		public function __construct( $file_or_handle, $opts = array(4096, ',') ) | ||||
| 		{ | ||||
| 			$d = function($n) use(&$opts){ return isset($opts[$n]) ? $opts[$n] : false; }; | ||||
| 	 | ||||
| 			$this->combine = $d('combine'); | ||||
| 			$this->headers = $d('headers'); | ||||
| 			$this->headerCheckFunction = $d('header_check_function'); | ||||
| 	 | ||||
| 			$this->f = | ||||
| 				is_string($file_or_handle) | ||||
| 				? fopen( $file_or_handle, 'r' ) | ||||
| 				: $file_or_handle; | ||||
| 			if (!$this->f) throw new Exception('bad file descriptor'); | ||||
| 			$this->fgetcsv_args = array( | ||||
| 					$this->f, | ||||
| 					isset($opts['row_size']) ? $opts['row_size'] : 4096, | ||||
| 					isset($opts['delimiter']) ? $opts['delimiter'] : ',', | ||||
| 					isset($opts['enclosure']) ? $opts['enclosure'] : '"', | ||||
| 					isset($opts['escape']) ? $opts['escape'] : '\\', | ||||
| 			); | ||||
| 			$this->start(); | ||||
| 		} | ||||
| 	 | ||||
| 		protected function readRow(){ | ||||
| 			$this->curr = call_user_func_array('fgetcsv', $this->fgetcsv_args ); | ||||
| 			$this->rowCounter++; | ||||
| 			if ($this->rowCounter == 1){ | ||||
| 				$this->processHeader(); | ||||
| 			} elseif ($this->curr) { | ||||
| 				$this->processRow(); | ||||
| 			} | ||||
| 		} | ||||
| 	 | ||||
| 		public function processHeader(){ | ||||
| 			if ($this->headers || $this->combine){ | ||||
| 				$this->header = $this->curr; | ||||
| 				if ($this->headerCheckFunction){ | ||||
| 					$f = $this->headerCheckFunction; | ||||
| 					$f($this->header); | ||||
| 				} | ||||
| 				$this->readRow(); | ||||
| 			} | ||||
| 		} | ||||
| 	 | ||||
| 		public function processRow(){ | ||||
| 			if ($this->combine) | ||||
| 				$this->curr = array_combine($this->header, $this->curr); | ||||
| 		} | ||||
| 	 | ||||
| 		public function start(){ | ||||
| 			$this->rowCounter = 0; | ||||
| 			rewind( $this->f ); | ||||
| 			$this->readRow(); | ||||
| 		} | ||||
| 	 | ||||
| 		public function rewind() | ||||
| 		{ | ||||
| 			$this->start(); | ||||
| 		} | ||||
| 	 | ||||
| 		public function current() | ||||
| 		{ | ||||
| 			$curr = $this->curr; | ||||
| 			$this->readRow(); | ||||
| 			return $curr; | ||||
| 		} | ||||
| 	 | ||||
| 		public function key() | ||||
| 		{ | ||||
| 			return $this->rowCounter; | ||||
| 		} | ||||
| 	 | ||||
| 		public function next() | ||||
| 		{ | ||||
| 			return $this->curr; | ||||
| 		} | ||||
| 	 | ||||
| 		public function valid(){ | ||||
| 			if( !$this->next() ) | ||||
| 			{ | ||||
| 				fclose( $this->f ); | ||||
| 				return FALSE; | ||||
| 			} | ||||
| 			return TRUE; | ||||
| 		} | ||||
| 	 | ||||
| 	} // end class | ||||
|  | ||||
| snippet is | ||||
| 	isset($1{VISUAL}) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 amix
					amix