1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated vim plugins

This commit is contained in:
amix
2016-11-09 18:22:55 +01:00
parent aad95603ea
commit 1494e2edfa
81 changed files with 2756 additions and 470 deletions

View File

@ -1,8 +1,8 @@
snippet setup
void setup()
{
${0}
Serial.begin(9600);
Serial.begin(${1:9600});
${2}
}
snippet loop
@ -14,6 +14,9 @@ snippet loop
snippet inc
#include <${1}.h>
snippet def
#define ${1}
# if
snippet if
if (${1:/* condition */}) {
@ -50,12 +53,12 @@ snippet case
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
for (int ${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
@ -93,14 +96,29 @@ snippet dwLow
# digitalRead
snippet dr
digitalRead(${1});
# analogRead
snippet ar
analogRead(${1});
# analogWrite
snippet aw
analogWrite(${1});
# serialRead
snippet sr
serialRead();
# serial.println
Serial.read();
# serialWrite
snippet sw
Serial.write();
# serial.print
snippet sp
serial.println(${1});
Serial.print(${1});
# serial.println
snippet sl
Serial.println(${1});
# delay
snippet dl
delay(${1});
# millis
snippet ml
millis();

View File

@ -104,12 +104,12 @@ snippet ret
## Loops
# for
snippet for
for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
${4}
}
# for (custom)
snippet forr
for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
for (int ${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {
${5}
}
# while
@ -164,6 +164,12 @@ snippet pr
# fprintf (again, this isn't as nice as TextMate's version, but it works)
snippet fpr
fprintf(${1:stderr}, "${2:%s}\n"${3});
snippet prd
printf("${1:} = %d\n", $1);
snippet prf
printf("${1:} = %f\n", $1);
snippet prx
printf("${1:} = %${2}\n", $1);
# getopt
snippet getopt
int choice;

View File

@ -88,6 +88,8 @@ snippet defmo
defmodule ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} do
${0}
end
snippet dfp
defp ${1:name}, do: ${2}
snippet defp
defp ${1:name} do
${0}
@ -100,6 +102,8 @@ snippet doc
@doc """
${0}
"""
snippet docf
@doc false
snippet fn
fn ${1:args} -> ${0} end
snippet mdoc

View File

@ -875,3 +875,5 @@ snippet video
<video src="${1} height="${2}" width="${3}" preload="${5:none}" autoplay="${6:autoplay}>${7}</video>
snippet wbr
<wbr />
snippet viewport
<meta name="viewport" content="width=device-width, initial-scale=1">

View File

@ -214,12 +214,20 @@ snippet wh
while (${1}) ${0}
##
## Main method
snippet psvm
public static void main (String[] args) {
${0}
}
snippet main
public static void main (String[] args) {
${0}
}
##
## Print Methods
snippet sout
System.out.println(${0});
snippet serr
System.err.println(${0});
snippet print
System.out.print("${0:Message}");
snippet printf

View File

@ -42,7 +42,7 @@ snippet e
snippet mo
mods : { ${1:modName} : '${2:modVal}' },
mi - BEM mix mod
# mi - BEM mix mod
snippet mi
mix : [ { ${1:block} : '${2:block}' } ],

View File

@ -6,6 +6,10 @@ snippet it "it" b
it('${1:}', () => {
${0}
});
snippet xit "xit" b
xit('${1:}', () => {
${0}
});
snippet exp "expect" b
expect(${1:})${0};
snippet expe "expect" b

View File

@ -0,0 +1,81 @@
# Import only React
snippet ri1
import React from 'react'
# Import both React and Component
snippet ri2
import React, { Component, PropTypes } from 'react'
# React class
snippet rcla
class ${1:MyComponent} extends Component {
render() {
return (
${0:<div></div>}
)
}
}
# React constructor
snippet rcon
constructor(props) {
super(props)
this.state = {
${1}: ${0},
}
}
# Proptypes for React Class
snippet rcpt
static propTypes = {
${1}: PropTypes.${0},
}
# Default props for React Class
snippet rcdp
static defaultProps = {
${1}: ${0},
}
# Presentational component
snippet rcom
(props) => {
return (
${0:<div></div>}
)
}
# Proptypes for Presentational component
snippet rpt
${1}.propTypes = {
${2}: PropTypes.${0},
}
# Default props for Presentational component
snippet rdp
${1}.defaultProps = {
${2}: ${0},
}
# Lifecycle Methods
snippet rcdm
componentDidMount() {
${0}
}
# State
snippet rsst
this.setState({
${1}: ${0},
})
snippet rtst
this.state.${0}
# Props
snippet rp
props.${0}
snippet rtp
this.props.${0}

View File

@ -0,0 +1,83 @@
snippet ir
import React from 'react';
snippet ird
import ReactDOM from 'react-dom';
snippet cdm
componentDidMount() {
${1}
}
snippet cdup
componentDidUpdate(prevProps, prevState) {
${1}
}
snippet cwm
componentWillMount() {
${1}
}
snippet cwr
componentWillReceiveProps(nextProps) {
${1}
}
snippet cwun
componentWillUnmount() {
${1}
}
snippet cwu
componentWillUpdate(nextProps, nextState) {
${1}
}
snippet fup
forceUpdate(${1:callback});
snippet dp
static defaultProps = {
${1}: ${2},
}
snippet st
state = {
${1}: ${2},
}
snippet pt
static propTypes = {
${1}: React.PropTypes.${2:type},
}
snippet rcc
class ${1:ClassName} extends React.Component {
render() {
return (
${0:<div />}
);
}
}
snippet rdr
ReactDOM.render(${1}, ${2})
snippet ercc
export default class ${1:ClassName} extends React.Component {
render() {
return (
${0:<div />}
);
}
}
snippet ctor
constructor() {
super();
${1}
}
snippet ren
render() {
return (
${1:<div />}
);
}
snippet sst
this.setState({
${1}: ${2}
});
snippet scu
shouldComponentUpdate(nextProps, nextState) {
${1}
}
snippet prp i
this.props.${1}
snippet ste i
this.state.${1}

View File

@ -12,6 +12,30 @@ snippet clax
class ${1} extends ${2} {
${0}
}
snippet clac
class ${1} {
constructor(${2}) {
${0}
}
}
# For of loop
snippet foro
for (let ${1:prop} of ${2:object}) {
${0:$1}
}
# Generator
snippet fun*
function* ${1:function_name}(${2}) {
${0}
}
snippet c=>
const ${1:function_name} = (${2}) => {
${0}
}
snippet caf
const ${1:function_name} = (${2}) => {
${0}
}
snippet =>
(${1}) => {
${0}

View File

@ -1,5 +1,4 @@
# Functions
# prototype
snippet proto
${1:class_name}.prototype.${2:method_name} = function(${3}) {
@ -44,9 +43,7 @@ snippet sdf
${0}
};
};
# Flow control
# if
snippet if
if (${1:true}) {
@ -100,9 +97,6 @@ snippet terr
# return
snippet ret
return ${0:result};
# Loops
# for loop
snippet for
for (var ${2:i} = 0, l = ${1:arr}.length; $2 < l; $2++) {
@ -128,9 +122,7 @@ snippet fori
for (var ${1:prop} in ${2:object}) {
${0:$2[$1]}
}
# Objects
# Object Method
snippet :f
${1:method_name}: function (${2:attribute}) {
@ -207,9 +199,7 @@ snippet prop
configurable : ${0:boolean}
}
);
# Documentation
# docstring
snippet /**
/**
@ -228,9 +218,7 @@ snippet jsonp
# JSON.stringify
snippet jsons
JSON.stringify(${0:object});
# DOM selectors
# Get elements
snippet get
getElementsBy${1:TagName}('${0}')
@ -249,7 +237,6 @@ snippet qs
# Query selector all
snippet qsa
${1:document}.querySelectorAll('${0:CSS selector}')
# Debugging
snippet de
debugger;
@ -265,6 +252,9 @@ snippet ce
# console.warn
snippet cw
console.warn(${0});
# console.info
snippet ci
console.info(${0});
# console.trace
snippet ct
console.trace(${0:label});
@ -277,13 +267,10 @@ snippet ca
# console.dir
snippet cdir
console.dir(${0:obj});
# Misc
# 'use strict';
snippet us
'use strict';
# setTimeout function
snippet timeout
setTimeout(function () {${0}}${2}, ${1:10});

View File

@ -351,8 +351,8 @@ snippet foreachkil "<?php foreach ($var as $key => $value): ?> ... <?php endfor
<?php foreach ($${1:variable} as $${2:key} => $${3:value}): ?>
${0:<!-- html... -->}
<?php endforeach; ?>
snippet array "$... = array(...)"
$${1:arrayName} = array('${2}' => ${3});
snippet array "$... = ['' => ]"
$${1:arrayName} = ['${2}' => ${3}];
snippet try "try { ... } catch (Exception $e) { ... }"
try {
${0}
@ -466,7 +466,7 @@ snippet CSVWriter
? fopen($file_or_handle, $mode)
: $file_or_handle;
$this->fputcsv_args = array($this->f, null, $sep, $quot);
$this->fputcsv_args = [$this->f, null, $sep, $quot];
if (!$this->f) throw new Exception('bad file descriptor');
}
@ -502,7 +502,7 @@ snippet CSVIterator
* enclosure
* delimiter
*/
public function __construct( $file_or_handle, $opts = array(4096, ',') )
public function __construct( $file_or_handle, $opts = [4096, ','] )
{
$d = function($n) use(&$opts){ return isset($opts[$n]) ? $opts[$n] : false; };
@ -515,13 +515,13 @@ snippet CSVIterator
? fopen( $file_or_handle, 'r' )
: $file_or_handle;
if (!$this->f) throw new Exception('bad file descriptor');
$this->fgetcsv_args = array(
$this->fgetcsv_args = [
$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();
}

View File

@ -0,0 +1,58 @@
# Snippets for
# Authored by Trevor Sullivan <trevor@trevorsullivan.net>
# PowerShell Class
snippet class
class {
[string] ${0:FirstName}
}
# PowerShell Advanced Function
snippet function
function {0:name} {
[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[string] $Param1
)
begin {
}
process {
}
end {
}
}
# PowerShell Splatting
snippet splatting
$Params = @{
${0:Param1} = 'Value1'
${1:Param2} = 'Value2'
}
${3:CommandName}
# PowerShell Enumeration
snippet enum
enum ${0:name} {
${1:item1}
${2:item2}
}
# PowerShell if..then
snippet if
if (${0:condition}) {
${1:statement}
}
# PowerShell While Loop
snippet while
while (${0:condition}) {
${1:statement}
}
# PowerShell Filter..Sort
snippet filtersort
${0:command} | Where-Object -FilterScript { $PSItem.${1:property} -${2:operator} '${3:expression}' } | Sort-Object -Property ${4:sortproperty}

View File

@ -993,3 +993,7 @@ snippet for
for ${1:i} in ${0}
snippet keyf
@keyframes ${0}
snippet jc:c
justify-content center
snippet jc
justify-content