vincentcordobes / convert-snippets Goto Github PK
View Code? Open in Web Editor NEWUltiSnips ↔︎ VsCode (json) snippets converter
License: MIT License
UltiSnips ↔︎ VsCode (json) snippets converter
License: MIT License
donie@Donies ~/.vim/UltiSnips master ● convert-snippets php_laravel.snippets 1.json -- INSERT --
/Users/donie/.nvm/versions/node/v7.5.0/lib/node_modules/convert-snippets/src/parse.js:12
...(description ? { description } : {}),
^^^
SyntaxError: Unexpected token ...
at Object.exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/donie/.nvm/versions/node/v7.5.0/lib/node_modules/convert-snippets/src/generate.js:2:19)
at Module._compile (module.js:571:32)
The content of php_laravel.snippets is:
snippet lvalidator "参数检验"
$validator = Validator::make($ ${1:request->all()}, [
${2}
]);
if ($validator->fails()) {
return$this->$ {3:response->}error($validator->errors()->first(), 422);
}
endsnippetsnippet luserid "当前用户ID" i
$this$ {1:->auth}->user()->id${0}
endsnippetsnippet lreturn "返回JSON" b
return$this->$ {1:response->}success(${2});${0}
endsnippetsnippet lfail "返回错误响应" i
return$this->$ {1:response->}error(${2}, ${3:500});${0}
endsnippetsnippet lerr "Log::error()" b
Log::error('${1}'${2:.json_encode(${3:$request->all()})});${0}
endsnippetsnippet lctbl "migration: create table" b
Schema::create('${1:users}', function (Blueprint $table) {
${2:$table->increments('id')->comment('ID');}${0}
});
endsnippetsnippet ltbl "migration: alter table" b
Schema::table('${1:users}', function (Blueprint $table) {
${2}
});${0}
endsnippetsnippet lstring "migration: table->string()" b
$table->string('$ {1:email}', ${2:50})${3:->nullable()}->comment('${4:电邮}');${0}
endsnippetsnippet lint "migration: table->integer()" b
$table->integer('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet luint "migration: table->unsignedInteger()" b
$table->unsignedInteger('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet lbint "migration: table->bigInteger()" b
$table->bigInteger('$ {1:user_id}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:用户ID}');${0}
endsnippetsnippet lubint "migration: table->unsignedBigInteger()" b
$table->unsignedBigInteger('$ {1:user_id}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:用户ID}');${0}
endsnippetsnippet ltint "migration: table->tinyInteger()" b
$table->tinyInteger('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet lutint "migration: table->unsignedTinyInteger()" b
$table->unsignedTinyInteger('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet lsint "migration: table->smallInteger()" b
$table->smallInteger('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet lusint "migration: table->unsignedSmallInteger()" b
$table->unsignedSmallInteger('$ {1:age}')${3:->nullable()}${4:->default(${5:0})}->comment('${6:年龄}');${0}
endsnippetsnippet ldecimal "migration: table->decimal()" b
$table->decimal('$ {1:price}', ${3:10}, ${4:2})${5:->nullable()}${6:->default(${7:0})}->comment('${8:价格}');${0}
endsnippetsnippet lbool "migration: table->boolean()" b
$table->boolean('$ {1:email}')${2:->nullable()}${3:->default(${4:1})}->comment('${5:是否显示}');${0}
endsnippetsnippet ltss "migration: table->timestamps()" b
$table->timestamps();
endsnippetsnippet lts "migration: table->timestamp()" b
$table->timestamp('$ {1}')${2:->nullable()}${3:->default(${4:1})}->comment('${5:是否显示}');${0}
endsnippetsnippet ldrop "migration: Schema::drop()" b
Schema::drop('${1:users}');${0}
endsnippetsnippet ldropcol "migration: $table->dropColumn()" b
$table->dropColumn('$ {1}');${0}
endsnippetsnippet ltext "migration: table->text()" b
$table->text('$ {1:desc}')${2:->nullable()}->comment('${3:描述}');${0}
endsnippetsnippet ldatetime "migration: table->datetime()" b
$table->datetime('$ {1:created_at}')${2:->nullable()}->comment('${3:创建时间}');${0}
endsnippetsnippet laction "controller->action()" b
/**
- ${4:Description}
- @param Request
$request 请求对象$ {5}- @return Illuminate\Http\JsonResponse
- @author donieli
- @SInCE ${6:1.0}
- @Version $6
*/
public function ${1:actionName}(Request$request$ {2:, $${3:id}})
{
${8:// TODO: finish this.}
}${0}
endsnippetsnippet ..where "->where()" i
->where('${1:id}', ${2:'${3}', $${4:id}})${0}
endsnippetsnippet ..key "->whereKey()" i
->where${1:Key}(${2:$ ${3:var}})${0}
endsnippetsnippet ..or "->orWhere()" i
->orWhere('${1:id}', ${2:'${3}', $${4:id}})${0}
endsnippetsnippet ..bt "->whereBetween() or ->whereNotBetween()" i
->where${1:Not}Between('${2}', ${3:[${4}, ${5}]})${0}
endsnippetsnippet ..in "->whereIn() or ->whereNotIn()" i
->where${1:Not}In('${2:id}',${3:$ ${4:ids}})${0}
endsnippetsnippet ..null "->whereNull() or ->whereNotNull" i
->where${1:Not}Null('${2}')${0}
endsnippetsnippet ..raw "->whereRaw()" i
->whereRaw('${1}')${0}
endsnippetsnippet ..hav "->having()" i
->having('${1}', '${2:>}', ${3})${0}
endsnippetsnippet ..havraw "->havingRaw()" i
->havingRaw('${1}')${0}
endsnippetsnippet ..when "->when()" i
->when(${1}, function ($ ${2:query})${3:use ($ ${4:request}) }{
${5}
}${6})${0}
endsnippetsnippet ..order "->orderBy()" i
->orderBy(${1:'${2}', '${3:desc}'})${0}
endsnippetsnippet ..insert "->insert() or ->insertGetId()" i
->insert${1:GetId}(${2})${0}
endsnippetsnippet ..update "->update()" i
->update(${1})${0}
endsnippetsnippet ..group "->groupBy()" i
->groupBy('${1}')${0}
endsnippetsnippet ..page "->paginate()" i
->paginate($${1:size}))${0}
endsnippetsnippet ..page2 "->skip()->take()" i
->skip(($${1:page} - 1) * $$ {2:size})->take($${2:size})${0}
endsnippetsnippet ..sel "->select()" i
->select(${1})${0}
endsnippetsnippet ..add "->addSelect()" i
->addSelect(${1})${0}
endsnippetsnippet ..get "->get()" i
->get()${0}
endsnippetsnippet ..fir "->first()" i
->first()${0}
endsnippetsnippet ..count "->count()" i
->count(${1})${0}
endsnippetsnippet ..min "->min()" i
->min('${1}')${0}
endsnippetsnippet ..max "->max()" i
->max('${1}')${0}
endsnippetsnippet ..avg "->avg()" i
->avg('${1}')${0}
endsnippetsnippet ..sum "->sum()" i
->sum('${1}')${0}
endsnippetsnippet ..dist "->distinct()" i
->distinct()${0}
endsnippetsnippet ..join "->join()" i
->join('${1}', ${2:'${3}', '${4:=}', '${5}'})${0}
endsnippetsnippet ..ljoin "->leftJoin()" i
->leftJoin('${1}', ${2:'${3}', '${4:=}', '${5}'})${0}
endsnippetsnippet ..rjoin "->rightJoin()" i
->rightJoin('${1}', ${2:'${3}', '${4:=}', '${5}'})${0}
endsnippetsnippet ..on "->on()" i
->on('${1}', '${2}', '${3}')${0}
endsnippetsnippet ..exi "->whereExists() or ->whereNotExists()" i
->where${1:Not}Exists(${2})${0}
endsnippetsnippet ..val "->value()" i
->value('${1}')${0}
endsnippetsnippet ..plu "->pluck()" i
->pluck('${1}')${0}
endsnippetsnippet ..incr "->increment()" i
->increment('${1}'${2:, ${3:10}})${0}
endsnippetsnippet ..decr "->decrement()" i
->decrement('${1}'${2:, ${3:10}})${0}
endsnippetsnippet ..del "->delete()" i
->delete()${0}
endsnippetsnippet ..from "->from()" i
->from('${1}')${0}
endsnippetsnippet ..lst "->latest()" i
->latest()${0}
endsnippetsnippet ..ost "->oldest()" i
->oldest()${0}
endsnippetsnippet ..sql "->toSql()" i
->toSql()${0}
endsnippetsnippet dbc "DB::connection()" i
DB::connection('${1}')${0:;}
endsnippetsnippet dbtbl "DB::table()" i
DB::table('${1}')${0}
endsnippetsnippet dbraw "DB::raw()" i
DB::raw('${1}')${0}
endsnippetsnippet dbstmt "DB::statement()" b
DB::statement('${1}');${0}
endsnippetsnippet dbbegin "DB::beginTransaction()" b
DB::beginTransaction();
endsnippetsnippet dbroll "DB::rollBack()" b
DB::rollBack();
endsnippetsnippet dbcommit "DB::commit()" b
DB::commit();
endsnippetsnippet lget "$request->get()" i
$request->get('$ {1}'${2:, ${3:1}})${0}
endsnippetsnippet lhas "$request->has()" i
$request->has('$ {1}')
endsnippetsnippet lresult "return ['totalPages', 'result']" b
return [
'totalPages' => $${1:totalPages},
'result' => $${2:${3:query}->get()},
];
endsnippetsnippet ltotal "calc $totalPages" b
$${1:totalNum} = $$ {2:query}->count();
$${3:totalPages} = ceil($$ {4:totalNum} / $${5:size});
endsnippetsnippet lmake "$this->app->make()" b
$${1:var} =$this->app->make($ {2});${0}
endsnippetsnippet lins "$this->app->instance()" b
$this->app->instance($ {1:User}::class, $${2:fakeUser});${0}
endsnippetsnippet lsing "$this->app->singleton()" b
$this->app->singleton('$ {1:OSS}', function ($app) {
${1}
});${0}
endsnippetsnippet dd "dd()" b
dd($1);$ {0}
endsnippetsnippet lqlog1 "DB::connection()->enableQueryLog()" b
\DB::connection()->enableQueryLog();${0}
endsnippetsnippet lqlog2 "DB::getQueryLog()" b
$logs = \DB::getQueryLog();$ {0}
endsnippet
When trying to convert a snippet
"prefix": ["Hello World", "HW"]
it just throw an error saying something like "split() of prefix is undefined"
In order I think this should be impletment:
Hi, thanks for building this library.
Just wanted to report a problem when trying to convert this snippet file:
https://github.com/honza/vim-snippets/blob/master/UltiSnips/ruby.snippets
The output is an empty hash {}
. No errors are reported.
This other file in the same repo seems to convert fine:
https://github.com/honza/vim-snippets/blob/master/UltiSnips/rails.snippets
Thanks
Andy
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.