diff --git a/lua/plugins/completion.lua b/lua/plugins/completion.lua index 4e73457..60bb3c9 100644 --- a/lua/plugins/completion.lua +++ b/lua/plugins/completion.lua @@ -5,7 +5,9 @@ return { version = '*', dependencies = { 'rafamadriz/friendly-snippets' }, config = function() - require('luasnip.loaders.from_vscode').lazy_load() + require('luasnip.loaders.from_vscode').lazy_load({ + paths = { vim.fn.stdpath('config') .. '/snippets' }, + }) end, }, @@ -66,11 +68,11 @@ return { signature = { window = { border = 'rounded' }, }, + snippets = { preset = 'luasnip' }, sources = { default = { 'lsp', 'path', 'snippets', 'buffer' }, providers = {}, }, - snippets = { preset = 'luasnip' }, keymap = { preset = 'none', [''] = { 'select_prev', 'snippet_backward', 'fallback' }, diff --git a/lua/plugins/languages.lua b/lua/plugins/languages.lua index 7d2c1ab..facd1a9 100644 --- a/lua/plugins/languages.lua +++ b/lua/plugins/languages.lua @@ -97,7 +97,7 @@ return { local cond = require('nvim-autopairs.conds') pairs.add_rules({ rule('$', '$', { 'tex', 'latex', 'plaintex' }) - -- do not move right when repeat character + -- do not move right when repeat character :with_move(cond.none()), }) end, diff --git a/snippets/c.json b/snippets/c.json new file mode 100644 index 0000000..96cbe4e --- /dev/null +++ b/snippets/c.json @@ -0,0 +1,360 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "_FOREACH": { + "prefix": "_FOREACH", + "body": [ + "#define foreach(item, array) \\", + "\tfor(int keep = 1, \\", + "\tcount = 0,\\", + "\tsize = sizeof (array) / sizeof *(array); \\", + "\tkeep && count != size; \\", + "\tkeep = !keep, count++) \\", + "\tfor(item = (array) + count; keep; keep = !keep)" + ], + "description": "foreach loop C" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "glfw330win": { + "prefix": "glfw330win", + "body": [ + "if (!glfwInit()) {", + "log_warn(\"GLFW failed\");", + "glfwTerminate();", + "return 1;", + "}", + "glfwWindowHint(GLFW_SAMPLES, 4);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);", + "glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);", + "glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);" + ], + "description": "Glfw window hint for opengl v3.3" + }, + "gl_vertex_arr": { + "prefix": "gl_vertex_arr", + "body": [ + "glGenVertexArrays(${1:size}, &$2);", + "glBindVertexArray($2);" + ], + "description": "GL generate vertex array" + }, + "gl_vertex_buffer": { + "prefix": "gl_vertex_buffer", + "body": [ + "glGenBuffers(${1:1}, &$2);", + "glBindBuffer(${3:buffer_type}, $2);", + "glBufferData($3, sizeof($4), $4, $5)" + ], + "description": "gl generate buffer" + }, + "DBG": { + "prefix": "DBG", + "body": ["#define WHERE fprintf(stderr,\"[LOG]%s:%d\\n\",__FILE__,__LINE__);"], + "description": "Debug code line" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "_MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))\n"], + "description": "mod of N,M" + }, + "between": { + "prefix": "_BETWEEN", + "body": ["#define BETWEEN(x, a, b) ((a) <= (x) && (x) <= (b))\n"], + "description": "x is between a, b" + }, + "length" : { + "prefix": "_LENGTH", + "body": ["#define LENGTH(x) sizeof(x)/sizeof(x[0])\n"], + "description": "Array size macro" + }, + "max" : { + "prefix": "_MAX", + "body": ["#define MAX(x,y) (x) > (y) ? (x) : (y)","$0"], + "description": "Get max element" + }, + "min" : { + "prefix": "_MIN", + "body": ["#define MIN(x,y) (x) < (y) ? (x) : (y)","$0"], + "description": "Get min element" + }, + "getbit": { + "prefix": "_GETBIT", + "body": ["#define GETBIT(x,i) (x&(1<"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C program" + }, + "Standard Starter Template": { + "prefix": "sst", + "body": [ + "#include ", + "", + "int main ()", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program" + }, + "Stdlib Variant Starter Template": { + "prefix": "libsst", + "body": [ + "#include ", + "#include ", + "", + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard starter template for a C program with stdlib included" + }, + "Create linked list": { + "prefix": "clist", + "body": [ + "typedef struct _node * Link;", + "typedef struct _node node;", + "struct _node {", + "\tint value;", + "\tLink next;", + "};" + ], + "description": "Creates a linked list template" + }, + "Scan integer": { + "prefix": "sci", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan int" + }, + "Scan 2 integer": { + "prefix": "sci2", + "body": ["scanf(\"%d %d\", &$1, &$2);"], + "description": "Scan 2 int" + }, + "Scan unsigned integer": { + "prefix": "scui", + "body": ["scanf(\"%d\", &$1);"], + "description": "Scan unsigned int" + }, + "Scan float": { + "prefix": "scf", + "body": ["scanf(\"%f\", &$1);"], + "description": "Scan float" + }, + "Scan 2 float": { + "prefix": "scf2", + "body": ["scanf(\"%f %f\", &$1, &$2);"], + "description": "Scan 2 float" + }, + "Scan long": { + "prefix": "scl", + "body": ["scanf(\"%ld\", &$1);"], + "description": "Scan long" + }, + "Scan 2 long": { + "prefix": "scl2", + "body": ["scanf(\"%ld %ld\", &$1, &$2);"], + "description": "Scan 2 long" + }, + "Scan unsigned long": { + "prefix": "scul", + "body": ["scanf(\"%lu\", &$1);"], + "description": "Scan unsigned long" + }, + "Scan unsigned long long": { + "prefix": "scull", + "body": ["scanf(\"%llu\", &$1);"], + "description": "Scan unsigned long long" + }, + "Print variable of type float (2 decimal places)": { + "prefix": "pflo", + "body": ["printf(\"$1 :>> %.2f\\n\", $1);"], + "description": "Calls printf() to log value of variable of type float rounded to 2 decimal places" + }, + "Print variable of type integer": { + "prefix": "pint", + "body": ["printf(\"$1 : %d\\n\", $1);"], + "description": "Calls printf() to log value of variable of type signed integer" + }, + "Print variable of type char": { + "prefix": "pcha", + "body": ["printf(\"$1 : %c\\n\", $1);"], + "description": "Calls printf() to log value of variable of type char" + }, + "Print variable of type pointer": { + "prefix": "ppoint", + "body": ["printf(\"$1 : %p\\n\", (void *) $1);"], + "description": "Calls printf() to log value of variable of type pointer" + }, + "Print variable of type size_t": { + "prefix": "psiz", + "body": ["printf(\"$1 : %zu\\n\", $1);"], + "description": "Calls printf() to log value of variable of type size_t" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "Allocate memory using malloc": { + "prefix": "mal", + "body": [ + "${1:int} *${2:v} = malloc(${3:1} * sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using malloc(), then deallocates using free()." + }, + "Allocate memory using calloc": { + "prefix": "cal", + "body": [ + "${1:int} *${2:v} = calloc(${3:1}, sizeof($1));", + "", + "if (!$2) {", + "\tfprintf(stderr, \"Memory allocation failed!\\n\");", + "\t$4;", + "}", + "$0", + "free($2);" + ], + "description": "Allocates memory to a pointer variable using calloc(), then deallocates using free()." + }, + "X11 default incs": { + "prefix": "_X11", + "body": ["#include \n#include \n#include \n#include \n"], + "description": "X11 default library headers" + }, + "Primitive macros": { + "prefix": "_PRIMITIVE", + "body": [ + "#define i16 short", + "#define ui16 unsigned short", + "#define i32 int", + "#define ui32 unsigned int", + "#define i64 long long", + "#define ui64 unsigned long long" + ], + "description": "Primitive macros for int type" + } +} diff --git a/snippets/cpp.json b/snippets/cpp.json new file mode 100644 index 0000000..c949464 --- /dev/null +++ b/snippets/cpp.json @@ -0,0 +1,219 @@ +{ + "for": { + "prefix": "for", + "body": [ + "for (${1:size_t} ${2:i} = ${3:0}; $2 < ${4:length}; $2++) {", + "\t$0", + "}" + ], + "description": "Code snippet for 'for' loop" + }, + "*": { + "prefix": "*", + "body": ["/* $0 */"], + "description": "Block comment" + }, + "forr": { + "prefix": "forr", + "body": [ + "for (${1:size_t} ${2:i} = ${3:length} - 1; $2 >= ${4:0}; $2--) {", + "\t$0", + "}" + ], + "description": "Code snippet for reverse 'for' loop" + }, + "mod": { + "prefix": "MOD", + "body": ["#define MOD(N,M)\t((N)%(M) < 0 ? (N)%(M) + (M) : (N)%(M))"], + "description": "mod of N,M" + }, + "between": { + "prefix": "between", + "body": ["#define BETWEEN(x, a, b)\t((a) <= (x) && (x) <= (b))"], + "description": "x is between a, b" + }, + "sze" : { + "prefix": "sze", + "body": ["#define SIZE(x) sizeof(x)/sizeof(x[0])","$0"], + "description": "Array size macro" + }, + "do": { + "prefix": "do", + "body": ["do", "{", "\t$1", "} while($2);"], + "description": "Code snippet for do...while loop" + }, + "while": { + "prefix": "while", + "body": ["while ($1) {", "\t$2", "}"], + "description": "" + }, + "foreach": { + "prefix": "foreach", + "body": ["for (${1:auto} ${2:var} : ${3:collection_to_loop}) {", "\t$0", "}"], + "description": "Code snippet for range-based for loop (c++11) statement" + }, + "enum": { + "prefix": "enum", + "body": ["enum ${1:MyEnum} {", "\t$0", "};"], + "description": "Code snippet for enum" + }, + "enum class": { + "prefix": "enum class", + "body": ["enum class ${1:MyClass} {$0};"], + "description": "Code snippet for enum class (c++11)" + }, + "class": { + "prefix": "class", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1();", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1();", + "", + "private:", + "\t$2", + "};", + "", + "$1::$1()", + "{", + "}", + "", + "$1::~$1()", + "{", + "}" + ], + "description": "Code snippet for class" + }, + "classi": { + "prefix": "classi", + "body": [ + "class ${1:MyClass}", + "{", + "public:", + "\t$1() = default;", + "\t$1($1 &&) = default;", + "\t$1(const $1 &) = default;", + "\t$1 &operator=($1 &&) = default;", + "\t$1 &operator=(const $1 &) = default;", + "\t~$1() = default;", + "", + "private:", + "\t$2", + "};" + ], + "description": "Code snippet for class with inline constructor/destructor" + }, + "interface": { + "prefix": "interface", + "body": ["__interface I${1:Interface}", "{", "\t$0", "};"], + "description": "Code snippet for interface (Visual C++)" + }, + "namespace": { + "prefix": "namespace", + "body": ["namespace ${1:MyNamespace}", "{", "\t$0", "}"] + }, + "#ifdef": { + "prefix": "#ifdef", + "body": ["#ifdef ${1:DEBUG}", "$0", "#endif // ${DEBUG}"], + "description": "Code snippet for #ifdef" + }, + "#ifndef": { + "prefix": "#ifndef", + "body": ["#ifndef ${1:DEBUG}", "$0", "#endif // !$1"], + "description": "Code snippet for #ifndef" + }, + "#if": { + "prefix": "#if", + "body": ["#if ${1:0}", "$0", "#endif // $1"], + "description": "Code snippet for #if" + }, + "struct": { + "prefix": "struct", + "body": ["struct ${1:MyStruct}", "{", "\t$0", "};"], + "description": "Code snippet for struct" + }, + "switch": { + "prefix": "switch", + "body": ["switch (${1:switch_on}) {", "\tdefault:", "\t\t$0", "\t\tbreak;", "}"], + "description": "Code snippet for switch statement" + }, + "try": { + "prefix": "try", + "body": [ + "try {", + "\t", + "}", + "catch (const std::exception&)", + "{", + "\t$1", + "}" + ], + "description": "Code snippet for try catch" + }, + "union": { + "prefix": "union", + "body": ["union ${1:MyUnion}", "{", "\t$0", "};"], + "description": "Code snippet for union" + }, + "printf": { + "prefix": "printf", + "body": ["printf(\"$1\\n\"$0);"], + "description": "Generic printf() snippet" + }, + "sprintf": { + "prefix": "sprintf", + "body": ["sprintf($1, \"$2\\n\"$0);"], + "description": "Generic sprintf() snippet" + }, + "fprintf": { + "prefix": "fprintf", + "body": ["fprintf(${1:stderr}, \"$2\\n\"$0);"], + "description": "Generic fprintf() snippet" + }, + "scanf": { + "prefix": "scanf", + "body": ["scanf(\"$1\"$0);"], + "description": "Generic scanf() snippet" + }, + "sscanf": { + "prefix": "sscanf", + "body": ["sscanf($1, \"$2\"$0);"], + "description": "Generic sscanf() snippet" + }, + "fscanf": { + "prefix": "fscanf", + "body": ["fscanf($1, \"$2\"$0);"], + "description": "Generic fscanf() snippet" + }, + "#inc": { + "prefix": "#inc", + "body": ["#include \"$0\""], + "description": "Code snippet for #include \" \"" + }, + "#inc<": { + "prefix": "#inc<", + "body": ["#include <$0>"], + "description": "Code snippet for #include < >" + }, + "#def": { + "prefix": "def", + "body": ["#define $0"], + "description": "Code snippet for #define \" \"" + }, + "Main function template": { + "prefix": "main", + "body": [ + "int main (int argc, char *argv[])", + "{", + "\t$0", + "\treturn 0;", + "}" + ], + "description": "A standard main function for a C++ program" + } +} diff --git a/snippets/css.json b/snippets/css.json new file mode 100644 index 0000000..294af23 --- /dev/null +++ b/snippets/css.json @@ -0,0 +1,651 @@ +{ + "align-items": { + "prefix": "ai", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,start,end,self-start,self-end|};", + "description": "initial value: stretch" + }, + "align-items: baseline": { + "prefix": "aib", + "body": "align-items: baseline;" + }, + "align-items: center": { + "prefix": "aic", + "body": "align-items: center;" + }, + "align-items: flex-start": { + "prefix": "aifs", + "body": "align-items: flex-start;" + }, + "align-items: flex-end": { + "prefix": "aife", + "body": "align-items: flex-end;" + }, + "align-items: stretch": { + "prefix": "ais", + "body": "align-items: stretch;" + }, + "align-self": { + "prefix": "as", + "body": "align-items: ${1|flex-start,flex-end,center,baseline,stretch,auto|};", + "description": "initial value: auto" + }, + "animation": { + "prefix": "ani", + "body": "animation: ${1:name} ${2:1s} ${3|linear,ease-in-out,ease,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "animation: name duration timing-function delay direction count fill-mode play-state" + }, + "animation-delay": { + "prefix": "anide", + "body": "animation-delay: ${0:1s};" + }, + "animation-direction": { + "prefix": "anidi", + "body": "animation-direction: ${1|alternate,alternate-reverse,reverse,normal|};", + "description": "initial value: normal" + }, + "animation-duratuion": { + "prefix": "anidu", + "body": "animation-duration: ${0:1s};" + }, + "animation-fill-mode": { + "prefix": "anifm", + "body": "animation-fill-mode: ${1|forwards,backwards,both,none|};", + "description": "initial value: none" + }, + "animation-iteration-count": { + "prefix": "aniic", + "body": "animation-iteration-count: ${0:infinite};", + "description": "initial value: 1" + }, + "animation-name": { + "prefix": "anin", + "body": "animation-name: ${0:name};" + }, + "animation-play-state": { + "prefix": "anips", + "body": "animation-play-state: ${1|paused,running|};", + "description": "initial value: running" + }, + "animation-timing-function": { + "prefix": "anitf", + "body": "animation-timing-function: ${1|linear,ease,ease-in-out,ease-in,ease-out,step-start,step-end,steps,cubic-bezier|};", + "description": "initial value: ease" + }, + "background": { + "prefix": "bg", + "body": "background: ${0:#fff};", + "description": "background: image position/size repeat attachment box box" + }, + "background-attachment": { + "prefix": "bga", + "body": "background-attachment: ${1|fixed,scroll,local|};", + "description": "initial value: scroll" + }, + "background-color": { + "prefix": "bgc", + "body": "background-color: ${0:#fff};" + }, + "background-clip": { + "prefix": "bgcl", + "body": "background-clip: ${1|border-box,padding-box,content-box,text|};", + "description": "initial value: border-box" + }, + "background-image": { + "prefix": "bgi", + "body": "background-image: url('${0:background.jpg}');" + }, + "background-origin": { + "prefix": "bgo", + "body": "background-origin: ${1|border-box,padding-box,content-box|};", + "description": "initial value: padding-box" + }, + "background-position": { + "prefix": "bgp", + "body": "background-position: ${1:left} ${2:top};" + }, + "background-repeat": { + "prefix": "bgr", + "body": "background-repeat: ${1|no-repeat,repeat-x,repeat-y,repeat,space,round|};", + "description": "initial value: repeat" + }, + "background-repeat: repeat": { + "prefix": "bgrr", + "body": "background-repeat: repeat;" + }, + "background-repeat: repeat-x": { + "prefix": "bgrx", + "body": "background-repeat: repeat-x;" + }, + "background-repeat: repeat-y": { + "prefix": "bgry", + "body": "background-repeat: repeat-y;" + }, + "background-repeat: no-repeat": { + "prefix": "bgrn", + "body": "background-repeat: no-repeat;" + }, + "background-size": { + "prefix": "bgs", + "body": "background-size: ${0:cover};" + }, + "border": { + "prefix": "bor", + "body": "border: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border: none": { + "prefix": "born", + "body": "border: none;" + }, + "border-color": { + "prefix": "borc", + "body": "border-color: ${0:#000};" + }, + "border-style": { + "prefix": "bors", + "body": "border-style: ${1|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|};" + }, + "border-width": { + "prefix": "borw", + "body": "border-width: ${0:1px};" + }, + "border-bottom": { + "prefix": "borb", + "body": "border-bottom: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-left": { + "prefix": "borl", + "body": "border-left: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-right": { + "prefix": "borr", + "body": "border-right: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-top": { + "prefix": "bort", + "body": "border-top: ${1:1px} ${2|solid,dashed,dotted,double,groove,ridge,inset,outset,none,hidden|} ${0:#000};" + }, + "border-radius": { + "prefix": "br", + "body": "border-radius: ${0:2px};" + }, + "bottom": { + "prefix": "bot", + "body": "bottom: ${0:0};" + }, + "box-shadow": { + "prefix": "bos", + "body": "box-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "box-shadow: x-offset y-offset blur spread color" + }, + "box-sizing": { + "prefix": "boz", + "body": "box-sizing: ${1|border-box,content-box|};", + "description": "initial value: content-box" + }, + "clear": { + "prefix": "clr", + "body": "clear: ${1|both,left,right,none|};" + }, + "color": { + "prefix": "col", + "body": "color: ${0:#000};" + }, + "content": { + "prefix": "con", + "body": "content: '$0';" + }, + "cursor": { + "prefix": "cur", + "body": "cursor: ${1|auto,default,alias,cell,copy,crosshair,context-menu,help,grab,grabbing,move,none,no-drop,not-allowed,pointer,progress,e-resize,all-scroll,text,wait,vertical-text,zoom-in,zoom-out|};", + "description": "initial value: auto" + }, + "cursor: pointer": { + "prefix": "curp", + "body": "cursor: pointer;" + }, + "cursor: default": { + "prefix": "curd", + "body": "cursor: default;" + }, + "display": { + "prefix": "dis", + "body": "display: ${1|none,block,inline,inline-block,flex,inline-flex,list-item,table,inline-table,table-caption,table-cell,table-row,table-row-group,table-column|};" + }, + "display: block": { + "prefix": "disb", + "body": "display: block;" + }, + "display: inline-block": { + "prefix": "disi", + "body": "display: inline-block;" + }, + "display: none": { + "prefix": "disn", + "body": "display: none;" + }, + "display: flex": { + "prefix": "disf", + "body": "display: flex;" + }, + "flex": { + "prefix": "flex", + "body": "flex: ${1:1} ${2:1} ${3:auto};", + "description": "flex: grow shrink basis" + }, + "flex (alt)": { + "prefix": "fle", + "body": "flex: ${1:1} ${2:1} ${3:auto};" + }, + "flex-direction": { + "prefix": "fld", + "body": "flex-direction: ${1|row,row-reverse,column,column-reverse|};", + "description": "initial value: row" + }, + "flex-direction: row": { + "prefix": "fldr", + "body": "flex-direction: row;" + }, + "flex-direction: column": { + "prefix": "fldc", + "body": "flex-direction: column;" + }, + "flex-flow": { + "prefix": "flf", + "body": "flex-flow: ${1|row,row-reverse,column,column-reverse|} ${2|wrap,wrap-reverse,nowrap|};" + }, + "flex-wrap": { + "prefix": "flw", + "body": "flex-wrap: ${1|wrap,wrap-reverse,nowrap|};", + "description": "initial value: nowrap" + }, + "float": { + "prefix": "fl", + "body": "float: ${1|left,right,none|};" + }, + "float: left": { + "prefix": "fll", + "body": "float: left;" + }, + "float: right": { + "prefix": "flr", + "body": "float: right;" + }, + "float: none": { + "prefix": "fln", + "body": "float: none;" + }, + "font-family": { + "prefix": "ff", + "body": "font-family: ${0:arial};" + }, + "font-size": { + "prefix": "fz", + "body": "font-size: ${0:12px};" + }, + "font-style": { + "prefix": "fst", + "body": "font-style: ${1|italic,oblique,normal|};" + }, + "font-style: italic": { + "prefix": "fsti", + "body": "font-style: italic;" + }, + "font-style: normal": { + "prefix": "fstn", + "body": "font-style: normal;" + }, + "font-style: oblique": { + "prefix": "fsto", + "body": "font-style: oblique;" + }, + "font-weight": { + "prefix": "fw", + "body": "font-weight: ${0:bold};" + }, + "font-weight: bold": { + "prefix": "fwb", + "body": "font-weight: bold;" + }, + "font-weight: light": { + "prefix": "fwl", + "body": "font-weight: light;" + }, + "font-weight: normal": { + "prefix": "fwn", + "body": "font-weight: normal;" + }, + "font": { + "prefix": "ft", + "body": "font: ${0:12px/1.5};", + "description": "font: [weight style variant stretch] size/line-height family" + }, + "height": { + "prefix": "hei", + "body": "height: ${0:1px};" + }, + "justify-content": { + "prefix": "jc", + "body": "justify-content: ${1|flex-start,flex-end,center,space-between,space-around|};", + "description": "initial value: flex-start" + }, + "justify-content: flex-start": { + "prefix": "jcfs", + "body": "justify-content: flex-start;" + }, + "justify-content: flex-end": { + "prefix": "jcfe", + "body": "justify-content: flex-end;" + }, + "justify-content: center": { + "prefix": "jcc", + "body": "justify-content: center;" + }, + "justify-content: space-around": { + "prefix": "jcsa", + "body": "justify-content: space-around;" + }, + "justify-content: space-between": { + "prefix": "jcsb", + "body": "justify-content: space-between;" + }, + "list-style": { + "prefix": "lis", + "body": "list-style: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|} ${2|outside,inside|};", + "description": "list-style: type position image" + }, + "list-style-position": { + "prefix": "lisp", + "body": "${1|outside,inside|}", + "description": "initial value: outside" + }, + "list-style-type": { + "prefix": "list", + "body": "list-style-type: ${1|disc,circle,square,decimal,lower-roman,upper-roman,lower-alpha,upper-alpha,none,armenian,cjk-ideographic,georgian,lower-greek,hebrew,hiragana,hiragana-iroha,katakana,katakana-iroha,lower-latin,upper-latin|};", + "description": "initial value: disc" + }, + "list-style-type: circle": { + "prefix": "listc", + "body": "list-style-type: circle;" + }, + "list-style-type: disc": { + "prefix": "listd", + "body": "list-style-type: disc;" + }, + "list-style-type: none": { + "prefix": "listn", + "body": "list-style-type: none;" + }, + "list-style-type: square": { + "prefix": "lists", + "body": "list-style-type: square;" + }, + "list-style-type: lower-roman": { + "prefix": "listlr", + "body": "list-style-type: lower-roman;" + }, + "list-style-type: upper-roman": { + "prefix": "listur", + "body": "list-style-type: upper-roman;" + }, + "left": { + "prefix": "lef", + "body": "left: ${0:0};" + }, + "line-height": { + "prefix": "lh", + "body": "line-height: ${0:1.5};" + }, + "letter-spacing": { + "prefix": "ls", + "body": "letter-spacing: ${0:2px};" + }, + "letter-spacing: normal": { + "prefix": "lsn", + "body": "letter-spacing: normal;" + }, + "margin": { + "prefix": "mar", + "body": "margin: ${0:0};" + }, + "margin-bottom": { + "prefix": "marb", + "body": "margin-bottom: ${0:0};" + }, + "margin-left": { + "prefix": "marl", + "body": "margin-left: ${0:0};" + }, + "margin-right": { + "prefix": "marr", + "body": "margin-right: ${0:0};" + }, + "margin-top": { + "prefix": "mart", + "body": "margin-top: ${0:0};" + }, + "margin: 0 auto": { + "prefix": "mara", + "body": "margin: 0 auto;" + }, + "min-height": { + "prefix": "mih", + "body": "min-height: ${0:1px};" + }, + "min-width": { + "prefix": "miw", + "body": "min-width: ${0:1px};" + }, + "max-height": { + "prefix": "mah", + "body": "max-height: ${0:1px};" + }, + "max-width": { + "prefix": "maw", + "body": "max-width: ${0:1px};" + }, + "opacity": { + "prefix": "opa", + "body": "opacity: ${0:0};" + }, + "overflow": { + "prefix": "ov", + "body": "overflow: ${1|visible,hidden,scroll,auto,clip|};" + }, + "overflow: auto": { + "prefix": "ova", + "body": "overflow: auto;" + }, + "overflow: hidden": { + "prefix": "ovh", + "body": "overflow: hidden;" + }, + "overflow: scroll": { + "prefix": "ovs", + "body": "overflow: scroll;" + }, + "overflow: visible": { + "prefix": "ovv", + "body": "overflow: visible;" + }, + "padding": { + "prefix": "pad", + "body": "padding: ${0:0};" + }, + "padding-bottom": { + "prefix": "padb", + "body": "padding-bottom: ${0:0};" + }, + "padding-left": { + "prefix": "padl", + "body": "padding-left: ${0:0};" + }, + "padding-right": { + "prefix": "padr", + "body": "padding-right: ${0:0};" + }, + "padding-top": { + "prefix": "padt", + "body": "padding-top: ${0:0};" + }, + "position": { + "prefix": "pos", + "body": "position: ${1|relative,absolute,fixed,sticky,static|};" + }, + "position absolute": { + "prefix": "posa", + "body": "position: absolute;" + }, + "position fixed": { + "prefix": "posf", + "body": "position: fixed;" + }, + "position relative": { + "prefix": "posr", + "body": "position: relative;" + }, + "position sticky": { + "prefix": "poss", + "body": "position: sticky;" + }, + "right": { + "prefix": "rig", + "body": "right: ${0:0};" + }, + "text-align": { + "prefix": "ta", + "body": "text-align: ${1|center,left,right,justify,start,end|};" + }, + "text-align: center": { + "prefix": "tac", + "body": "text-align: center;" + }, + "text-align: left": { + "prefix": "tal", + "body": "text-align: left;" + }, + "text-align: right": { + "prefix": "tar", + "body": "text-align: right;" + }, + "text-decoration": { + "prefix": "td", + "body": "text-decoration: ${1|none,underline,overline,line-through|};" + }, + "text-decoration: underline": { + "prefix": "tdu", + "body": "text-decoration: underline;" + }, + "text-decoration: none": { + "prefix": "tdn", + "body": "text-decoration: none;" + }, + "text-decoration: line-through": { + "prefix": "tdl", + "body": "text-decoration: line-through;" + }, + "text-indent": { + "prefix": "ti", + "body": "text-indent: ${0:2em};" + }, + "text-shadow": { + "prefix": "ts", + "body": "text-shadow: ${1:1px} ${2:1px} ${3:1px} ${4:1px} ${0:rgba(0, 0, 0, .5)};", + "description": "text-shadow: x-offset y-offset blur spread color" + }, + "text-transform": { + "prefix": "tt", + "body": "text-transform: ${1|capitalize,uppercase,lowercase,full-width,none|};" + }, + "top": { + "prefix": "top", + "body": "top: ${0:0};" + }, + "vertical-align": { + "prefix": "va", + "body": "vertical-align: ${1|baseline,middle,top,bottom,sub,super,text-top,text-bottom|};" + }, + "vertical-align: bottom": { + "prefix": "vab", + "body": "vertical-align: bottom;" + }, + "vertical-align: middle": { + "prefix": "vam", + "body": "vertical-align: middle;" + }, + "vertical-align: top": { + "prefix": "vat", + "body": "vertical-align: top;" + }, + "visibility": { + "prefix": "vis", + "body": "visibility: ${1|visible,hidden,collapse|};" + }, + "visibility: visible": { + "prefix": "visv", + "body": "visibility: visible;" + }, + "visibility: hidden": { + "prefix": "vish", + "body": "visibility: hidden;" + }, + "word-break": { + "prefix": "wb", + "body": "word-break: ${1|break-all,keep-all,break-word,normal|};" + }, + "width": { + "prefix": "wid", + "body": "width: ${0:0};" + }, + "width: auto": { + "prefix": "wida", + "body": "width: auto;" + }, + "white-space": { + "prefix": "ws", + "body": "white-space: ${1|nowrap,pre,pre-wrap,pre-line,normal|};" + }, + "white-space: nowrap": { + "prefix": "wsn", + "body": "white-space: nowrap;" + }, + "white-space: pre": { + "prefix": "wsp", + "body": "white-space: pre;" + }, + "word-wrap": { + "prefix": "ww", + "body": "word-wrap: ${1|break-word,break-spaces,normal|};" + }, + "z-index": { + "prefix": "zi", + "body": "z-index: ${0:-1};" + }, + "@import": { + "prefix": "imp", + "body": "@import '${0:filename}';" + }, + "@mixin": { + "prefix": "mix", + "body": "@mixin ${1:name} {\n $0\n}" + }, + "@include": { + "prefix": "inc", + "body": "@include ${0:mixin};" + }, + "@keyframes": { + "prefix": "key", + "body": "@keyframes ${1:name} {\n $0\n}" + }, + "@media": { + "prefix": "med", + "body": "@media screen and (${1:max-width: 300px}) {\n $0\n}" + }, + "!important": { + "prefix": "!", + "body": "!important" + }, + "!important (alt)": { + "prefix": "i", + "body": "!important" + } +} diff --git a/snippets/django.json b/snippets/django.json new file mode 100644 index 0000000..0bb986f --- /dev/null +++ b/snippets/django.json @@ -0,0 +1,1052 @@ +{ + "adminview": { + "prefix": "adminview", + "body": [ + "@admin.register(${1})", + "class ${1}Admin(admin.ModelAdmin):", + "\t'''Admin View for ${1}'''", + "", + "\tlist_display = ('${2}',)", + "\tlist_filter = ('${3}',)", + "\tinlines = [", + "\t\t${4}Inline,", + "\t]", + "\traw_id_fields = ('${5}',)", + "\treadonly_fields = ('${6}',)", + "\tsearch_fields = ('${7}',)", + "\tdate_hierarchy = '${8}'", + "\tordering = ('${9}',)" + ], + "description": "Model Admin View", + "scope": "source.python" + }, + "stackedinline": { + "prefix": "stackedinline", + "body": [ + "class ${1}Inline(admin.StackedInline):", + "\t'''Stacked Inline View for ${1}'''", + "", + "\tmodel = ${2:${1}}", + "\tmin_num = ${3:3}", + "\tmax_num = ${4:20}", + "\textra = ${5:1}", + "\traw_id_fields = (${6},)" + ], + "description": "Stacked Inline", + "scope": "source.python" + }, + "tabularinline": { + "prefix": "tabularinline", + "body": [ + "class ${1}Inline(admin.TabularInline):", + "\t'''Tabular Inline View for ${1}'''", + "", + "\tmodel = ${2:${1}}", + "\tmin_num = ${3:3}", + "\tmax_num = ${4:20}", + "\textra = ${5:1}", + "\traw_id_fields = (${6},)" + ], + "description": "Tabular Inline", + "scope": "source.python" + }, + "simplelistfilter": { + "prefix": "simplelistfilter", + "body": [ + "class ${1:NAME}Filter(admin.SimpleListFilter):", + "", + "\ttitle = '$2'", + "\tparameter_name = '$0'", + "", + "\tdef lookups(self, request, model_admin):", + "\t\tpass", + "", + "\tdef queryset(self, request, queryset):", + "\t\treturn queryset" + ], + "description": "Admin SimpleList Filter", + "scope": "source.python" + }, + "iadmin": { + "prefix": "iadmin", + "body": "from django.contrib import admin", + "description": "from ... import admin", + "scope": "source.python" + }, + "iadminsite": { + "prefix": "iadminsite", + "body": "from django.contrib.admin import AdminSite", + "description": "from ... import AdminSite", + "scope": "source.python" + }, + "register": { + "prefix": "register", + "body": "admin.site.register($1)", + "description": "register the model class without providing a ModelAdmin description.", + "scope": "source.python" + }, + "registermadmin": { + "prefix": "registermadmin", + "body": "admin.site.register($1, $1Admin)", + "description": "register the model class providing a ModelAdmin description", + "scope": "source.python" + }, + "fieldsets": { + "prefix": "fieldsets", + "body": [ + "fieldsets = (", + "\t(None, {", + "\t\t'fields': (", + "\t\t\t$1", + "\t\t),", + "\t}),", + ")" + ], + "description": "", + "scope": "source.python" + }, + "Form": { + "prefix": "Form", + "body": [ + "class ${1:FORMNAME}(forms.Form):", + "\t\"\"\"${2:$1 definition}.\"\"\"", + "", + "\t${3:# TODO: Define form fields here}", + "" + ], + "description": "Form", + "scope": "source.python" + }, + "ModelForm": { + "prefix": "ModelForm", + "body": [ + "class ${1:MODELNAME}Form(forms.ModelForm):", + "\t\"\"\"${2:Form definition for $1}.\"\"\"", + "", + "\tclass Meta:", + "\t\t\"\"\"Meta definition for ${1}form.\"\"\"", + "", + "\t\tmodel = $1", + "\t\tfields = ('$3',)", + "" + ], + "description": "ModelForm", + "scope": "source.python" + }, + "fbool": { + "prefix": "fbool", + "body": "${1:FIELDNAME} = forms.BooleanField($2, required=${3:False})", + "description": "BooleanField (fbool)", + "scope": "source.python" + }, + "fchar": { + "prefix": "fchar", + "body": "${1:FIELDNAME} = forms.CharField($2,${3: max_length=$4,} required=${5:False})", + "description": "CharField (fchar)", + "scope": "source.python" + }, + "fchoice": { + "prefix": "fchoice", + "body": "${1:FIELDNAME} = forms.ChoiceField($2, choices=[${3:CHOICES}], required=${4:False})", + "description": "ChoiceField (fchoice)", + "scope": "source.python" + }, + "fcombo": { + "prefix": "fcombo", + "body": "${1:FIELDNAME} = forms.ComboField($2)", + "description": "ComboField (fcombo)", + "scope": "source.python" + }, + "fdate": { + "prefix": "fdate", + "body": "${1:FIELDNAME} = forms.DateField($2, required=${3:False})", + "description": "DateField (fdate)", + "scope": "source.python" + }, + "fdatetime": { + "prefix": "fdatetime", + "body": "${1:FIELDNAME} = forms.DateTimeField($2, required=${3:False})", + "description": "DateTimeField (fdatetime)", + "scope": "source.python" + }, + "fdecimal": { + "prefix": "fdecimal", + "body": "${1:FIELDNAME} = forms.DecimalField($2, required=${3:False})", + "description": "DecimalField (fdecimal)", + "scope": "source.python" + }, + "fduration": { + "prefix": "fduration", + "body": "${1:FIELDNAME} = forms.DurationField($2, required=${3:False})", + "description": "DurationField (fduration)", + "scope": "source.python" + }, + "femail": { + "prefix": "femail", + "body": "${1:FIELDNAME} = forms.EmailField($2, required=${3:False})", + "description": "EmailField (femail)", + "scope": "source.python" + }, + "ffile": { + "prefix": "ffile", + "body": "${1:FIELDNAME} = forms.FileField($2,${3: max_length=$4,} required=${5:False})", + "description": "FileField (ffile)", + "scope": "source.python" + }, + "ffilepath": { + "prefix": "ffilepath", + "body": "${1:FIELDNAME} = forms.FilePathField($2, path=${3:/absolute_path/}, required=${4:False})", + "description": "FilePathField (ffilepath)", + "scope": "source.python" + }, + "ffloat": { + "prefix": "ffloat", + "body": "${1:FIELDNAME} = forms.FloatField($2, required=${3:False})", + "description": "FloatField (ffloat)", + "scope": "source.python" + }, + "fip": { + "prefix": "fip", + "body": "${1:FIELDNAME} = forms.IPAddressField($2)", + "description": "IPAddressField (fip).\n\nThis field has been deprecated since version 1.7 in favor of GenericIPAddressField.\n\n", + "scope": "source.python" + }, + "fgenericip": { + "prefix": "fip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField($2)", + "description": "IPAddressField (fgenericip)", + "scope": "source.python" + }, + "fimg": { + "prefix": "fimg", + "body": "${1:FIELDNAME} = forms.ImageField($2, required=${3:False})", + "description": "ImageField (fimg)", + "scope": "source.python" + }, + "fint": { + "prefix": "fint", + "body": "${1:FIELDNAME} = forms.IntegerField($2, required=${3:False})", + "description": "IntegerField (fint)", + "scope": "source.python" + }, + "fmochoice": { + "prefix": "fmochoice", + "body": "${1:FIELDNAME} = forms.ModelChoiceField($2)", + "description": "ModelChoiceField (fmochoice)", + "scope": "source.python" + }, + "fmomuchoice": { + "prefix": "fmomuchoice", + "body": "${1:FIELDNAME} = forms.ModelMultipleChoiceField($2)", + "description": "ModelMultipleChoiceField (fmomuchoice)", + "scope": "source.python" + }, + "fmuval": { + "prefix": "fmuval", + "body": "${1:FIELDNAME} = forms.MultiValueField($2)", + "description": "MultiValueField (fmuval)", + "scope": "source.python" + }, + "fmuchoice": { + "prefix": "fmuchoice", + "body": "${1:FIELDNAME} = forms.MultipleChoiceField($2, choices=[${3:CHOICES}], required=${4:False})", + "description": "MultipleChoiceField (fmuchoice)", + "scope": "source.python" + }, + "ftypedmuchoice": { + "prefix": "ftypedmuchoice", + "body": "${1:FIELDNAME} = forms.TypedMultipleChoiceField($2, choices=[${3:CHOICES}], coerce=${4:TYPE}, required=${5:False})", + "description": "TypedMultipleChoiceField (ftypedmuchoice)", + "scope": "source.python" + }, + "fnullbool": { + "prefix": "fnullbool", + "body": "${1:FIELDNAME} = forms.NullBooleanField($2, required=${3:False})", + "description": "NullBooleanField (fnullbool)", + "scope": "source.python" + }, + "fregex": { + "prefix": "fregex", + "body": "${1:FIELDNAME} = forms.RegexField($2, regex=${3:REGEX}, required=${4:False})", + "description": "RegexField (fregex)", + "scope": "source.python" + }, + "fslug": { + "prefix": "fslug", + "body": "${1:FIELDNAME} = forms.SlugField($2, allow_unicode=${3:False}, required=${4:False})", + "description": "SlugField (fslug)", + "scope": "source.python" + }, + "fsdatetime": { + "prefix": "fsdatetime", + "body": "${1:FIELDNAME} = forms.SplitDateTimeField($2)", + "description": "SplitDateTimeField (fsdatetime)", + "scope": "source.python" + }, + "ftime": { + "prefix": "ftime", + "body": "${1:FIELDNAME} = forms.TimeField($2, required=${3:False})", + "description": "TimeField (ftime)", + "scope": "source.python" + }, + "ftchoice": { + "prefix": "ftchoice", + "body": "${1:FIELDNAME} = forms.TypedChoiceField($2, required=${3:False})", + "description": "TypedChoiceField (ftchoice)", + "scope": "source.python" + }, + "ftmuchoice": { + "prefix": "ftmuchoice", + "body": "${1:FIELDNAME} = forms.TypedMultipleChoiceField($2)", + "description": "TypedMultipleChoiceField (ftmuchoice)", + "scope": "source.python" + }, + "furl": { + "prefix": "furl", + "body": "${1:FIELDNAME} = forms.URLField($2, required=${3:False})", + "description": "URLField (furl)", + "scope": "source.python" + }, + "fuuid": { + "prefix": "fuuid", + "body": "${1:FIELDNAME} = forms.UUIDField($2, required=${3:False})", + "description": "UUIDField (fuuid)", + "scope": "source.python" + }, + "fsimplearray": { + "prefix": "fsimplearray", + "body": "${1:FIELDNAME} = SimpleArrayField()", + "description": "SimpleArrayField (fsimplearray).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fsplitarray": { + "prefix": "fsplitarray", + "body": "${1:FIELDNAME} = SplitArrayField()", + "description": "SplitArrayField (fsplitarray).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fhstore": { + "prefix": "fhstore", + "body": "${1:FIELDNAME} = HStoreField()", + "description": "HStoreField (fhstore).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fjson": { + "prefix": "fjson", + "body": "${1:FIELDNAME} = JSONField()", + "description": "JSONField (fjson).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fintrange": { + "prefix": "fintrange", + "body": "${1:FIELDNAME} = IntegerRangeField()", + "description": "IntegerRangeField (fintrange).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "ffloatrange": { + "prefix": "ffloatrange", + "body": "${1:FIELDNAME} = FloatRangeField()", + "description": "FloatRangeField (ffloatrange).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fdatetimerange": { + "prefix": "fdatetimerange", + "body": "${1:FIELDNAME} = DateTimeRangeField()", + "description": "DateTimeRangeField (fdatetimerange).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "fdaterange": { + "prefix": "fdaterange", + "body": "${1:FIELDNAME} = DateRangeField()", + "description": "DateRangeField (fdaterange).\n\n*PostgreSQL specific form fields*.", + "scope": "source.python" + }, + "ffi": { + "prefix": "ffi", + "body": "from .forms import $1", + "description": "", + "scope": "source.python" + }, + "iforms": { + "prefix": "iforms", + "body": "from django import forms", + "description": "from ... import forms", + "scope": "source.python" + }, + "ipostgresff": { + "prefix": "ipostgresff", + "body": "from django.contrib.postgres.forms import ${1|SimpleArrayField,SplitArrayField,HStoreField,JSONField,IntegerRangeField,FloatRangeField,DateTimeRangeField,DateRangeField|}", + "description": "PostgreSQL specific forms fields", + "scope": "source.python" + }, + "clean_data": { + "prefix": "clean_data", + "body": [ + "def clean_${1:FIELD}(self):", + "\t${1:FIELD} = self.cleaned_data.get('${1:FIELD}')", + "\n\n\t # TODO Validation\n", + "\treturn ${1:FIELD}" + ], + "description": "", + "scope": "source.python" + }, + "Model_full": { + "prefix": "Model_full", + "body": [ + "class ${1:MODELNAME}(models.Model):", + "\t\"\"\"${2:Model definition for $1}.\"\"\"", + "", + "\t${3:# TODO: Define fields here}", + "", + "\tclass Meta:", + "\t\t\"\"\"Meta definition for $1.\"\"\"", + "", + "\t\tverbose_name = '$1'", + "\t\tverbose_name_plural = '$1s'", + "", + "\tdef ${4|__str__,__unicode__|}(self):", + "\t\t\"\"\"Unicode representation of $1.\"\"\"", + "\t\t${7|pass,return '{}'.format(self. ) # TODO,return f'{self. }' # TODO|}", + "", + "\tdef save(self):", + "\t\t\"\"\"Save method for $1.\"\"\"", + "\t\tpass", + "", + "\tdef get_absolute_url(self):", + "\t\t\"\"\"Return absolute url for $1.\"\"\"", + "\t\treturn ('')", + "", + "\t${6:# TODO: Define custom methods here}", + "" + ], + "description": "Model (full)", + "scope": "source.python" + }, + "Model": { + "prefix": "Model", + "body": [ + "class ${1:MODELNAME}(models.Model):", + "\t\"\"\"${2:Model definition for $1}.\"\"\"", + "", + "\t${3:# TODO: Define fields here}", + "", + "\tclass Meta:", + "\t\t\"\"\"Meta definition for $1.\"\"\"", + "", + "\t\tverbose_name = '$1'", + "\t\tverbose_name_plural = '$1s'", + "", + "\tdef ${4|__str__,__unicode__|}(self):", + "\t\t\"\"\"Unicode representation of $1.\"\"\"", + "\t\t${5|pass,return '{}'.format(self. ) # TODO,return f'{self. }' # TODO|}", + "" + ], + "description": "Model", + "scope": "source.python" + }, + "modelmixin": { + "prefix": "modelmixin", + "body": [ + "class $1Mixin(models.Model):", + "\t${2:# TODO}\r\n", + "\tclass Meta:", + "\t\tabstract = True" + ], + "description": "", + "scope": "source.python" + }, + "queryset": { + "prefix": "qs", + "body": ["class $1QuerySet(models.QuerySet):", "\tpass"], + "description": "", + "scope": "source.python" + }, + "manager": { + "prefix": "mngr", + "body": [ + "class $1Manager(models.Manager):", + "\tdef get_queryset(self):", + "\t\treturn super ($1Manager, self).get_queryset().${2|filter,exclude,order_by,distinct,reverse|}($3)" + ], + "description": "Add extra Manager methods", + "scope": "source.python" + }, + "queryset_from_manager": { + "prefix": "qs_mngr", + "body": [ + "class $1Manager(models.Manager):", + "\tdef get_queryset(self):", + "\t\treturn $1QuerySet(self.model, using=self._db)" + ], + "description": "Modify the initial QuerySet the Manager returns.", + "scope": "source.python" + }, + "mauto": { + "prefix": "mauto", + "body": "${1:FIELDNAME} = models.AutoField($2)", + "description": "AutoField (mauto).\n\nAn IntegerField that automatically increments according to available IDs.\n\n", + "scope": "source.python" + }, + "mbigauto": { + "prefix": "mbigauto", + "body": "${1:FIELDNAME} = models.BigAutoField($2)", + "description": "BigAutoField (mbigauto).\n\n[New in Django 1.10.]\n\nA 64-bit integer, much like an AutoField.\n\n", + "scope": "source.python" + }, + "mbigint": { + "prefix": "mbigint", + "body": "${1:FIELDNAME} = models.BigIntegerField($2)", + "description": "BigIntegerField (mbigint).\n\nA 64-bit integer, much like an IntegerField.\n\n", + "scope": "source.python" + }, + "mbinary": { + "prefix": "mbinary", + "body": "${1:FIELDNAME} = models.BinaryField($2)", + "description": "BinaryField (mbinary).\n\nA field to store raw binary data.\n\n", + "scope": "source.python" + }, + "mbool": { + "prefix": "mbool", + "body": "${1:FIELDNAME} = models.BooleanField($2)", + "description": "BooleanField (mbool).\n\nA true/false field.\n\n", + "scope": "source.python" + }, + "mchar": { + "prefix": "mchar", + "body": "${1:FIELDNAME} = models.CharField($2, max_length=${3:50})", + "description": "CharField (mchar)", + "scope": "source.python" + }, + "mcoseint": { + "prefix": "mcoseint", + "body": "${1:FIELDNAME} = models.CommaSeparatedIntegerField($2)", + "description": "CommaSeparatedIntegerField (mcoseint).\n\nThis field is deprecated since 1.9 in favor of CharField with validators.\n\n", + "scope": "source.python" + }, + "mdate": { + "prefix": "mdate", + "body": "${1:FIELDNAME} = models.DateField($2, auto_now=${3:False}, auto_now_add=${4:False})", + "description": "DateField (mdate).\n\nA date, represented in Python by a datetime.date instance.\n\n", + "scope": "source.python" + }, + "mdatetime": { + "prefix": "mdatetime", + "body": "${1:FIELDNAME} = models.DateTimeField($2, auto_now=${3:False}, auto_now_add=${4:False})", + "description": "DateTimeField (mdatetime).\n\nA date, represented in Python by a datetime.datetime instance.\n\n", + "scope": "source.python" + }, + "mdecimal": { + "prefix": "mdecimal", + "body": "${1:FIELDNAME} = models.DecimalField($2, max_digits=${3:5}, decimal_places=${4:2})", + "description": "DecimalField (mdecimal).\n\nA fixed-precision decimal number, represented in Python by a Decimal instance.\n\n", + "scope": "source.python" + }, + "mduration": { + "prefix": "mduration", + "body": "${1:FIELDNAME} = models.DurationField($2)", + "description": "DurationField (mduration).\n\nA field for storing periods of time - modeled in Python by timedelta.\n\n", + "scope": "source.python" + }, + "memail": { + "prefix": "memail", + "body": "${1:FIELDNAME} = models.EmailField($2, max_length=${3:254})", + "description": "EmailField (memail).\n\nA CharField that checks that the value is a valid email address.\n\n", + "scope": "source.python" + }, + "mfile": { + "prefix": "mfile", + "body": "${1:FIELDNAME} = models.FileField($2, upload_to=${3:None}, max_length=${4:100})", + "description": "FileField (mfile).\n\nA file-upload field.\n\n", + "scope": "source.python" + }, + "mfilepath": { + "prefix": "mfilepath", + "body": "${1:FIELDNAME} = models.FilePathField($2, path=${3:None}, match=${4:None}, recursive=${5:recursive}, max_length=${6:100})", + "description": "FilePathField (mfilepath).\n\nA CharField whose choices are limited to the filenames in a certain directory on the filesystem.\n\n", + "scope": "source.python" + }, + "mfloat": { + "prefix": "mfloat", + "body": "${1:FIELDNAME} = models.FloatField($2)", + "description": "FloatField (mfloat).\n\nA floating-point number represented in Python by a float instance.\n\n", + "scope": "source.python" + }, + "fk": { + "prefix": "fk", + "body": "${1:FIELDNAME} = models.ForeignKey(${2:OTHERMODEL}, on_delete=models.${3|CASCADE,PROTECT,SET_NULL,SET_DEFAULT,SET(),DO_NOTHING|})", + "description": "ForeignKey (fk).\n\nA many-to-one relationship.\n\non_delete will become a required argument in Django 2.0. In older versions it defaults to CASCADE.\n\n", + "scope": "source.python" + }, + "mip": { + "prefix": "mip", + "body": "${1:FIELDNAME} = models.IPAddressField($2)", + "description": "IPAddressField (mip).\n\nThis field has been deprecated since version 1.7 in favor of GenericIPAddressField.\n\n", + "scope": "source.python" + }, + "mimg": { + "prefix": "mimg", + "body": "${1:FIELDNAME} = models.ImageField($2, upload_to=${3:None}, height_field=${4:None}, width_field=${5:None}, max_length=${5:100})", + "description": "ImageField (mimg).\n\nInherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image.\n\n", + "scope": "source.python" + }, + "mint": { + "prefix": "mint", + "body": "${1:FIELDNAME} = models.IntegerField($2)", + "description": "IntegerField (mint).\n\nAn integer. Values from -2147483648 to 2147483647 are safe in all databases supported by Django.\n\n", + "scope": "source.python" + }, + "mgenericip": { + "prefix": "mgenericip", + "body": "${1:FIELDNAME} = models.GenericIPAddressField($2, protocol=${3:'both'}, unpack_ipv4=${4:False})", + "description": "GenericIPAddressField (mimg).\n\nAn IPv4 or IPv6 address, in string format.\n\n", + "scope": "source.python" + }, + "m2m": { + "prefix": "m2m", + "body": "${1:FIELDNAME} = models.ManyToManyField(${2:OTHERMODEL})", + "description": "ManyToManyField (m2m).\n\nA many-to-many relationship.\n\n", + "scope": "source.python" + }, + "mnullbool": { + "prefix": "mnullbool", + "body": "${1:FIELDNAME} = models.NullBooleanField($2)", + "description": "NullBooleanField (mnullbool).\n\nLike a BooleanField, but allows NULL as one of the options.\n\n", + "scope": "source.python" + }, + "o2o": { + "prefix": "o2o", + "body": "${1:FIELDNAME} = models.OneToOneField(${2:OTHERMODEL}, on_delete=models.${3|CASCADE,PROTECT,SET_NULL,SET_DEFAULT,SET(),DO_NOTHING|})", + "description": "OneToOneField (o2o).\n\nA one-to-one relationship.\n\non_delete will become a required argument in Django 2.0. In older versions it defaults to CASCADE.\n\n", + "scope": "source.python" + }, + "mphone": { + "prefix": "mphone", + "body": "${1:FIELDNAME} = models.PhoneNumberField($2)", + "description": "PhoneNumberField (mphone).\n\n*external package: django-phonenumber-field*\n\n", + "scope": "source.python" + }, + "mposint": { + "prefix": "mposint", + "body": "${1:FIELDNAME} = models.PositiveIntegerField($2)", + "description": "PositiveIntegerField (mposint).\n\nLike an IntegerField, but must be either positive or zero (0).\n\n", + "scope": "source.python" + }, + "mpossmallint": { + "prefix": "mpossmallint", + "body": "${1:FIELDNAME} = models.PositiveSmallIntegerField($2)", + "description": "PositiveSmallIntegerField (mpossmallint).\n\nLike a PositiveIntegerField, but only allows values under a certain (database-dependent) point.\n\n", + "scope": "source.python" + }, + "mslug": { + "prefix": "mslug", + "body": "${1:FIELDNAME} = models.SlugField($2)", + "description": "SlugField (mslug).\n\nA slug is a short label for something, containing only letters, numbers, underscores or hyphens. They’re generally used in URLs.\n\n", + "scope": "source.python" + }, + "msmallint": { + "prefix": "msmallint", + "body": "${1:FIELDNAME} = models.SmallIntegerField($2)", + "description": "SmallIntegerField (msmallint).\n\nLike an IntegerField, but only allows values under a certain (database-dependent) point.\n\n", + "scope": "source.python" + }, + "mtext": { + "prefix": "mtext", + "body": "${1:FIELDNAME} = models.TextField($2)", + "description": "TextField (mtext).\n\nA large text field.\n\n", + "scope": "source.python" + }, + "mtime": { + "prefix": "mtime", + "body": "${1:FIELDNAME} = models.TimeField($2, auto_now=${4:False}, auto_now_add=${5:False})", + "description": "TimeField (mtime).\n\nA time, represented in Python by a datetime.time instance.\n\n", + "scope": "source.python" + }, + "murl": { + "prefix": "murl", + "body": "${1:FIELDNAME} = models.URLField($2, max_length=${3:200})", + "description": "URLField (murl).\n\nA CharField for a URL.\n\n", + "scope": "source.python" + }, + "musstate": { + "prefix": "musstate", + "body": "${1:FIELDNAME} = models.USStateField($2)", + "description": "USStateField (musstate).\n\n*external package: django-localflavor*\n\n", + "scope": "source.python" + }, + "muuid": { + "prefix": "muuid", + "body": "${1:FIELDNAME} = models.UUIDField($2)", + "description": "UUIDField (muuid).\n\nA field for storing universally unique identifiers. Uses Python’s UUID class.\n\n", + "scope": "source.python" + }, + "mxml": { + "prefix": "mxml", + "body": "${1:FIELDNAME} = models.XMLField($2)", + "description": "XMLField (mxml).\n\n*All uses of XMLField can be replaced with TextField. This field has been deprecated since version 1.3*\n\n", + "scope": "source.python" + }, + "mstore": { + "prefix": "mstore", + "body": "${1:FIELDNAME} = HStoreField()", + "description": "HStoreField (mstore).\n\n*PostgreSQL specific model fields*.\n\nA field for storing key-value pairs. The Python data type used is a dict.\n\n", + "scope": "source.python" + }, + "mjson": { + "prefix": "mjson", + "body": "${1:FIELDNAME} = JSONField()", + "description": "JSONField (mjson).\n\n*PostgreSQL specific model fields*.\n\n[New in Django 1.11.]\n\nA field for storing JSON encoded data.\n\n", + "scope": "source.python" + }, + "marray": { + "prefix": "marray", + "body": "${1:FIELDNAME} = ArrayField()", + "description": "ArrayField (marray).\n\n*PostgreSQL specific model fields*.\n\nA field for storing lists of data\n\n", + "scope": "source.python" + }, + "fmai": { + "prefix": "fmai", + "body": "from .managers import $1QuerySet", + "description": "", + "scope": "source.python" + }, + "fmi": { + "prefix": "fmi", + "body": "from .models import $1", + "description": "", + "scope": "source.python" + }, + "imodels": { + "prefix": "imodels", + "body": "from django.db import models", + "description": "from ... import models", + "scope": "source.python" + }, + "ipy2_unicode_compatible": { + "prefix": "iuc", + "body": "from django.utils.encoding import python_2_unicode_compatible", + "description": "For forwards compatibility, this decorator is available as of Django 1.4.2.", + "scope": "source.python" + }, + "ipostgresmf": { + "prefix": "ipostgresmf", + "body": "from django.contrib.postgres.fields import ${1|ArrayField,JSONField,HStoreField|}", + "description": "PostgreSQL specific model fields", + "scope": "source.python" + }, + "isignals": { + "prefix": "isignals", + "body": "from django.db.models.signals import ${1|pre_init,post_init,pre_save,post_save,pre_delete,post_delete,m2m_changed,class_prepared,Management signals,pre_migrate,post_migrate|}", + "description": "Signals for Django Model", + "scope": "source.python" + }, + "__str__": { + "prefix": "str", + "body": ["def __str__(self):", "\treturn self${1: # TODO}"], + "description": "", + "scope": "source.python" + }, + "get_absolute_url": { + "prefix": "get_absolute_url", + "body": [ + "def get_absolute_url(self):", + "\tfrom django.core.urlresolvers import reverse", + "\treturn reverse('$1', kwargs={'pk': self.pk})" + ], + "description": "", + "scope": "source.python" + }, + "receiver": { + "prefix": "receiver", + "body": [ + "def ${1:FUNCTIONNAME}_${2|pre_init,post_init,pre_save,post_save,pre_delete,post_delete,m2m_changed,class_prepared,Management signals,pre_migrate,post_migrate|}_receiver(sender, instance, *args, **kwargs):", + "\tpass", + "\n\n${2|pre_init,post_init,pre_save,post_save,pre_delete,post_delete,m2m_changed,class_prepared,Management signals,pre_migrate,post_migrate|}.connect(${1:name}_${2|pre_init,post_init,pre_save,post_save,pre_delete,post_delete,m2m_changed,class_prepared,Management signals,pre_migrate,post_migrate|}_receiver, sender=${3:MODELNAME})" + ], + "description": "", + "scope": "source.python" + }, + "__init__": { + "prefix": "__init__", + "body": "\r\ndef __init__(self, *args, **kwargs):\r\n super(${1:CLASS_NAME}, self).__init__(*args, **kwargs)\r\n", + "description": "", + "scope": "source.python" + }, + "ipdb": { + "prefix": "ipdb", + "body": "import ipdb; ipdb.set_trace()", + "description": "ipdb debug tool", + "scope": "source.python" + }, + "npdb": { + "prefix": "npdb", + "body": "from nose.tools import set_trace; set_trace()", + "description": "nose pdb debug tool", + "scope": "source.python" + }, + "pdb": { + "prefix": "pdb", + "body": "import pdb; pdb.set_trace()", + "description": "pdb debug tool", + "scope": "source.python" + }, + "traceback": { + "prefix": "traceback", + "body": "import traceback; traceback.print_exc();", + "description": "traceback print exception", + "scope": "source.python" + }, + "utfc": { + "prefix": "utfc", + "body": "# -*- coding: utf-8 -*-", + "description": "coding: utf-8", + "scope": "source.python" + }, + "iunicode_literals": { + "prefix": "iul", + "body": "from __future__ import unicode_literals", + "description": "In order to enable the same behavior in Python 2, every module must import: \n", + "scope": "source.python" + }, + "ilib": { + "prefix": "ilib", + "body": ["from django import template", "register = template.Library()"], + "description": "", + "scope": "source.python" + }, + "li18n": { + "prefix": "li18n", + "body": "{% load i18n %}", + "description": "", + "scope": "text.html.django" + }, + "lstatic": { + "prefix": "lstatic", + "body": "{% load staticfiles %}", + "description": "", + "scope": "text.html.django" + }, + "ltags": { + "prefix": "ltags", + "body": "{% load $SELECTION$1_tags %}", + "description": "", + "scope": "text.html.django" + }, + "register_assignment_tag": { + "prefix": "register_assignment_tag", + "body": [ + "def get_$1(context):", + "\trequest = context.get('request')", + "\t$1 = ${2:[]}", + "\treturn ${3:$1}" + ], + "description": "", + "scope": "source.python" + }, + "register_filter": { + "prefix": "register_filter", + "body": ["@register.filter", "def $1(value):", "\treturn value$2"], + "description": "", + "scope": "source.python" + }, + "register_inclusion_tag": { + "prefix": "register_inclusion_tag", + "body": [ + "@register.inclusion_tag(${2:'$1.html'}, takes_context=True)", + "def $1(context):", + "\trequest = context.get('request')", + "\t$3", + "\treturn {", + "\t\t'request': request,", + "\t\t$4", + "\t}" + ], + "description": "", + "scope": "source.python" + }, + "register_simple_tag": { + "prefix": "register_simple_tag", + "body": [ + "@register.simple_tag(takes_context=True)", + "def $1(context):", + "\trequest = context.get('request')", + "\treturn ${2:'It Works!'}" + ], + "description": "", + "scope": "source.python" + }, + "urlresolvers": { + "prefix": "iurlresolvers", + "body": "from django.core.urlresolvers import ${1|reverse,reverse_lazy,resolve,get_script_prefix|}", + "description": "*Deprecated since version 1.10*\n\nUtility functions.\n\n", + "scope": "source.python" + }, + "urls (≥1.10 & ≤1.11)": { + "prefix": "iurls", + "body": "from django.urls import ${1|reverse,reverse_lazy,resolve,get_script_prefix|}", + "description": "Utility functions for use in URLconfs.", + "scope": "source.python" + }, + "conf.urls (≤1.11)": { + "prefix": "iconf_urls", + "body": "from django.conf.urls import ${1|static,url,include,handler400,handler403,handler404,handler500|}", + "description": "Utility functions for use in URLconfs.", + "scope": "source.python" + }, + "urls (≥2.0)": { + "prefix": "iurls", + "body": "from django.urls import ${1|path,re_path,include,reverse,reverse_lazy,register_converter|}", + "description": "Utility functions for use in URLconfs.", + "scope": "source.python" + }, + "conf.urls (≥2.0)": { + "prefix": "iconf_urls", + "body": "from django.conf.urls import ${1|static,url,handler400,handler403,handler404,handler500|}", + "description": "Utilityfunctions for use in URLconfs.", + "scope": "source.python" + }, + "url_stack": { + "prefix": "url_stack", + "body": [ + "${1|url,re_path|}(", + "\tr'^${2:REGEX}/$',", + "\t${3:VIEW}${4:.as_view()},", + "\tname='$5'", + ")," + ], + "description": "url(regex, view, kwargs=None, name=None)\n\n*url is an alias to re_path*\n\n", + "scope": "source.python" + }, + "url_inline": { + "prefix": "url_inline", + "body": [ + "${1|url,re_path|}(r'^${2:REGEX}/$', ${3:VIEW}${4:.as_view()}, name='$5')," + ], + "description": "url(regex, view, kwargs=None, name=None)\n\n*url is an alias to re_path*\n\n", + "scope": "source.python" + }, + "path_stack": { + "prefix": "path_stack", + "body": [ + "path(", + "\t'${1:ROUTE}/',", + "\t${2:VIEW}${3:.as_view()},", + "\tname='$4'", + ")," + ], + "description": "path(route, view, kwargs=None, name=None)", + "scope": "source.python" + }, + "path_inline": { + "prefix": "path_inline", + "body": ["path('${1:ROUTE}/', ${2:VIEW}${3:.as_view()}, name='$4'),"], + "description": "path(route, view, kwargs=None, name=None)", + "scope": "source.python" + }, + "urlpatterns": { + "prefix": "urlpatterns", + "body": ["urlpatterns = [", "\t$0", "]"], + "description": "", + "scope": "source.python" + }, + "repk": { + "prefix": "repk", + "body": "r'^(?P<${1:pk}>d+)/$'", + "description": "PK URL regex", + "scope": "source.python" + }, + "reslug": { + "prefix": "reslug", + "body": "r'^(?P<${1:slug}>[-w]+)/$'", + "description": "Slug URL regex", + "scope": "source.python" + }, + "reusername": { + "prefix": "reusername", + "body": "r'^(?P[w.@+-]+)/$'", + "description": "Username regex", + "scope": "source.python" + }, + "createview": { + "prefix": "createview", + "body": "\r\nclass ${1:MODEL_NAME}CreateView(CreateView):\r\n model = ${1:MODEL_NAME}\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "deleteview": { + "prefix": "deleteview", + "body": "\r\nclass ${1:MODEL_NAME}DeleteView(DeleteView):\r\n model = ${1:MODEL_NAME}\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "detailview": { + "prefix": "detailview", + "body": "\r\nclass ${1:MODEL_NAME}DetailView(DetailView):\r\n model = ${1:MODEL_NAME}\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "listview": { + "prefix": "listview", + "body": "\r\nclass ${1:MODEL_NAME}ListView(ListView):\r\n model = ${1:MODEL_NAME}\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "templateview": { + "prefix": "templateview", + "body": "\r\nclass ${1:CLASS_NAME}(TemplateView):\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "updateview": { + "prefix": "updateview", + "body": "\r\nclass ${1:MODEL_NAME}UpdateView(UpdateView):\r\n model = ${1:MODEL_NAME}\r\n template_name = \"${2:TEMPLATE_NAME}\"\r\n", + "description": "", + "scope": "source.python" + }, + "from views import": { + "prefix": "fvi", + "body": "from . import $1", + "description": "", + "scope": "source.python" + }, + "igenericviews": { + "prefix": "igenericviews", + "body": "from django.views.generic import ${1|CreateView,DetailView,FormView,ListView,TemplateView,UpdateView|}", + "description": "Generic class-based views", + "scope": "source.python" + }, + "isettings": { + "prefix": "isettings", + "body": "from django.conf import settings", + "description": "from django.conf import settings", + "scope": "source.python" + }, + "view": { + "prefix": "view", + "body": "def ${1:VIEWNAME}(request):", + "description": "View", + "scope": "source.python" + }, + "dispatch": { + "prefix": "dispatch", + "body": "\r\ndef dispatch(self, request, *args, **kwargs):\r\n return super(${1:CLASS_NAME}, self).dispatch(request, *args, **kwargs)\r\n", + "description": "", + "scope": "source.python" + }, + "context": { + "prefix": "get_context_data", + "body": "\r\ndef get_context_data(self, **kwargs):\r\n context = super(${1:CLASS_NAME}, self).get_context_data(**kwargs)\r\n return context\r\n", + "description": "", + "scope": "source.python" + }, + "get_queryset": { + "prefix": "get_queryset", + "body": [ + "def get_queryset(self):", + "\tqueryset = super(${1:CLASS_NAME}, self).get_queryset()", + "\tqueryset = queryset${3: # TODO}", + "\treturn queryset" + ], + "description": "", + "scope": "source.python" + } +} diff --git a/snippets/frameworks/django/filetemplates.json b/snippets/frameworks/django/filetemplates.json new file mode 100644 index 0000000..c6561f3 --- /dev/null +++ b/snippets/frameworks/django/filetemplates.json @@ -0,0 +1,35 @@ +{ + "Django URLFile Template":{ + "prefix": "fturl", + "body": [ + "from django.urls import path", + "from . import views as v", + "\n\napp_name = ${1:AppName}", + "urlpatterns = [", + "\t# TODO: Define $1 URLs here", + "\t${0}", + "]" + ], + "description": "Django File-Template Sinppet For ``URL`` File" + }, + "Django FormFile Template":{ + "prefix": "ftform", + "body": [ + "from django import forms", + "from ${1:.models} import ${2}", + "\n\n# TODO: Create your forms here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``Form`` File" + }, + "Django CustomTagsFile Template":{ + "prefix": "ftcutomtags", + "body": [ + "from django import template", + "\nregister = template.Library()", + "\n# TODO: Create your custom tags here", + "${0}" + ], + "description": "Django File-Template Sinppet For ``CustomTags`` File" + } +} diff --git a/snippets/frameworks/django/forms.json b/snippets/frameworks/django/forms.json new file mode 100644 index 0000000..5b2c319 --- /dev/null +++ b/snippets/frameworks/django/forms.json @@ -0,0 +1,168 @@ +{ + "Django Simple Form ":{ + "prefix": "sform", + "body": [ + "class ${1:Name}Form(forms.Form):", + "\t# Define $1Form fields here", + "\t${0}" + ], + "description": "Django Simple Form" + }, + "Django Model Form ":{ + "prefix": "modelform", + "body": [ + "class ${1:ModelName}Form(forms.ModelForm):", + "\tclass Meta:", + "\t\tmodel = ${2:$1}", + "\t\tfields = (${3:\"__all__\"})", + "\t\t${0}" + ], + "description": "Django Model Form" + }, + "Forms BooleanField":{ + "prefix": "fbool", + "body": "${1:FIELDNAME} = forms.BooleanField(${2})", + "description": "Django forms ``BooleanField``" + }, + "Forms CharField":{ + "prefix": "fchar", + "body": "${1:FIELDNAME} = forms.CharField(${2})", + "description": "Django forms ``CharField``" + }, + "Forms ComboField":{ + "prefix": "fcombo", + "body": "${1:FIELDNAME} = forms.ComboField(${2})", + "description": "Django forms ``ComboField``" + }, + "Forms DateField":{ + "prefix": "fdate", + "body": "${1:FIELDNAME} = forms.DateField(${2})", + "description": "Django forms ``DateField``" + }, + "Forms DateTime":{ + "prefix": "fdatetime", + "body": "${1:FIELDNAME} = forms.DateTime(${2})", + "description": "Django forms ``DateTime``" + }, + "Forms DecimalField":{ + "prefix": "fdecimal", + "body": "${1:FIELDNAME} = forms.DecimalField(${2})", + "description": "Django forms ``DecimalField``" + }, + "Forms DurationField":{ + "prefix": "fduration", + "body": "${1:FIELDNAME} = forms.DurationField(${2})", + "description": "Django forms ``DurationField``" + }, + "Forms EmailField":{ + "prefix": "femail", + "body": "${1:FIELDNAME} = forms.EmailField(${2})", + "description": "Django forms ``EmailField``" + }, + "Forms FileField":{ + "prefix": "ffile", + "body": "${1:FIELDNAME} = forms.FileField(${2})", + "description": "Django forms ``FileField``" + }, + "Forms FilePathField":{ + "prefix": "ffilepath", + "body": "${1:FIELDNAME} = forms.FilePathField(${2})", + "description": "Django forms ``FilePathField``" + }, + "Forms FloatField":{ + "prefix": "ffloat", + "body": "${1:FIELDNAME} = forms.FloatField(${2})", + "description": "Django forms ``FloatField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms GenericIPAddressField":{ + "prefix": "fgip", + "body": "${1:FIELDNAME} = forms.GenericIPAddressField(${2})", + "description": "Django forms ``GenericIPAddressField``" + }, + "Forms ImageField":{ + "prefix": "fimg", + "body": "${1:FIELDNAME} = forms.ImageField(${2})", + "description": "Django forms ``ImageField``" + }, + "Forms IntegerField":{ + "prefix": "fint", + "body": "${1:FIELDNAME} = forms.IntegerField(${2})", + "description": "Django forms ``IntegerField``" + }, + "Forms IPAddressField":{ + "prefix": "fip", + "body": "${1:FIELDNAME} = forms.IPAddressField(${2})", + "description": "Django forms ``IPAddressField``" + }, + "Forms ModelChoiceField":{ + "prefix": "fmochoice", + "body": "${1:FIELDNAME} = forms.ModelChoiceField(${2})", + "description": "Django forms ``ModelChoiceField``" + }, + "Forms ModelMultipleChoiceField":{ + "prefix": "fmomuchoice", + "body": "${1:FIELDNAME} = forms.ModelMultipleChoiceField(${2})", + "description": "Django forms ``ModelMultipleChoiceField``" + }, + "Forms MultipleChoiceField":{ + "prefix": "fmuchoice", + "body": "${1:FIELDNAME} = forms.MultipleChoiceField(${2})", + "description": "Django forms ``MultipleChoiceField``" + }, + "Forms MultipleValueField":{ + "prefix": "fmuvalue", + "body": "${1:FIELDNAME} = forms.MultipleValueField(${2})", + "description": "Django forms ``MultipleValueField``" + }, + "Forms NullBooleanField":{ + "prefix": "fnullbool", + "body": "${1:FIELDNAME} = forms.NullBooleanField(${2})", + "description": "Django forms ``NullBooleanField``" + }, + "Forms RegexField":{ + "prefix": "fregex", + "body": "${1:FIELDNAME} = forms.RegexField(${2})", + "description": "Django forms ``RegexField``" + }, + "Forms SlugField":{ + "prefix": "fslug", + "body": "${1:FIELDNAME} = forms.SlugField(${2})", + "description": "Django forms ``SlugField``" + }, + "Forms SplitDateTime":{ + "prefix": "fsdatetime", + "body": "${1:FIELDNAME} = forms.SplitDateTime(${2})", + "description": "Django forms ``SplitDateTime`` Field" + }, + "Forms TimeField":{ + "prefix": "ftime", + "body": "${1:FIELDNAME} = forms.TimeField(${2})", + "description": "Django forms ``TimeField``" + }, + "Forms TypedChoiceField":{ + "prefix": "ftchoice", + "body": "${1:FIELDNAME} = forms.TypedChoiceField(${2})", + "description": "Django forms ``TypedChoiceField``" + }, + "Forms TypedMultipleChoiceField":{ + "prefix": "ftmuchoice", + "body": "${1:FIELDNAME} = forms.TypedMultipleChoiceField(${2})", + "description": "Django forms ``TypedMultipleChoiceField``" + }, + "Forms URLField":{ + "prefix": "fulr", + "body": "${1:FIELDNAME} = forms.URLField(${2})", + "description": "Django forms ``URLField``" + }, + "Forms UUIDField":{ + "prefix": "fuuid", + "body": "${1:FIELDNAME} = forms.UUIDField(${2})", + "description": "Django forms ``UUIDField``" + } + +} diff --git a/snippets/frameworks/django/imports.json b/snippets/frameworks/django/imports.json new file mode 100644 index 0000000..d099fb9 --- /dev/null +++ b/snippets/frameworks/django/imports.json @@ -0,0 +1,43 @@ +{ + "Import forms":{ + "prefix": "di-forms", + "body": "from django import forms", + "description": "Import Django ``forms``" + }, + "Import models":{ + "prefix": "di-model", + "body": "from django import models", + "description": "Import Django ``models``" + }, + "Import get_user_model":{ + "prefix": "di-getusermodel", + "body": "from django.contrib.auth import get_user_model", + "description": "Import Django ``get_user_model``" + }, + "Import generic views":{ + "prefix": "di-generic", + "body": "from django.views import generic", + "description": "Import Django ``generic``" + }, + "Import JsonResponse":{ + "prefix": "di-jsonresponse", + "body": "from django.http import JsonResponse", + "description": "Import Django ``JsonResponse``" + }, + "Import reverse":{ + "prefix": "di-reverse", + "body": "from django.urls import reverse", + "description": "Import Django ``reverse``" + }, + "Import reverse_lazy":{ + "prefix": "di-reverse_lazy", + "body": "from django.urls import revers_lazy", + "description": "Import Django ``revers_lazy``" + }, + + "Import messages":{ + "prefix": "di-messages", + "body": "from django.contrib import messages", + "description": "Import Django ``messages``" + } +} diff --git a/snippets/frameworks/django/models.json b/snippets/frameworks/django/models.json new file mode 100644 index 0000000..c0b656c --- /dev/null +++ b/snippets/frameworks/django/models.json @@ -0,0 +1,183 @@ +{ + "Django Simple Model": { + "prefix": "smodel", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Simple Model with properties and attributes" + }, + "Django Full Model": { + "prefix": "model", + "body": [ + "class ${1:ModelName}(models.Model):", + "\t# Define $1 fields here", + "\t${2}", + "\n\tclass Meta:", + "\t\tordering = [\"${3:-pk}\"]", + "\t\tverbose_name = \"${4:$1}\"", + "\t\tverbose_name_plural = \"${5:$1s}\"", + "\n\tdef __str__(self):", + "\t\treturn ${6:super().__str__()}", + "\n\tdef save(self, *args, **kwargs):", + "\t\treturn ${7:super().save(*args, **kwargs)}", + "\n\tdef get_absolute_url(self):", + "\t\treturn reverse('${8:view_or_url_name}', kwargs={${9:'pk'}: ${10: self.pk}})", + "\n\t# Define $1 properties here", + "\t${0}" + ], + "description": "Django Full Model with properties and attributes" + }, + + "Models AutoField":{ + "prefix": "mauto", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BigIntegerField":{ + "prefix": "mbigint", + "body": "${1:FIELDNAME} = models.AutoField(${2})", + "description": "Django model ``AutoField``" + }, + "Models BinaryField":{ + "prefix": "mbinary", + "body": "${1:FIELDNAME} = models.BinaryField(${2})", + "description": "Django model ``BinaryField``" + }, + "Models Boolean":{ + "prefix": "mbool", + "body": "${1:FIELDNAME} = models.BooleanField(default=${2:False})", + "description": "Django model ``BooleanField``" + }, + "Models CharField":{ + "prefix": "mchar", + "body": "${1:FieldName} = models.CharField(max_length=${2:32})", + "description": "Django model ``CharField``" + }, + "Models CommaSeparatedIntegerField":{ + "prefix": "mcomma", + "body": "${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2})", + "description": "Django model ``CommaSeparatedIntegerField``" + }, + "Models DateField":{ + "prefix": "mdate", + "body": "${1:FIELDNAME} = models.DateField(auto_now_add=${2:True}, auto_now=${3:False}})", + "description": "Django model ``DateField``" + }, + "Models DateTimeField":{ + "prefix": "mdatetime", + "body": "${1:FIELDNAME} = models.DateTimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``DateTimeField``" + }, + "Models DecimalField":{ + "prefix": "mdecimal", + "body": "${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3})", + "description": "Django model ``DecimalField``" + }, + "Models EmailField":{ + "prefix": "memail", + "body": "${1:FIELDNAME} = models.EmailField(${2})", + "description": "Django model ``EmailField``" + }, + "Models FileField":{ + "prefix": "mfile", + "body": "${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload})", + "description": "Django model ``FileField``" + }, + "Models FilePathField":{ + "prefix": "mfilepath", + "body": "${1:FIELDNAME} = models.FilePathField(path=${2:\"/abs/path/to/dir\"}${3:, max_length=100}${4:, match=\"*.ext\"}${4:, recursive=True})", + "description": "Django model ``FilePathField``" + }, + "Models FloatField":{ + "prefix": "mfloat", + "body": "${1:FIELDNAME} = models.FloatField(${2})", + "description": "Django model ``FloatField``" + }, + "Models ImageField":{ + "prefix": "mimg", + "body": "${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100})", + "description": "Django model ``ImageField``" + }, + "Models IntegerField":{ + "prefix": "mint", + "body": "${1:FIELDNAME} = models.IntegerField(${2})", + "description": "Django model ``IntegerField``" + }, + "Models IPAddressField":{ + "prefix": "mip", + "body": "${1:FIELDNAME} = models.IPAddressField(${2})", + "description": "Django model ``IPAddressField``" + }, + "Models NullBooleanField":{ + "prefix": "mnullboolean", + "body": "${1:FIELDNAME} = models.NullBooleanField(${2})", + "description": "Django model ``NullBooleanField``" + }, + "Models PositiveIntegerField":{ + "prefix": "mposint", + "body": "${1:FIELDNAME} = models.PositiveIntegerField(${2})", + "description": "Django model ``PositiveIntegerField``" + }, + "Models PositiveSmallIntegerField":{ + "prefix": "mpossmallint", + "body": "${1:FIELDNAME} = models.PositiveSmallIntegerField(${2})", + "description": "Django model ``PositiveSmallIntegerField``" + }, + "Models SlugField":{ + "prefix": "mslug", + "body": "${1:FIELDNAME} = models.SlugField(${2})", + "description": "Django model ``SlugField``" + }, + "Models SmallIntegerField":{ + "prefix": "msmallint", + "body": "${1:FIELDNAME} = models.SmallIntegerField(${2})", + "description": "Django model ``SmallIntegerField``" + }, + "Models TextField":{ + "prefix": "mtext", + "body": "${1:FIELDNAME} = models.TextField(${2})", + "description": "Django model ``TextField``" + }, + "Models TimeField":{ + "prefix": "mtime", + "body": "${1:FIELDNAME} = models.TimeField(auto_now_add=${2:True}, auto_now=${3:False})", + "description": "Django model ``TimeField``" + }, + "Models URLField":{ + "prefix": "murl", + "body": "${1:FIELDNAME} = models.URLField(verify_exists=${2:False})", + "description": "Django model ``URLField``" + }, + "Models XMLField":{ + "prefix": "mxml", + "body": "${1:FIELDNAME} = models.XMLField(schema_path=${2:None})", + "description": "Django model ``XMLField``" + }, + + "Models ForeignKey":{ + "prefix": "fk", + "body": "${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}, on_delete=models.${3:CASCADE}, related_name=\"${4:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ForeignKey``" + }, + "Models ManyToManyField":{ + "prefix": "m2m", + "body": "${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}, related_name=\"${3:RelatedName}\" ${0:, limit_choices_to=})", + "description": "Django model ``ManyToManyField``" + }, + "Models OneToOneField":{ + "prefix": "o2o", + "body": "${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}, related_name=\"${4:RelatedName}\"${0:, to_field=''})", + "description": "Django model ``OneToOneField``" + } +} + diff --git a/snippets/frameworks/django/views.json b/snippets/frameworks/django/views.json new file mode 100644 index 0000000..4faa917 --- /dev/null +++ b/snippets/frameworks/django/views.json @@ -0,0 +1,243 @@ +{ + "Django CreateView":{ + "prefix": "createview", + "body": [ + "class ${1:ModelName}CreateView(generic.CreateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"" + ], + "description": "Django CBV ``CreateView``" + }, + "Django UpdateView":{ + "prefix": "updateview", + "body": [ + "class ${1:ModelName}UpdateView(generic.UpdateView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_form.html}\"", + "\tform_class = ${4:forms.$1Form}", + "\tsuccess_url = \"${5:.}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${6:self.kwargs.get(\"pk\")})" + ], + "description": "Django CBV ``UpdateView``" + }, + "Django DeleteView":{ + "prefix": "deleteview", + "body": [ + "class ${1:ModelName}DeleteView(generic.DeleteView):", + "\tmodel = ${2:$1}", + "\n\tdef get_success_url(self):", + "\t\treturn reverse(\"${3:$1:list}\")", + "\n\tdef get(self, request, *args, **kwargs):", + "\t\treturn post(request, *args, **kwargs)" + ], + "description": "Django CBV ``DeleteView``" + }, + "Django DetailView":{ + "prefix": "detailview", + "body": [ + "class ${1:ModelName}DetailView(generic.DetailView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_detail.html}\"", + "\n\tdef get_object(self):", + "\t\treturn $1.objects.get(pk=${4:self.kwargs.get(\"pk\")})", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${5})" + ], + "description": "Django CBV ``DetailView``" + }, + "Django ListView":{ + "prefix": "listview", + "body": [ + "class ${1:ModelName}ListView(generic.ListView):", + "\tmodel = ${2:$1}", + "\ttemplate_name = \"${3:$1/$1_list.html}\"", + "\n\tdef get_queryset(self):", + "\t\treturn $1.objects.filter(${4})" + ], + "description": "Django CBV ``ListView``" + }, + "Django TemplateView":{ + "prefix": "templateview", + "body": [ + "class ${1:ModelName}TemplateView(generic.TemplateView):", + "\ttemplate_name = \"${2:$1/$1_list.html}\"", + "\n${3}" + ], + "description": "Django CBV ``TemplateView``" + }, + "Django FormView":{ + "prefix": "formview", + "body": [ + "class ${1:ModelName}FormView(generic.FormView):", + "\tform_class = ${2:forms.$1Form}", + "\ttemplate_name = \"${3}\"" + ], + "description": "Django CBV ``FormView``" + }, + "Django AdminView":{ + "prefix": "adminview", + "body": [ + "@admin.register($1)", + "class ${1:ModelName}Admin(admin.ModelAdmin):", + "\tlist_display = ${2:\"pk\",}", + "\tsearch_fields = ${3:\"pk\",}", + "\tlist_filter = ${4:\"FilterFields\",}" + ], + "description": "Django AdminView for ``admin.py``" + }, + "Django AdminTabularInline":{ + "prefix": "tabularinline", + "body": [ + "class ${1:ModelName}Inline(admin.TabularInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django TabularInline for ``admin.py``" + }, + "Django AdminStackedInline":{ + "prefix": "stackedinline", + "body": [ + "class ${1:ModelName}Inline(admin.StackedInline):", + "\tmodel = ${2:$1}", + "\tmin_num = ${4:0}", + "\tmax_num = ${4:8}", + "\textra = ${5:1}" + ], + "description": "Django StackedInline for ``admin.py``" + }, + + "Django Views get_context_data":{ + "prefix": "getcontextdata", + "body": [ + "def get_context_data(self, *args, **kwargs):", + "\tcontext = super().get_context_data(*args, **kwargs)", + "\treturn context" + ], + "description": "Django Views ``get_context_data`` method" + }, + "Django Views get_success_url":{ + "prefix": "getsuccessurl", + "body": [ + "def get_success_url(self):", + "\treturn reverse(\"${1:ViewName}\", kwargs={${2:\"pk\": self.get_object().pk}})" + ], + "description": "Django Views ``get_success_url`` method" + }, + "Django Views get_queryset":{ + "prefix": "getqueryset", + "body": [ + "def get_queryset(self):", + "\treturn ${1:ModelName}.objects.filter(${2})" + ], + "description": "Django Views ``get_queryset`` method" + }, + "Django Views get_object":{ + "prefix": "getobject", + "body": [ + "def get_object(self):", + "\treturn ${1:ModelName}.objects.get(${2})" + ], + "description": "Django Views ``get_object`` method" + }, + "Django Views form_valid":{ + "prefix": "formvalid", + "body": [ + "def form_valid(self, form):", + "\treturn super().form_valid(form)" + ], + "description": "Django Views ``form_valid`` method" + }, + "Django Views form_invalid":{ + "prefix": "forminvalid", + "body": [ + "def form_invalid(self, form):", + "\treturn super().form_invalid(form)" + ], + "description": "Django Views ``form_invalid`` method" + }, + "Django Views get_form_kwargs":{ + "prefix": "getformkwargs", + "body": [ + "def get_form_kwargs(self, form):", + "\tkwargs = super().get_form_kwargs()", + "\treturn kwargs" + ], + "description": "Django Views ``get_form_kwargs`` method" + }, + "Django Views dispatch":{ + "prefix": "dispatch", + "body": [ + "def dispatch(self, request, *args, **kwargs):", + "\treturn super().dispatch(request, *args, **kwargs)" + ], + "description": "Django Views ``dispatch`` method" + }, + "Django Views get_initial":{ + "prefix": "getinitial", + "body": [ + "def get_initial(self):", + "\tinit = super().get_initial()", + "\treturn init" + ], + "description": "Django Views ``get_initial`` method" + }, + "Django Views post":{ + "prefix": "post", + "body": [ + "def post(self, request, *args, **kwargs):", + "\treturn super().post(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + "Django Views get":{ + "prefix": "get", + "body": [ + "def get(self, request, *args, **kwargs):", + "\treturn super().get(request, *args, **kwargs)" + ], + "description": "Django Views ``post`` method" + }, + + + "Django Forms field_clean":{ + "prefix": "cleanf", + "body": [ + "def clean_${1:FieldName}(self):", + "\t$1 = self.cleaned_data[\"$1\"]", + "\t${0}", + "\treturn $1" + ], + "description": "Django Views ``field_clean`` method" + }, + "Django Forms clean":{ + "prefix": "cleanff", + "body": [ + "def clean(self):", + "\tcleaned_data = super().clean()", + "\t${0}" + ], + "description": "Django Views ``clean`` method" + }, + + + "Django FBV Path":{ + "prefix": "fpath", + "body": "path(\"${1:Path}\", v.${2:View}, name=${0:PathName})", + "description": "Django Path For ``Function Based Views``" + }, + "Django CBV Path":{ + "prefix": "cpath", + "body": "path(\"${1:Path}\", v.${2:View}.as_viewJ(), name=${0:PathName})", + "description": "Django Path For ``Class Based Views``" + }, + "Django Path as Include":{ + "prefix": "ipath", + "body": "path(\"${1:Path}\", include(\"${2}.urls\", namespace=${0:Name})", + "description": "Django Path as ``Include``" + } +} diff --git a/snippets/frameworks/ejs.json b/snippets/frameworks/ejs.json new file mode 100644 index 0000000..477ecf5 --- /dev/null +++ b/snippets/frameworks/ejs.json @@ -0,0 +1,87 @@ +{ + "EJS No Output": { + "prefix": "ejs", + "body": [ + "<% $1 %> $2" + ], + "description": "EJS No Output" + }, + "EJS Output Value": { + "prefix": "ejsout", + "body": [ + "<%= $1 %> $2" + ], + "description": "EJS outputs no value" + }, + "EJS Output Escaped": { + "prefix": "ejsesc", + "body": [ + "<%- $1 %> $2" + ], + "description": "EJS outputs value" + }, + "EJS Comment": { + "prefix": "ejscom", + "body": [ + "<%# $1 %> $2" + ], + "description": "EJS comment tag with no output" + }, + "EJS Literal": { + "prefix": "ejslit", + "body": [ + "<%% $1 %> $2" + ], + "description": "EJS outputs a literal '<%'" + }, + "EJS Include": { + "prefix": "ejsinc", + "body": [ + "<% include $1 %> $2" + ], + "description": "EJS include statement" + }, + "EJS For Loop": { + "prefix": "ejsfor", + "body": [ + "<% for( let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++ ) { %>", + "$3", + "<% } %>" + ], + "description": "EJS For Loop" + }, + "EJS ForEach": { + "prefix": "ejseach", + "body": [ + "<% ${1:array}.forEach(${2:element} => { %>", + " $3", + "<% }) %>" + ], + "description": "EJS ForEach Loop" + }, + "EJS If Statement": { + "prefix": "ejsif", + "body": [ + "<% if (${1:condition}) { %>", + " $2", + "<% } %>" + ], + "description": "EJS if statement" + }, + "EJS Else Statement": { + "prefix": "ejselse", + "body": [ + "<% } else { %>", + " $1" + ], + "description": "EJS if statement" + }, + "EJS Else If Statement": { + "prefix": "ejselif", + "body": [ + "<% } else if ({$1:condition}) { %>", + " $2" + ], + "description": "EJS if statement" + } +} diff --git a/snippets/frameworks/flutter.json b/snippets/frameworks/flutter.json new file mode 100644 index 0000000..594eeba --- /dev/null +++ b/snippets/frameworks/flutter.json @@ -0,0 +1,498 @@ +{ + "Stateless Widget": { + "prefix": "statelessW", + "body": [ + "class ${1:name} extends StatelessWidget {", + " const ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateless widget" + }, + "Stateful Widget": { + "prefix": "statefulW", + "body": [ + "class ${1:name} extends StatefulWidget {", + " ${1:name}({Key? key}) : super(key: key);\n", + " @override", + " _${1:WidgetName}State createState() => _${1:WidgetName}State();", + "}\n", + "class _${1:index}State extends State<${1:index}> {", + " @override", + " Widget build(BuildContext context) {", + " return Container(", + " child: ${2:null},", + " );", + " }", + "}" + ], + "description": "Create a Stateful widget" + }, + "Build Method": { + "prefix": "build", + "body": [ + "@override", + "Widget build(BuildContext context) {", + " return ${0:};", + "}" + ], + "description": "Describes the part of the user interface represented by this widget." + }, + "Custom Painter ": { + "prefix": "customPainter", + "body": [ + "class ${0:name}Painter extends CustomPainter {", + "", + " @override", + " void paint(Canvas canvas, Size size) {", + " }", + "", + " @override", + " bool shouldRepaint(${0:name}Painter oldDelegate) => false;", + "", + " @override", + " bool shouldRebuildSemantics(${0:name}Painter oldDelegate) => false;", + "}" + ], + "description": "Used for creating custom paint" + }, + "Custom Clipper ": { + "prefix": "customClipper", + "body": [ + "class ${0:name}Clipper extends CustomClipper {", + "", + " @override", + " Path getClip(Size size) {", + " }", + "", + " @override", + " bool shouldReclip(CustomClipper oldClipper) => false;", + "}" + ], + "description": "Used for creating custom shapes" + }, + "InitState ": { + "prefix": "initS", + "body": [ + "@override", + "void initState() { ", + " super.initState();", + " ${0:}", + "}" + ], + "description": "Called when this object is inserted into the tree. The framework will call this method exactly once for each State object it creates." + }, + "Dispose": { + "prefix": "dis", + "body": [ + "@override", + "void dispose() { ", + " ${0:}", + " super.dispose();", + "}" + ], + "description": "Called when this object is removed from the tree permanently. The framework calls this method when this State object will never build again." + }, + "Reassemble": { + "prefix": "reassemble", + "body": [ + "@override", + "void reassemble(){", + " super.reassemble();", + " ${0:}", + "}" + ], + "description": "Called whenever the application is reassembled during debugging, for example during hot reload." + }, + "didChangeDependencies": { + "prefix": "didChangeD", + "body": [ + "@override", + "void didChangeDependencies() {", + " super.didChangeDependencies();", + " ${0:}", + "}" + ], + "description": "Called when a dependency of this State object changes" + }, + "didUpdateWidget": { + "prefix": "didUpdateW", + "body": [ + "@override", + "void didUpdateWidget (${1:Type} ${2:oldWidget}) {", + " super.didUpdateWidget(${2:oldWidget});", + " ${0:}", + "}" + ], + "description": "Called whenever the widget configuration changes." + }, + "ListView.Builder": { + "prefix": "listViewB", + "body": [ + "ListView.builder(", + " itemCount: ${1:1},", + " itemBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + ")," + ], + "description": "Creates a scrollable, linear array of widgets that are created on demand.Providing a non-null `itemCount` improves the ability of the [ListView] to estimate the maximum scroll extent." + }, + "ListView.Separated": { + "prefix": "listViewS", + "body": [ + "ListView.separated(", + " itemCount: ${1:1},", + " separatorBuilder: (BuildContext context, int index) {", + " return ${2:};", + " },", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a fixed-length scrollable linear array of list 'items' separated by list item 'separators'." + }, + "GridView.Builder": { + "prefix": "gridViewB", + "body": [ + "GridView.builder(", + " gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(", + " crossAxisCount: ${1:2},", + " ),", + " itemCount: ${2:2},", + " itemBuilder: (BuildContext context, int index) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets that are created on demand. Providing a non-null `itemCount` improves the ability of the [GridView] to estimate the maximum scroll extent." + }, + "GridView.Count": { + "prefix": "gridViewC", + "body": [ + "GridView.count(", + " crossAxisSpacing: ${1:1},", + " mainAxisSpacing: ${2:2},", + " crossAxisCount: ${3:2},", + " children: [", + " ${4:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with a fixed number of tiles in the cross axis." + }, + "GridView.Extent": { + "prefix": "gridViewE", + "body": [ + "GridView.extent(", + " maxCrossAxisExtent: ${1:2},", + " children: [", + " ${2:}", + " ],", + ")," + ], + "description": "Creates a scrollable, 2D array of widgets with tiles that each have a maximum cross-axis extent." + }, + "Custom Scroll View": { + "prefix": "customScrollV", + "body": [ + "CustomScrollView(", + " slivers: [", + " ${0:}", + " ],", + ")," + ], + "description": "Creates a `ScrollView` that creates custom scroll effects using slivers. If the `primary` argument is true, the `controller` must be null." + }, + "Stream Builder": { + "prefix": "streamBldr", + "body": [ + "StreamBuilder(", + " stream: ${1:stream},", + " initialData: ${2:initialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a new `StreamBuilder` that builds itself based on the latest snapshot of interaction with the specified `stream`" + }, + "Animated Builder": { + "prefix": "animatedBldr", + "body": [ + "AnimatedBuilder(", + " animation: ${1:animation},", + " child: ${2:child},", + " builder: (BuildContext context, Widget child) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates an Animated Builder. The widget specified to `child` is passed to the `builder` " + }, + "Stateful Builder": { + "prefix": "statefulBldr", + "body": [ + "StatefulBuilder(", + " builder: (BuildContext context, setState) {", + " return ${0:};", + " },", + ")," + ], + "description": "Creates a widget that both has state and delegates its build to a callback. Useful for rebuilding specific sections of the widget tree." + }, + "Orientation Builder": { + "prefix": "orientationBldr", + "body": [ + "OrientationBuilder(", + " builder: (BuildContext context, Orientation orientation) {", + " return Container(", + " child: ${3:child},", + " );", + " },", + ")," + ], + "description": "Creates a builder which allows for the orientation of the device to be specified and referenced" + }, + "Layout Builder": { + "prefix": "layoutBldr", + "body": [ + "LayoutBuilder(", + " builder: (BuildContext context, BoxConstraints constraints) {", + " return ${0:};", + " },", + ")," + ], + "description": "Similar to the Builder widget except that the framework calls the builder function at layout time and provides the parent widget's constraints." + }, + "Single Child ScrollView": { + "prefix": "singleChildSV", + "body": [ + "SingleChildScrollView(", + " controller: ${1:controller,}", + " child: Column(", + " ${0:}", + " ),", + ")," + ], + "description": "Creates a scroll view with a single child" + }, + "Future Builder": { + "prefix": "futureBldr", + "body": [ + "FutureBuilder(", + " future: ${1:Future},", + " initialData: ${2:InitialData},", + " builder: (BuildContext context, AsyncSnapshot snapshot) {", + " return ${3:};", + " },", + ")," + ], + "description": "Creates a Future Builder. This builds itself based on the latest snapshot of interaction with a Future." + }, + "No Such Method": { + "prefix": "nosm", + "body": [ + "@override", + "dynamic noSuchMethod(Invocation invocation) {", + " ${1:}", + "}" + ], + "description": "This method is invoked when a non-existent method or property is accessed." + }, + "Inherited Widget": { + "prefix": "inheritedW", + "body": [ + "class ${1:Name} extends InheritedWidget {", + " ${1:Name}({Key? key, required this.child}) : super(key: key, child: child);", + "", + " final Widget child;", + "", + " static ${1:Name}? of(BuildContext context) {", + " return context.dependOnInheritedWidgetOfExactType<${1:Name}>();", + " }", + "", + " @override", + " bool updateShouldNotify(${1:Name} oldWidget) {", + " return ${2:true};", + " }", + "}" + ], + "description": "Class used to propagate information down the widget tree" + }, + "Mounted": { + "prefix": "mounted", + "body": [ + "@override", + "bool get mounted {", + " ${0:}", + "}" + ], + "description": "Whether this State object is currently in a tree." + }, + "Sink": { + "prefix": "snk", + "body": [ + "Sink<${1:type}> get ${2:name} => _${2:name}Controller.sink;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A Sink is the input of a stream." + }, + "Stream": { + "prefix": "strm", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Controller.stream;", + "final _${2:name}Controller = StreamController<${1:type}>();" + ], + "description": "A source of asynchronous data events. A stream can be of any data type " + }, + "Subject": { + "prefix": "subj", + "body": [ + "Stream<${1:type}> get ${2:name} => _${2:name}Subject.stream;", + "final _${2:name}Subject = BehaviorSubject<${1:type}>();" + ], + "description": "A BehaviorSubject is also a broadcast StreamController which returns an Observable rather than a Stream." + }, + "toString": { + "prefix": "toStr", + "body": [ + "@override", + "String toString() {", + "return ${1:toString};", + " }" + ], + "description": "Returns a string representation of this object." + }, + "debugPrint": { + "prefix": "debugP", + "body": [ + "debugPrint(${1:statement});" + ], + "description": "Prints a message to the console, which you can access using the flutter tool's `logs` command (flutter logs)." + }, + "Material Package": { + "prefix": "importM", + "body": "import 'package:flutter/material.dart';", + "description": "Import flutter material package" + }, + "Cupertino Package": { + "prefix": "importC", + "body": "import 'package:flutter/cupertino.dart';", + "description": "Import Flutter Cupertino package" + }, + "flutter_test Package": { + "prefix": "importFT", + "body": "import 'package:flutter_test/flutter_test.dart';", + "description": "Import flutter_test package" + }, + "Material App": { + "prefix": "mateapp", + "description": "Create a MaterialApp", + "body": [ + "import 'package:flutter/material.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return MaterialApp(", + " title: 'Material App',", + " home: Scaffold(", + " appBar: AppBar(", + " title: Text('Material App Bar'),", + " ),", + " body: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Cupertino App": { + "prefix": "cupeapp", + "description": "Create a CupertinoApp", + "body": [ + "import 'package:flutter/cupertino.dart';", + " ", + "void main() => runApp(MyApp());", + " ", + "class MyApp extends StatelessWidget {", + " @override", + " Widget build(BuildContext context) {", + " return CupertinoApp(", + " title: 'Cupertino App',", + " home: CupertinoPageScaffold(", + " navigationBar: CupertinoNavigationBar(", + " middle: Text('Cupertino App Bar'),", + " ),", + " child: Center(", + " child: Container(", + " child: Text('Hello World'),", + " ),", + " ),", + " ),", + " );", + " }", + "}" + ] + }, + "Tween Animation Builder": { + "prefix": "tweenAnimationBuilder", + "body": [ + "TweenAnimationBuilder(", + " duration: ${1:const Duration(),}", + " tween: ${2:Tween(),}", + " builder: (BuildContext context, ${3:dynamic} value, Widget? child) {", + " return ${4:Container();}", + " },", + " ), " + ], + "description": "Widget builder that animates a property of a Widget to a target value whenever the target value changes." + }, + "Value Listenable Builder": { + "prefix": "valueListenableBuilder", + "body": [ + "ValueListenableBuilder(", + " valueListenable: ${1: null},", + " builder: (BuildContext context, ${2:dynamic} value, Widget? child) {", + " return ${3: Container();}", + " },", + " )," + ], + "description": "Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes." + }, + "Test": { + "prefix": "f-test", + "body": [ + "test(", + " \"${1:test description}\",", + " () {},", + ");" + ], + "description": "Create a test function" + }, + "Test Widgets": { + "prefix": "widgetTest", + "body": [ + "testWidgets(", + " \"${1:test description}\",", + " (WidgetTester tester) async {},", + ");" + ], + "description": "Create a testWidgets function" + } +} \ No newline at end of file diff --git a/snippets/frameworks/jekyll.json b/snippets/frameworks/jekyll.json new file mode 100644 index 0000000..9a11714 --- /dev/null +++ b/snippets/frameworks/jekyll.json @@ -0,0 +1,526 @@ +{ + "Show": { + "prefix": "show", + "description": "Output markup: {{ }}", + "body": "{{ $1 }}" + }, + + "Execute": { + "prefix": "execute", + "description": "Tag markup: {%- -%}", + "body": "{%- $1 -%}" + }, + + "Tag assign": { + "prefix": "assign", + "description": "Variable tag: assign", + "body": [ + "{%- assign ${variable} = ${value} -%}" + ] + }, + + "Tag break": { + "prefix": "break", + "description": "Iteration tag: break", + "body": [ + "{%- break -%}" + ] + }, + + "Tag capture": { + "prefix": "capture", + "description": "Variable tag: capture", + "body": [ + "{%- capture ${variable} -%}${code:}{%- endcapture -%}" + ] + }, + + "Tag case": { + "prefix": "case", + "description": "Control flow tag: case", + "body": [ + "{%- case ${variable} -%}", + "\t{%- when ${condition} -%}", + "\t\t${code1:}", + "\t{%- else -%}", + "\t\t${code2:}", + "{%- endcase -%}" + ] + }, + + "Tag comment": { + "prefix": "comment", + "description": "Control flow tag: case", + "body": [ + "{%- comment -%}${description:}{%- endcomment -%}" + ] + }, + + "Tag context variable": { + "prefix": "convar", + "description": "Context Variable", + "body": [ + "{{ ${variable:} }}" + ] + }, + + "Tag continue": { + "prefix": "continue", + "description": "Iteration tag: continue", + "body": [ + "{%- continue -%}" + ] + }, + + "Tag cycle": { + "prefix": "cycle", + "description": "Iteration tag: cycle", + "body": [ + "{%- cycle '${0:odd}', '${1:even}' -%}" + ] + }, + + "Tag collection directory": { + "prefix": "cdirp", + "description": "The full path to the collection's source direcotry", + "body": [ + "{{ site.${my_collection}.directory }}" + ] + }, + + "Tag collection relative path": { + "prefix": "crelp", + "description": "The path to the document's source file realtive to the site source", + "body": [ + "{{ site.collections.${my_collection}.relative_path }}" + ] + }, + + "Tag decrement": { + "prefix": "decrement", + "description": "Variable tag: decrement", + "body": [ + "{%- decrement ${variable} -%}" + ] + }, + + "Tag for": { + "prefix": "for", + "description": "Iteration tag: for", + "body": [ + "{%- for ${item} in ${collection} -%}", + "\t${code:}", + "{%- endfor -%}" + ] + }, + + "Tag increment": { + "prefix": "increment", + "description": "Variable tag: increment", + "body": [ + "{%- increment ${variable} -%}" + ] + }, + + "Tag if": { + "prefix": "if", + "description": "Control flow tag: if", + "body": [ + "{%- if ${condition} -%}", + "\t${code:}", + "{%- endif -%}" + ] + }, + + "Tag else": { + "prefix": "else", + "description": "Control flow tag: else", + "body": [ + "{%- else -%}" + ] + }, + + "Tag elsif": { + "prefix": "elsif", + "description": "Control flow tag: elsif", + "body": [ + "{%- elsif ${condition} -%}" + ] + }, + + "Tag if else": { + "prefix": "ifelse", + "description": "Control flow tag: if else", + "body": [ + "{%- if ${condition} -%}", + "\t${code1:}", + "{%- else -%}", + "\t${code2:}", + "{%- endif -%}" + ] + }, + + "Tag gist": { + "prefix": "gist", + "description": "Add a gist code block", + "body": [ + "{%- gist ${gist:user/gist-id} -%}" + ] + }, + + "Tag highlight": { + "prefix": "highlight", + "description": "Syntax tag: highlight", + "body": [ + "{%- highlight ${lang:javascript} -%}", + "\t\t${code:}", + "{%- endhighlight -%}" + ] + }, + + "Tag include": { + "prefix": "include", + "description": "Tag: include", + "body": [ + "{%- include ${snippet} -%}" + ] + }, + + "Site Vairable Date": { + "prefix": "date", + "description": "Tag: site.date", + "body": [ + "{{ site.date | date: '${format: %b %d, %Y}' }}" + ] + }, + + "Tag include relative": { + "prefix": "increl", + "description": "Tag: include relative", + "body": [ + "{%- include_relative '${file:}' -%}" + ] + }, + + "Tag Post URL": { + "prefix": "posturl", + "description": "Tag: post_url", + "body": [ + "{%- post_url ${url:} -%}" + ] + }, + + "Tag unless": { + "prefix": "unless", + "description": "Control flow tag: unless", + "body": [ + "{%- unless ${condition} -%}", + "\t${code:}", + "{%- endunless -%}" + ] + }, + + "Tag when": { + "prefix": "when", + "description": "Control flow tag: when", + "body": [ + "{%- when ${condition} -%}", + "${code:}" + ] + }, + + "Tag Option limit": { + "prefix": "limit", + "description": "For loops option", + "body": [ + "limit: ${limit:5}" + ] + }, + + "Tag Option offset": { + "prefix": "offset", + "description": "For loops option", + "body": [ + "offset: ${offset:0}" + ] + }, + + "Tag Option reversed": { + "prefix": "reversed", + "description": "For loops option", + "body": [ + "reversed" + ] + }, + + "Tag raw": { + "prefix": "raw", + "description": "Tag: raw", + "body": [ + "{%- raw -%}${code:}{%- endraw -%}" + ] + }, + + "Tag paginate next or previous page": { + "prefix": "paginate", + "description": "Tag: paginate next or previous page", + "body": [ + "{{ paginator.${next:previous}_page }}" + ] + }, + + "Filter jsonify": { + "prefix": "json", + "description": "Array filter: jsonify", + "body": "| jsonify }}'" + }, + + "Filter join": { + "prefix": "join", + "description": "Array filter: join", + "body": "| join: '${seperator:, }}'" + }, + + "Filter first": { + "prefix": "first", + "description": "Array filter: first", + "body": "| first" + }, + + "Filter last": { + "prefix": "last", + "description": "Array filter: last", + "body": "| last" + }, + + "Filter map": { + "prefix": "map", + "description": "Array filter: map", + "body": "| map: '${key}'" + }, + + "Filter size": { + "prefix": "size", + "description": "Array filter: size", + "body": "| size" + }, + + "Filter sort": { + "prefix": "sort", + "description": "Array filter: sort", + "body": "| sort" + }, + + "Filter uniq": { + "prefix": "uniq", + "description": "Array filter: uniq", + "body": "| uniq" + }, + + "Filter ceil": { + "prefix": "ceil", + "description": "Math filter: ceil", + "body": "| ceil" + }, + + "Filter divided by": { + "prefix": "divided_by", + "description": "Math filter: divided by", + "body": "| divided_by: ${divided_by:2}" + }, + + "Filter floor": { + "prefix": "floor", + "description": "Math filter: floor", + "body": "| floor" + }, + + "Filter minus": { + "prefix": "minus", + "description": "Math filter: minus", + "body": "| minus: ${minus:1}" + }, + + "Filter modulo": { + "prefix": "modulo", + "description": "Math filter: modulo", + "body": "| modulo: ${modulo:2}" + }, + + "Filter plus": { + "prefix": "plus", + "description": "Math filter: plus", + "body": "| plus: ${plus:1}" + }, + + "Filter round": { + "prefix": "round", + "description": "Math filter: round", + "body": "| round: ${round:0}" + }, + + "Filter times": { + "prefix": "times", + "description": "Math filter: times", + "body": "| times: ${times:1}" + }, + + "Filter append": { + "prefix": "append", + "description": "String filter: append", + "body": "| append: '${string}' }}" + }, + + "Filter capitalize": { + "prefix": "capitalize", + "description": "String filter: capitalize", + "body": "| capitalize }}" + }, + + "Filter downcase": { + "prefix": "downcase", + "description": "String filter: downcase", + "body": "| downcase }}" + }, + + "Filter escape": { + "prefix": "escape", + "description": "String filter: escape", + "body": "| escape }}" + }, + + "Filter markdownify": { + "prefix": "markdown", + "description": "String filter: markdownify", + "body": "| markdownify }}" + }, + + "Filter prepend": { + "prefix": "prepend", + "description": "String filter: prepend", + "body": "| prepend: '${string}' }}" + }, + + "Filter remove": { + "prefix": "remove", + "description": "String filter: remove", + "body": "| remove: '${string}' }}" + }, + + "Filter remove first": { + "prefix": "remove_first", + "description": "String filter: remove first", + "body": "| remove_first: '${string}' }}" + }, + + "Filter replace": { + "prefix": "replace", + "description": "String filter: replace", + "body": "| replace: '${target}', '${replace}' }}" + }, + + "Filter replace first": { + "prefix": "replace_first", + "description": "String filter: replace first", + "body": "| replace_first: '${target}', '${replace}' }}" + }, + + "Filter slice": { + "prefix": "slice", + "description": "String filter: slice", + "body": "| slice: ${from:0}, ${to:5} }}" + }, + + "Filter slice single character": { + "prefix": "slice_single", + "description": "String filter: slice with single parameter", + "body": "| slice: ${at} }}" + }, + + "Filter split": { + "prefix": "split", + "description": "String filter: split", + "body": "| split: '${splitter:,}' }}" + }, + + "Filter strip": { + "prefix": "strip", + "description": "String filter: strip", + "body": "| strip }}" + }, + + "Filter lstrip": { + "prefix": "lstrip", + "description": "String filter: lstrip", + "body": "| lstrip }}" + }, + + "Filter rstrip": { + "prefix": "rstrip", + "description": "String filter: rstrip", + "body": "| rstrip }}" + }, + + "Filter strip html": { + "prefix": "strip_html", + "description": "String filter: strip html", + "body": "| strip_html }}" + }, + + "Filter strip newlines": { + "prefix": "strip_newlines", + "description": "String filter: strip newlines", + "body": "| strip_newlines }}" + }, + + "Filter truncate": { + "prefix": "truncate", + "description": "String filter: truncate", + "body": "| truncate: ${length:20}, '${ellipsis:...}' }}" + }, + + "Filter truncatewords": { + "prefix": "truncatewords", + "description": "String filter: truncatewords", + "body": "| truncatewords: ${length:5}, '${ellipsis:...}' }}" + }, + + "Filter upcase": { + "prefix": "upcase", + "description": "String filter: upcase }}", + "body": "| upcase }}" + }, + + "Filter url encode": { + "prefix": "url_encode", + "description": "String filter: url encode", + "body": "| url_encode }}" + }, + + "Filter uri escape": { + "prefix": "uri_escape", + "description": "String filter: uri escape", + "body": "| uri_escape }}" + }, + + "Filter xml escape": { + "prefix": "xml_escape", + "description": "String filter: xml escape", + "body": "| xml_escape }}" + }, + + "Front Matter": { + "prefix": "fm", + "description": "Add front matter", + "body": [ + "---", + "layout: ${layout:default}", + "title: ${title}", + "categories: ${category}", + "permalink: ${path}", + "tags: ${tag}", + "excerpt: ${description}", + "---" + ] + } +} diff --git a/snippets/frameworks/rails.json b/snippets/frameworks/rails.json new file mode 100644 index 0000000..db095a9 --- /dev/null +++ b/snippets/frameworks/rails.json @@ -0,0 +1,294 @@ +{ + "Before action": { + "prefix": "ba", + "body": [ + "before_action :${0:method}" + ], + "description": "before_action" + }, + "Before validation": { + "prefix": "bv", + "body": [ + "before_validation :${0:method}" + ], + "description": "before_validation" + }, + "Before create": { + "prefix": "bc", + "body": [ + "before_create :${0:method}" + ], + "description": "before_create" + }, + "Before update": { + "prefix": "bu", + "body": [ + "before_update :${0:method}" + ], + "description": "before_update" + }, + "Before save": { + "prefix": "bs", + "body": [ + "before_save :${0:method}" + ], + "description": "before_save" + }, + "Before destroy": { + "prefix": "bd", + "body": [ + "before_destroy :${0:method}" + ], + "description": "before_destroy" + }, + "After create": { + "prefix": "ac", + "body": [ + "after_create :${0:method}" + ], + "description": "after_create" + }, + "After validation": { + "prefix": "av", + "body": [ + "after_validation :${0:method}" + ], + "description": "after_validation" + }, + " update": { + "prefix": "au", + "body": [ + "after_update :${0:method}" + ], + "description": "after_update" + }, + " save": { + "prefix": "as", + "body": [ + "after_save :${0:method}" + ], + "description": "after_create" + }, + " destroy": { + "prefix": "ad", + "body": [ + "after_destroy :${0:method}" + ], + "description": "after_destroy" + }, + "Belongs to": { + "prefix": "bt", + "body": [ + "belongs_to :${0:association}" + ], + "description": "belongs_to assocation" + }, + "Belongs to polymorphic": { + "prefix": "btp", + "body": [ + "belongs_to :${0:association}, polymorphic: true" + ], + "description": "belongs_to polymorphic assocation" + }, + "Create action": { + "prefix": "create", + "body": [ + "def create", + "\t@${1:model_class_name} = ${2:ModelClassName}.new($1_params)", + "\trespond_to do |format|", + "\t\tif @$1.save", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 created' }", + "\t\telse", + "\t\t\tformat.html { render :new, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def create" + }, + "Destroy action": { + "prefix": "destroy", + "body": [ + "def destroy", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\t@$1.destroy!", + "\tredirect_to $1s_path, notice: '$2 removed'", + "end" + ], + "description": "def destroy" + }, + "Edit action": { + "prefix": "edit", + "body": [ + "def edit", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def edit" + }, + "Index action": { + "prefix": "index", + "body": [ + "def index", + "\t@${1:model_class_name} = ${2:ModelClassName}.all", + "end" + ], + "description": "def index" + }, + "New action": { + "prefix": "new", + "body": [ + "def new", + "\t@${1:model_class_name} = ${2:ModelClassName}.new", + "end" + ], + "description": "def new" + }, + "Show action": { + "prefix": "show", + "body": [ + "def show", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "end" + ], + "description": "def show" + }, + "Update action": { + "prefix": "update", + "body": [ + "def update", + "\t@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])", + "\trespond_to do |format|", + "\t\tif @$1.update($1_params)", + "\t\t\tformat.html { redirect_to @$1, notice: '$2 updated' }", + "\t\telse", + "\t\t\tformat.html { render :edit, status: :unprocessable_entity }", + "\t\tend", + "\tend", + "end" + ], + "description": "def update" + }, + "Model Params": { + "prefix": "params", + "body": [ + "def ${1:model_class_name}_params", + "\tparams.require(:$1).permit(${2:attributes})", + "end" + ], + "description": "def model_params" + }, + "Getting Params": { + "prefix": "pa", + "body": [ + "params[:${1:id}]" + ], + "description": "getting params using attribute" + }, + "Delegate to": { + "prefix": "dt", + "body": [ + "delegate: :${1:method}, to: :${0:object}" + ], + "description": "delegate to" + }, + "Delegate to with prefix": { + "prefix": "dtp", + "body": [ + "delegate: :${1:method}, to: :${2:object}, prefix: :${3:prefix}, allow_nil: ${0:allow_nil}" + ], + "description": "delegate to" + }, + "Scope": { + "prefix": "scope", + "body": [ + "scope :${1:name}, -> { where(${2:field}: ${0:value}) }" + ], + "description": "AR scope" + }, + "Validate presence": { + "prefix": "vp", + "body": [ + "validates :${1:attribute}, presence: true" + ], + "description": "validates presence" + }, + "Validate uniqueness": { + "prefix": "vu", + "body": [ + "validates :${1:attribute}, uniqueness: true" + ], + "description": "validates presence" + }, + "Migration add column": { + "prefix": "mac", + "body": [ + "add_column :${1:table_name}, :${2:column_name}, :${0:data_type}" + ], + "description": "Migration add column" + }, + "Migration add index": { + "prefix": "mai", + "body": [ + "add_index :${1:table_name}, :${0:column_name}" + ], + "description": "Migration add index" + }, + "Migration remove column": { + "prefix": "mrc", + "body": [ + "remove_column :${1:table_name}, :${0:column_name}" + ], + "description": "Migration remove column" + }, + "Migration rename column": { + "prefix": "mrnc", + "body": [ + "rename_column :${1:table_name}, :${2:old_column_name}, :${0:new_column_name}" + ], + "description": "Migration rename column" + }, + "Migration change column": { + "prefix": "mcc", + "body": [ + "change_column :${1:table_name}, :${2:old_column_name}, :${0:data_type}" + ], + "description": "Migration change column" + }, + "Has many dependent": { + "prefix": "hmd", + "body": [ + "has_many :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_many dependent" + }, + "Has many": { + "prefix": "hm", + "body": [ + "has_many :${0:object}" + ], + "description": "has_many association" + }, + "Has many through": { + "prefix": "hmt", + "body": [ + "has_many :${1:object}, through: :${0:object}" + ], + "description": "has_many through association" + }, + "Has one": { + "prefix": "ho", + "body": [ + "has_one :${0:object}" + ], + "description": "has_one association" + }, + "Has one dependent": { + "prefix": "hod", + "body": [ + "has_one :${1:object}, dependent: :${0:destroy}" + ], + "description": "has_one dependent" + } +} + diff --git a/snippets/frameworks/twig.json b/snippets/frameworks/twig.json new file mode 100644 index 0000000..b9a7469 --- /dev/null +++ b/snippets/frameworks/twig.json @@ -0,0 +1,536 @@ +{ + "asset": { + "prefix": "asset", + "body": + "{% set asset = ${1:entry.assetFieldHandle}.one() %}\n\n{% if asset %}\n\t\"{{\n{% endif %}", + "description": "asset" + }, + "assets": { + "prefix": "assets", + "body": + "{% for image in craft.assets.\n\t.sourceId(\"${1:1}\")\n\t.kind(\"${2:image}\")\n\t.limit(${3:10})\n}).all() %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets" + }, + "autoescape": { + "prefix": "autoescape", + "body": "{% autoescape \"${1:type}\" %}\n\t$0\n{% endautoescape %}", + "description": "autoescape" + }, + "blockb": { + "prefix": "blockb", + "body": "{% block ${1:name} %}\n\t$0\n{% endblock %}", + "description": "block (block)" + }, + "block": { + "prefix": "block", + "body": "{% block ${1:name} %}$0{% endblock %}", + "description": "block" + }, + "blockf": { + "prefix": "blockf", + "body": "{{ block(\"${1:name}\") }}$0", + "description": "blockf" + }, + "cache": { + "prefix": "cache", + "body": "{% cache %}\n\t$1\n{% endcache %}\n$0", + "description": "cache" + }, + "case": { + "prefix": "case", + "body": "{% case \"${1:value}\" %}\n\t$0", + "description": "case" + }, + "children": { + "prefix": "children", + "body": "{% children %}$0", + "description": "children" + }, + "ceil": { + "prefix": "ceil", + "body": "ceil($1)$0", + "description": "ceil" + }, + "assetso": { + "prefix": "assetso", + "body": + "{% set assets = craft.assets({\n\tsourceId: \"${1:1}\",\n\tkind: \"${2:image}\",\n\tlimit: ${3:10}\n}).all() %}\n\n{% for image in assets %}\n\t\"{{\n{% endfor %}\n$0", + "description": "craft.assets - object syntax" + }, + "categorieso": { + "prefix": "categorieso", + "body": + "{% set categories = craft.categories({\n\tgroup: \"${1:categoryGroupHandle}\",\n\tlimit: \"${2:11}\"\n}).all() %}\n\n
    \n\t{% nav category in categories %}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories - object syntax" + }, + "categories": { + "prefix": "categories", + "body": + "
    \n\t{% nav category in craft.categories\n\t\t.group(\"${1:categoryGroupHandle}\")\n\t\t.limit(${2:11})\n\t\t.all()\n\t%}\n\t\t
  • \n\t\t\t{{ category.title }}\n\t\t\t{% ifchildren %}\n\t\t\t\t
      \n\t\t\t\t\t{% children %}\n\t\t\t\t
    \n\t\t\t{% endifchildren %}\n\t\t
  • \n\t{% endnav %}\n
", + "description": "craft.categories" + }, + "entrieso": { + "prefix": "entrieso", + "body": + "{% set entries = craft.entries({\n\tsection: \"${1:sectionName}\",\n\tlimit: \"${2:10}\"\n}).all() %}\n\n{% for entry in entries %}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries - object syntax" + }, + "entries": { + "prefix": "entries", + "body": + "{% for entry in craft.entries\n\t.section(\"${1:sectionName}\")\n\t.limit(${2:10})\n\t.all()\n%}\n\t{{ entry.title }}\n{% endfor %}\n$0", + "description": "craft.entries" + }, + "t": { + "prefix": "t", + "body": "{{ $1 | t }}$0", + "description": "translate with | t" + }, + "replace": { + "prefix": "replace", + "body": "{{ ${1:$TM_SELECTED_TEXT} | replace(\"search\", \"replace\") }}$0", + "description": "replace with | replace(\"search\", \"replace\")" + }, + "replacex": { + "prefix": "replacex", + "body": + "{{ ${1:$TM_SELECTED_TEXT} | replace(\"/(search)/i\", \"replace\") }}$0", + "description": "replace regex with | replace(\"/(search)/i\", \"replace\")" + }, + "split": { + "prefix": "split", + "body": "{{ ${1:$TM_SELECTED_TEXT} | split(\"\\n\") }}$0", + "description": "split on | split (\"\\n\")" + }, + "tagso": { + "prefix": "tagso", + "body": + "{% set tags = craft.tags({\n\tgroup: \"${1:tagGroupHandle}\"\n}).all() %}\n\n
    \n\t{% for tag in tags %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags - object syntax" + }, + "tags": { + "prefix": "tags", + "body": + "
    \n\t{% for tag in craft.tags.group(\"${1:tagGroupHandle}\").all() %}\n\t\t
  • {{ tag }}
  • \n\t{% endfor %}\n
\n$0", + "description": "craft.tags" + }, + "userso": { + "prefix": "userso", + "body": + "{% set users = craft.users({\n\tgroup: \"${1:userGroupHandle}\"\n}).all() %}\n\n{% for user in users %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users - object syntax" + }, + "users": { + "prefix": "users", + "body": + "{% for user in craft.users.group(\"${1:userGroupHandle}\").all() %}\n\t{{ user.firstName }} {{ user.lastName }}\n{% endfor %}\n$0", + "description": "craft.users" + }, + "csrf": { + "prefix": "csrf", + "body": "{{ csrfInput() }}\n$0", + "description": "csrf" + }, + "dd": { + "prefix": "dd", + "body": "
\n\t{{ dump($1) }}\n
\n{% exit %}$0", + "description": "dump and die" + }, + "do": { + "prefix": "do", + "body": "{% do $1 %}$0", + "description": "do" + }, + "dojs": { + "prefix": "dojs", + "body": "{% do view.registerJsFile \"${1:url}\" %}$0", + "description": "do js" + }, + "docss": { + "prefix": "docss", + "body": "{% do view.registerCssFile \"${1:url}\" %}$0", + "description": "do css" + }, + "dump": { + "prefix": "dump", + "body": "
\n\t{{ dump($1) }}\n
", + "description": "dump" + }, + "else": { + "prefix": "else", + "body": "{% else %}\n\t$0", + "description": "else" + }, + "embed": { + "prefix": "embed", + "body": "{% embed \"${1:template}\" %}\n\t$0\n{% endembed %}", + "description": "embed" + }, + "endautoescape": { + "prefix": "endautoescape", + "body": "{% endautoescape %}$0", + "description": "endautoescape" + }, + "endblock": { + "prefix": "endblock", + "body": "{% endblock %}$0", + "description": "endblock" + }, + "endcache": { + "prefix": "endcache", + "body": "{% endcache %}$0", + "description": "endcache" + }, + "endembed": { + "prefix": "endembed", + "body": "{% endembed %}$0", + "description": "endembed" + }, + "endfilter": { + "prefix": "endfilter", + "body": "{% endfilter %}$0", + "description": "endfilter" + }, + "endfor": { + "prefix": "endfor", + "body": "{% endfor %}$0", + "description": "endfor" + }, + "endif": { + "prefix": "endif", + "body": "{% endif %}$0", + "description": "endif" + }, + "endifchildren": { + "prefix": "endifchildren", + "body": "{% endifchildren %}$0", + "description": "endifchildren" + }, + "endcss": { + "prefix": "endcss", + "body": "{% endcss %}$0", + "description": "endcss" + }, + "endjs": { + "prefix": "endjs", + "body": "{% endjs %}$0", + "description": "endjs" + }, + "endmacro": { + "prefix": "endmacro", + "body": "{% endmacro %}$0", + "description": "endmacro" + }, + "endnav": { + "prefix": "endnav", + "body": "{% endnav %}$0", + "description": "endnav" + }, + "endset": { + "prefix": "endset", + "body": "{% endset %}$0", + "description": "endset" + }, + "endspaceless": { + "prefix": "endspaceless", + "body": "{% endspaceless %}$0", + "description": "endspaceless" + }, + "endswitch": { + "prefix": "endswitch", + "body": "{% endswitch %}$0", + "description": "endswitch" + }, + "endtrans": { + "prefix": "endtrans", + "body": "{% endtrans %}$0", + "description": "endtrans" + }, + "endverbatim": { + "prefix": "endverbatim", + "body": "{% endverbatim %}$0", + "description": "endverbatim" + }, + "exit": { + "prefix": "exit", + "body": "{% exit ${1:404} %}", + "description": "exit" + }, + "extends": { + "prefix": "extends", + "body": "{% extends \"${1:template}\" %}$0", + "description": "extends" + }, + "filterb": { + "prefix": "filterb", + "body": "{% filter ${1:name} %}\n\t$0\n{% endfilter %}", + "description": "filter (block)" + }, + "filter": { + "prefix": "filter", + "body": "{% filter ${1:name} %}$0{% endfilter %}", + "description": "filter" + }, + "floor": { + "prefix": "floor", + "body": "floor($1)$0", + "description": "floor" + }, + "fore": { + "prefix": "fore", + "body": + "{% for ${1:item} in ${2:items} %}\n\t$3\n{% else %}\n\t$0\n{% endfor %}", + "description": "for ... else" + }, + "for": { + "prefix": "for", + "body": "{% for ${1:item} in ${2:items} %}\n\t$0\n{% endfor %}", + "description": "for" + }, + "from": { + "prefix": "from", + "body": "{% from \"${1:template}\" import \"${2:macro}\" %}$0", + "description": "from" + }, + "endbody": { + "prefix": "endbody", + "body": "{{ endBody() }}\n$0", + "description": "endBody" + }, + "head": { + "prefix": "head", + "body": "{{ head() }}\n$0", + "description": "head" + }, + "if": { + "prefix": "if", + "body": "{% if ${1:condition} %}$2{% endif %}\n$0", + "description": "if" + }, + "ifb": { + "prefix": "ifb", + "body": "{% if ${1:condition} %}\n\t$0\n{% endif %}", + "description": "if (block)" + }, + "ife": { + "prefix": "ife", + "body": "{% if ${1:condition} %}\n\t$2\n{% else %}\n\t$0\n{% endif %}", + "description": "if ... else" + }, + "if1": { + "prefix": "if", + "body": "{% if ${1:condition} %}$0{% endif %}", + "description": "if" + }, + "ifchildren": { + "prefix": "ifchildren", + "body": "{% ifchildren %}\n\t$1\n{% endifchildren %}\n$0", + "description": "ifchildren" + }, + "import": { + "prefix": "import", + "body": "{% import \"${1:template}\" as ${2:name} %}$0", + "description": "import" + }, + "importself": { + "prefix": "importself", + "body": "{% import _self as ${1:name} %}$0", + "description": "importself" + }, + "inckv": { + "prefix": "inckv", + "body": + "{% include \"${1:template}\" with {\n\t${2:key}: ${3:\"${4:value}\"}\n} %}\n$0", + "description": "include w/ key/value" + }, + "include": { + "prefix": "include", + "body": "{% include \"${1:template}\" %}$0", + "description": "include" + }, + "inc": { + "prefix": "inc", + "body": "{% include \"${1:template}\" %}$0", + "description": "inc" + }, + "incp": { + "prefix": "incp", + "body": "{% include \"${1:template}\"${2: with ${3:params} }%}$0", + "description": "include w/ params" + }, + "css1": { + "prefix": "css", + "body": "{% do view.registerCssFile(\"${1:/resources/css/global.css}\") %}\n$0", + "description": "registerCssFile" + }, + "js": { + "prefix": "js", + "body": "{% js %}\n\t$1\n{% endjs %}\n$0", + "description": "js" + }, + "js1": { + "prefix": "js", + "body": "{% do view.registerJsFile(\"${1:/resources/js/global.js}\") %}\n$0", + "description": "registerJsFile" + }, + "css": { + "prefix": "css", + "body": "{% css %}\n\t$1\n{% endcss %}\n$0", + "description": "css" + }, + "macro": { + "prefix": "macro", + "body": "{% macro ${1:name}(${2:params}) %}\n\t$0\n{% endmacro %}", + "description": "macro" + }, + "matrix": { + "prefix": "matrix", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrix" + }, + "matrixif": { + "prefix": "matrixif", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\t\t{{ block.${3:fieldHandle} }}\n\t{% endif %}\n\n\t{% if block.type == \"${4:blockHandle}\" %}\n\t\t{{ block.${5:fieldHandle} }}\n\t{% endif %}\n\n{% endfor %}\n$0", + "description": "matrixif" + }, + "matrixifelse": { + "prefix": "matrixifelse", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% if block.type == \"${2:blockHandle}\" %}\n\n\t\t{{ block.${3:fieldHandle} }}\n\n\t{% elseif block.type == \"${4:blockHandle}\" %}\n\n\t\t$0\n\t\n\t{% endif %}\n\n{% endfor %}", + "description": "matrixifelse" + }, + "matrixswitch": { + "prefix": "matrixswitch", + "body": + "{% for block in ${1:entry.matrixFieldHandle}.all() %}\n\n\t{% switch block.type %}\n\n\t\t{% case \"${2:blockHandle}\" %}\n\n\t\t\t{{ block.${3:fieldHandle} }}\n\n\t\t{% case \"${4:blockHandle}\" %}\n\n\t\t\t$0\n\n\t{% endswitch %}\n\n{% endfor %}", + "description": "matrixswitch" + }, + "max": { + "prefix": "max", + "body": "max(${1:$2, $3})$0", + "description": "max" + }, + "min": { + "prefix": "min", + "body": "min(${1:$2, $3})$0", + "description": "min" + }, + "nav": { + "prefix": "nav", + "body": "{% nav ${1:item} in ${2:items} %}\n\t$3\n{% endnav %}\n$0", + "description": "nav" + }, + "paginate": { + "prefix": "paginate", + "body": + "{% paginate ${1:elements} as ${2:pageInfo}, ${3:pageEntries} %}\n\n{% for item in ${3:pageEntries} %}\n\t$0\n{% endfor %}\n\n{% if ${2:pageInfo}.prevUrl %}Previous Page{% endif %}\n{% if ${2:pageInfo}.nextUrl %}Next Page{% endif %}", + "description": "paginate simple" + }, + "paginate1": { + "prefix": "paginate", + "body": + "{# PAGINATION\n\t\t\nFor this pagination to work properly, we need to be sure to set\nthe paginateBase variable in the template we are including the \npagination in.\n\n{% set paginateBase = \"/blog/p\" %}\n#}\n\n{% if pageInfo.totalPages > 1 %}\n
    \n\t{% if pageInfo.currentPage != \"1\" %}\n\t\t
  • First Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.prevUrl %}\n\t\t
  • Previous Page
  • \n\t{% endif %}\n\n\t{% for pageNumber in 1..pageInfo.totalPages %}\n\t\t
  • \n\t\t\t{{ pageNumber }}\n\t\t
  • \n\t{% endfor %}\n\n\t{% if pageInfo.nextUrl %}\n\t\t
  • Next Page
  • \n\t{% endif %}\n\n\t{% if pageInfo.currentPage != pageInfo.total %}\n\t\t
  • Last Page
  • \n\t{% endif %}\n
\n{% endif %}\n$0", + "description": "paginate advanced" + }, + "redirect": { + "prefix": "redirect", + "body": + "{% redirect \"${1:template/path or http://straightupcraft.com}\" %}\n$0", + "description": "redirect" + }, + "getparam": { + "prefix": "getparam", + "body": + "craft.app.request.getParam(${1:\"Query String or Post Variable Name\"})\n$0", + "description": "request getParam" + }, + "getbodyparam": { + "prefix": "getbodyparam", + "body": "craft.app.request.getBodyParam(${1:\"postVariableName\"})\n$0", + "description": "request getBodyParam" + }, + "getqueryparam": { + "prefix": "getqueryparam", + "body": "craft.app.request.getQueryParam(${1:\"queryStringName\"})\n$0", + "description": "request getQueryParam" + }, + "getsegment": { + "prefix": "getsegment", + "body": "craft.app.request.getSegment(${1:2})\n$0", + "description": "request getSegment" + }, + "requirelogin": { + "prefix": "requirelogin", + "body": "{% requireLogin %}\n$0", + "description": "requireLogin" + }, + "requirepermission": { + "prefix": "requirepermission", + "body": "{% requirePermission \"${1:spendTheNight}\" %}\n$0", + "description": "requirePermission" + }, + "round": { + "prefix": "round", + "body": "{{ $1 | round(1, 'floor') }}$0", + "description": "round" + }, + "setb": { + "prefix": "setb", + "body": "{% set ${1:var} %}\n\t$0\n{% endset %}", + "description": "set (block)" + }, + "set": { + "prefix": "set", + "body": "{% set ${1:var} = ${2:value} %}$0", + "description": "set" + }, + "shuffle": { + "prefix": "shuffle", + "body": "shuffle($1)$0", + "description": "shuffle" + }, + "random": { + "prefix": "random", + "body": "random($1)$0", + "description": "random" + }, + "spaceless": { + "prefix": "spaceless", + "body": "{% spaceless %}\n\t$0\n{% endspaceless %}", + "description": "spaceless" + }, + "switch": { + "prefix": "switch", + "body": + "{% switch ${1:variable} %}\n\n\t{% case \"${2:value1}\" %}\n\t\n\n\t{% case \"${3:value2}\" %}\n\t\n\n\t{% default %}\n\t\n\n{% endswitch %}\n$0", + "description": "switch" + }, + "trans": { + "prefix": "trans", + "body": "{% trans %}$0{% endtrans %}", + "description": "trans" + }, + "urla": { + "prefix": "urla", + "body": + "url(\"${1:path}\", ${2:{foo:\"1\", bar:\"2\"\\}}, ${3:\"http\"}, ${4:false})$0", + "description": "url w/ arguments" + }, + "url": { + "prefix": "url", + "body": "url(\"${1:path}\")$0", + "description": "url" + }, + "use": { + "prefix": "use", + "body": "{% use \"${1:template}\" %}$0", + "description": "use" + }, + "verbatim": { + "prefix": "verbatim", + "body": "{% verbatim %}\n\t$0\n{% endverbatim %}", + "description": "verbatim" + } +} diff --git a/snippets/frameworks/vue/html.json b/snippets/frameworks/vue/html.json new file mode 100644 index 0000000..9cb50ff --- /dev/null +++ b/snippets/frameworks/vue/html.json @@ -0,0 +1,397 @@ +{ + "template": { + "prefix": "template", + "body": [ + "" + ], + "description": "template element" + }, + "v-text": { + "prefix": "vText", + "body": [ + "v-text=\"${1:msg}\"" + ], + "description": "Expects: string. Updates the element’s textContent." + }, + "v-html": { + "prefix": "vHtml", + "body": [ + "v-html=\"${1:html}\"" + ], + "description": "Expects: string. Updates the element’s innerHTML." + }, + "v-show": { + "prefix": "vShow", + "body": [ + "v-show=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-if": { + "prefix": "vIf", + "body": [ + "v-if=\"${1:condition}\"" + ], + "description": "Expects: any" + }, + "v-else": { + "prefix": "vElse", + "body": [ + "v-else" + ], + "description": "Does not expect expression. previous sibling element must have v-if or v-else-if." + }, + "v-else-if": { + "prefix": "vElseIf", + "body": [ + "v-else-if=\"${1:condition}\"" + ], + "description": "Expects: any. previous sibling element must have v-if or v-else-if." + }, + "v-for-without-key": { + "prefix": "vForWithoutKey", + "body": [ + "v-for=\"${1:item} in ${2:items}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-for": { + "prefix": "vFor", + "body": [ + "v-for=\"(${1:item}, ${2:index}) in ${3:items}\" :key=\"${4:index}\"" + ], + "description": "Expects: Array | Object | number | string" + }, + "v-on": { + "prefix": "vOn", + "body": [ + "v-on:${1:event}=\"${2:handle}\"" + ], + "description": "Expects: Function | Inline Statement" + }, + "v-bind": { + "prefix": "vBind", + "body": [ + "v-bind$1=\"${2}\"" + ], + "description": "Expects: any (with argument) | Object (without argument)" + }, + "v-model": { + "prefix": "vModel", + "body": [ + "v-model=\"${1:something}\"" + ], + "description": "Expects: varies based on value of form inputs element or output of components" + }, + "v-slot": { + "prefix": "vSlot", + "body": [ + "v-slot$1=\"${2}\"" + ], + "description": "Expects: JavaScript expression that is valid in a function argument position (supports destructuring in supported environments). Optional - only needed if expecting props to be passed to the slot." + }, + "v-pre": { + "prefix": "vPre", + "body": [ + "v-pre" + ], + "description": "Does not expect expression" + }, + "v-cloak": { + "prefix": "vCloak", + "body": [ + "v-cloak" + ], + "description": "Does not expect expression" + }, + "v-once": { + "prefix": "vOnce", + "body": [ + "v-once" + ], + "description": "Does not expect expression" + }, + "key": { + "prefix": "key", + "body": [ + ":key=\"${1:key}\"" + ], + "description": "Expects: string. Children of the same common parent must have unique keys. Duplicate keys will cause render errors." + }, + "ref": { + "prefix": "ref", + "body": [ + "ref=\"${1:reference}\"$0" + ], + "description": "Expects: string. ref is used to register a reference to an element or a child component. The reference will be registered under the parent component’s $refs object. If used on a plain DOM element, the reference will be that element; if used on a child component, the reference will be component instance." + }, + "slotA": { + "prefix": "slotA", + "body": [ + "slot=\"$1\"$0" + ], + "description": "slot=''. Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotE": { + "prefix": "slotE", + "body": [ + "$2$0" + ], + "description": ". Expects: string. Used on content inserted into child components to indicate which named slot the content belongs to." + }, + "slotScope": { + "prefix": "slotScope", + "body": [ + "slot-scope=\"$1\"$0" + ], + "description": "Used to denote an element or component as a scoped slot. The attribute’s value should be a valid JavaScript expression that can appear in the argument position of a function signature. This means in supported environments you can also use ES2015 destructuring in the expression. Serves as a replacement for scope in 2.5.0+." + }, + "scope": { + "prefix": "scope", + "body": [ + "scope=\"${1:this api replaced by slot-scope in 2.5.0+}\"$0" + ], + "description": "Used to denote a