diff --git a/README.md b/README.md index 8b31f770b..8cf06c4b8 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,9 @@ on the fly adding those. Currently all snippets from UltiSnips have been put into `/UltiSnips` - some work on merging should be done (dropping duplicates etc). Also see engines section above. +Since UltiSnips supports both UltiSnip and vim-snipmate snippets, when +contributing fixes/new snippets, please prefer adding vim-snipmate snippets. + Related repositories -------------------- @@ -245,7 +248,6 @@ This list is kept up-to-date on a best effort basis. * Python - [honza](http://github.com/honza) * Ruby - [taq](http://github.com/taq) * Scala - [gorodinskiy](https://github.com/gorodinskiy) -* Supercollider - [lpil](https://github.com/lpil) License ------- diff --git a/UltiSnips/cpp.snippets b/UltiSnips/cpp.snippets index a997f001e..4a22782fb 100644 --- a/UltiSnips/cpp.snippets +++ b/UltiSnips/cpp.snippets @@ -30,6 +30,11 @@ endglobal ########################################################################### # TextMate Snippets # ########################################################################### +snippet ponce "#pragma once include guard" +#pragma once + +endsnippet + snippet main int main(int argc, char *argv[]) { @@ -67,6 +72,14 @@ namespace${1/.+/ /m}${1:`!p snip.rv = snip.basename or "name"`} }${1/.+/ \/* /m}$1${1/.+/ *\/ /m} endsnippet +snippet nsa "namespace alias" +namespace ${1:alias} = ${2:namespace}; +endsnippet + +snippet using "using directive/using declaration/type alias" +using ${1:namespace}`!p snip.rv = ' ' if t[1] == 'namespace' else ' = ' if t[1] != '' else ''`${2:name}; +endsnippet + snippet readfile "read file (readF)" std::vector v; if (FILE *fp = fopen(${1:"filename"}, "r")) diff --git a/UltiSnips/eruby.snippets b/UltiSnips/eruby.snippets index ef93be440..8d97277df 100644 --- a/UltiSnips/eruby.snippets +++ b/UltiSnips/eruby.snippets @@ -44,13 +44,13 @@ snippet fi "<%= Fixtures.identify(:symbol) %>" endsnippet snippet ft "form_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1::action => '${2:update}'}${3:, ${4:${5:class} => '${6:form}'\}}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_INLINE', snip)`form_tag(${1:action: '${2:update}'}${3:, ${4:${5:class}: '${6:form}'\}}}) do`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` $0 `!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_BLOCK', snip)` endsnippet snippet ffs "form_for submit 2" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${1:f}.submit '${2:Submit}'${3:, :disable_with => '${4:$2ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`${1:f}.submit '${2:Submit}'${3:, disable_with: '${4:$2ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet f. "f_fields_for (nff)" w @@ -84,7 +84,7 @@ snippet f. "f.radio_button" w endsnippet snippet f. "f.submit" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, :disable_with => '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`f.submit "${1:Submit}"${2:, disable_with: '${3:$1ing...}'}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet f. "f.text_area" w @@ -110,19 +110,19 @@ snippet ff "form_for" w endsnippet snippet ist "image_submit_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, :id => "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, :name => "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, :class => "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, :disabled => ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_submit_tag("${1:agree.png}"${2:${3:, id: "${4:${1/^(\w+)(\.\w*)?$/$1/}}"}${5:, name: "${6:${1/^(\w+)(\.\w*)?$/$1/}}"}${7:, class: "${8:${1/^(\w+)(\.\w*)?$/$1/}-button}"}${9:, disabled: ${10:false}}})`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet it "image_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, :title => "${5:title}"}${6:, :class => "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`image_tag "$1${2:.png}"${3:${4:, title: "${5:title}"}${6:, class: "${7:class}"}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet layout "layout" -layout "${1:template_name}"${2:${3:, :only => ${4:[:${5:action}, :${6:action}]}}${7:, :except => ${8:[:${9:action}, :${10:action}]}}} +layout "${1:template_name}"${2:${3:, only: ${4:[:${5:action}, :${6:action}]}}${7:, except: ${8:[:${9:action}, :${10:action}]}}} endsnippet snippet jit "javascript_include_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`javascript_include_tag ${1::all}${2:, cache: ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet lt "link_to (name, dest)" w @@ -130,23 +130,23 @@ snippet lt "link_to (name, dest)" w endsnippet snippet lia "link_to (action)" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", action: "${2:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet liai "link_to (action, id)" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :action => "${2:edit}", :id => ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", action: "${2:edit}", id: ${3:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet lic "link_to (controller)" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", controller: "${2:items}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet lica "link_to (controller, action)" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", controller: "${2:items}", action: "${3:index}"`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet licai "link_to (controller, action, id)" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", :controller => "${2:items}", :action => "${3:edit}", :id => ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`link_to "${1:link text...}", controller: "${2:items}", action: "${3:edit}", id: ${4:@item}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet linpp "link_to (nested path plural)" w @@ -174,15 +174,15 @@ page.hide ${1:"${2:id(s)}"} endsnippet snippet ins "page.insert_html (position, id, partial)" -page.insert_html :${1:top}, ${2:"${3:id}"}, :${4:partial => "${5:template}"} +page.insert_html :${1:top}, ${2:"${3:id}"}, ${4:partial: "${5:template}"} endsnippet snippet rep "page.replace (id, partial)" -page.replace ${1:"${2:id}"}, :${3:partial => "${4:template}"} +page.replace ${1:"${2:id}"}, ${3:partial: "${4:template}"} endsnippet snippet reph "page.replace_html (id, partial)" -page.replace_html ${1:"${2:id}"}, :${3:partial => "${4:template}"} +page.replace_html ${1:"${2:id}"}, ${3:partial: "${4:template}"} endsnippet snippet show "page.show (*ids)" @@ -198,31 +198,31 @@ page.visual_effect :${1:toggle_slide}, ${2:"${3:DOM ID}"} endsnippet snippet rp "render (partial) (rp)" -render :partial => "${1:item}" +render partial: "${1:item}" endsnippet snippet rpc "render (partial,collection) (rpc)" -render :partial => "${1:item}", :collection => ${2:@$1s} +render partial: "${1:item}", collection: ${2:@$1s} endsnippet snippet rpl "render (partial,locals) (rpl)" -render :partial => "${1:item}", :locals => { :${2:$1} => ${3:@$1}$0 } +render partial: "${1:item}", locals: { ${2:$1}: ${3:@$1}$0 } endsnippet snippet rpo "render (partial,object) (rpo)" -render :partial => "${1:item}", :object => ${2:@$1} +render partial: "${1:item}", object: ${2:@$1} endsnippet snippet rps "render (partial,status) (rps)" -render :partial => "${1:item}", :status => ${2:500} +render partial: "${1:item}", status: ${2:500} endsnippet snippet slt "stylesheet_link_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, :cache => ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`stylesheet_link_tag ${1::all}${2:, cache: ${3:true}}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet st "submit_tag" w -`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, :id => "${3:submit}"}${4:, :name => "${5:$3}"}${6:, :class => "${7:form_$3}"}${8:, :disabled => ${9:false}}${10:, :disable_with => "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` +`!p textmate_var('TM_RAILS_TEMPLATE_START_RUBY_EXPR', snip)`submit_tag "${1:Save changes}"${2:, id: "${3:submit}"}${4:, name: "${5:$3}"}${6:, class: "${7:form_$3}"}${8:, disabled: ${9:false}}${10:, disable_with: "${11:Please wait...}"}`!p textmate_var('TM_RAILS_TEMPLATE_END_RUBY_EXPR', snip)` endsnippet snippet else "else (ERB)" diff --git a/UltiSnips/gitcommit.snippets b/UltiSnips/gitcommit.snippets index e2f1ba5d0..353aff747 100644 --- a/UltiSnips/gitcommit.snippets +++ b/UltiSnips/gitcommit.snippets @@ -71,6 +71,10 @@ build(${1:scope}): ${2:title} ${0:${VISUAL}} endsnippet +snippet Co-authored-by "Co-authored-by:" +Co-authored-by: ${1:Author Name} <${2:Email}> +endsnippet + snippet sign "Signature" ------------------------------------------------------------------------------- ${1:Company Name} diff --git a/UltiSnips/java.snippets b/UltiSnips/java.snippets index 55883a365..9c7ed8208 100644 --- a/UltiSnips/java.snippets +++ b/UltiSnips/java.snippets @@ -21,7 +21,7 @@ def nl(snip): snip.rv += " " def getArgs(group): import re - word = re.compile('[a-zA-Z0-9><.]+ \w+') + word = re.compile(r'[a-zA-Z0-9><.]+ \w+') return [i.split(" ") for i in word.findall(group) ] def camel(word): diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index f27ac8be5..def1ca4da 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -6,7 +6,7 @@ import vim # Set g:ultisnips_php_scalar_types to 1 if you'd like to enable PHP 7's scalar types for return values def isPHPScalarTypesEnabled(): isEnabled = vim.eval("get(g:, 'ultisnips_php_scalar_types', 0)") == "1" - return isEnabled or re.match('<\?php\s+declare\(strict_types=[01]\);', '\n'.join(vim.current.window.buffer)) + return isEnabled or re.match(r'<\?php\s+declare\(strict_types=[01]\);', '\n'.join(vim.current.window.buffer)) endglobal ## Snippets from SnipMate, taken from diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index dc5761af2..a47544117 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -127,14 +127,18 @@ def triple_quotes_handle_trailing(snip, quoting_style): if not snip.c: # Do this only once, otherwise the following error would happen: # RuntimeError: The snippets content did not converge: … - _, col = vim.current.window.cursor - line = vim.current.line + row, col = vim.current.window.cursor + + # before ultisnip expansion, chars ahead cursor is at row - 1, col + # after ultisnip expansion, they are pushed to row + 1, col - 1 + # when this function is run, it's already after ultisni expansion + line = snip.buffer[row + 1] # Handle already existing quote chars after the trigger. _ret = quoting_style * 3 while True: try: - nextc = line[col] + nextc = line[col - 1] except IndexError: break if nextc == quoting_style and len(_ret): diff --git a/UltiSnips/smarty.snippets b/UltiSnips/smarty.snippets new file mode 100644 index 000000000..09677d6f3 --- /dev/null +++ b/UltiSnips/smarty.snippets @@ -0,0 +1,28 @@ +# snippets for smarty3 + +extends html +extends javascript +extends css + + + + +# https://www.smarty.net/docs/en/language.function.append.tpl +snippet append "{append} is used for creating or appending template variable arrays during the execution of a template." +{append var='${1}' value='${2}'${3: index='${4|first,last|}'}${5: scope='${6|parent,root,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.assign.tpl +snippet assign "{assign} is used for assigning template variables during the execution of a template." +{assign var='${1}' value='${2}'${3: scope='${4|parent,root,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.config.load.tpl +snippet config_load "config_load" +{config_load file='${1}'${2: section='${3}'}${4: scope='${5|local,parent,global|}'}} +endsnippet + +# https://www.smarty.net/docs/en/language.function.include.tpl +snippet include "{include} tags are used for including other templates in the current template. Any variables available in the current template are also available within the included template." +{include file='${1}'${2: assign='${3}'}${4: cache_lifetime=${5}}${6: compile_id='${7}'}${8: cache_id='${9}'}${10: scope='${11|parent,root,global|}'}${12: variables}} +endsnippet diff --git a/UltiSnips/tex.snippets b/UltiSnips/tex.snippets index 00e910de4..69d86f443 100644 --- a/UltiSnips/tex.snippets +++ b/UltiSnips/tex.snippets @@ -36,24 +36,6 @@ endglobal # ENVIRONMENT # ############### -snippet beg "begin{} / end{}" bi -\begin{$1} - ${0:${VISUAL}} -\end{$1} -endsnippet - -snippet cnt "Center" bi -\begin{center} - ${0:${VISUAL}} -\end{center} -endsnippet - -snippet desc "Description" bi -\begin{description} - \item[${1:${VISUAL}}] $0 -\end{description} -endsnippet - snippet lemma "Lemma" bi \begin{lemma} ${0:${VISUAL}} @@ -135,24 +117,6 @@ snippet fig "Figure environment" bi \end{figure} endsnippet -snippet enum "Enumerate" bi -\begin{enumerate} - \item ${0:${VISUAL}} -\end{enumerate} -endsnippet - -snippet item "Itemize" bi -\begin{itemize} - \item ${0:${VISUAL}} -\end{itemize} -endsnippet - -snippet case "cases" bi -\begin{cases} - ${0:${VISUAL}} -\end{cases} -endsnippet - snippet abs "abstract environment" b \begin{abstract} ${0:${VISUAL}} @@ -160,9 +124,9 @@ snippet abs "abstract environment" b endsnippet snippet tab "tabular / array environment" b - \begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} - $0${2/(?<=.)(c|l|r)|./(?1: & )/g} - \end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} +\begin{${1:t}${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}}{${2:c}} +$0${2/(?<=.)(c|l|r)|./(?1: & )/g} +\end{$1${1/(t)$|(a)$|(.*)/(?1:abular)(?2:rray)/}} endsnippet snippet table "Table environment" b @@ -247,26 +211,6 @@ snippet srto "... Root" wi \sqrt[$1]{${2:${VISUAL}}}$0 endsnippet -snippet bf "Bold" wi -\bf{${1:${VISUAL}}}$0 -endsnippet - -snippet it "Italic" wi -\it{${1:${VISUAL}}}$0 -endsnippet - -snippet un "Underline" wi -\un{${1:${VISUAL}}}$0 -endsnippet - -snippet rm "Text" wi -\rm{${1:${VISUAL}}}$0 -endsnippet - -snippet itm "Item" wi -\item ${0:${VISUAL}} -endsnippet - snippet ceil "Ceil" w \left\lceil $1 \right\rceil $0 endsnippet @@ -283,34 +227,10 @@ snippet bmat "Bmat" w \begin{bmatrix} $1 \end{bmatrix} $0 endsnippet -snippet () "Left( right)" w -\left( ${1:${VISUAL}} \right) $0 -endsnippet - -snippet lr "left( right)" i -\left( ${1:${VISUAL}} \right) $0 -endsnippet - -snippet lr( "left( right)" i -\left( ${1:${VISUAL}} \right) $0 -endsnippet - -snippet lr| "left| right|" i -\left| ${1:${VISUAL}} \right| $0 -endsnippet - -snippet lr{ "left\{ right\}" i -\left\\{ ${1:${VISUAL}} \right\\} $0 -endsnippet - snippet lrb "left\{ right\}" i \left\\{ ${1:${VISUAL}} \right\\} $0 endsnippet -snippet lr[ "left[ right]" i -\left[ ${1:${VISUAL}} \right] $0 -endsnippet - snippet lra "leftangle rightangle" wi \left<${1:${VISUAL}} \right>$0 endsnippet @@ -371,11 +291,11 @@ snippet != "Not Equal" w \neq endsnippet -snippet <= "leq" Aw +snippet <= "leq" w \le endsnippet -snippet >= "geq" Aw +snippet >= "geq" w \ge endsnippet @@ -384,7 +304,7 @@ snippet nn "Tikz node" w $0 endsnippet -snippet lll "l" Aw +snippet lll "l" w \ell endsnippet @@ -400,7 +320,7 @@ snippet snippet inc #include <${1:stdio}.h> - $0 # #include "..." snippet Inc #include "${1:`vim_snippets#Filename("$1.h")`}" - $0 # ifndef...define...endif snippet ndef #ifndef $1 @@ -86,8 +84,8 @@ snippet elif snippet ifi if (${1:true}) ${0}; # ternary -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 # switch snippet switch switch (${1:/* variable */}) { @@ -138,7 +136,7 @@ snippet wht snippet do do { ${0:${VISUAL}} - } while (${1:/* condition */}); + } while ($1); ## ## Functions # function definition @@ -351,7 +349,7 @@ snippet getopt ## Assertions snippet asr - assert(${1:condition}); + assert($1); snippet anl assert(${1:ptr} != NULL); diff --git a/snippets/clojure.snippets b/snippets/clojure.snippets index 048ce9fee..cc9d07043 100644 --- a/snippets/clojure.snippets +++ b/snippets/clojure.snippets @@ -81,7 +81,7 @@ snippet print snippet reduce (reduce ${1:(fn [p n] ${3})} ${2}) snippet when - (when ${1:test} ${0:body}) + (when ${1:test} $0) snippet when-let (when-let [${1:result} ${2:test}] - ${0:body}) + $0) diff --git a/snippets/codeigniter.snippets b/snippets/codeigniter.snippets index c38aa4dbd..afaf9638c 100644 --- a/snippets/codeigniter.snippets +++ b/snippets/codeigniter.snippets @@ -99,7 +99,7 @@ snippet ci_db-select snippet ci_db-from $this->db->from("${1:table}");${2} snippet ci_db-join - $this->db->join("${1:table}", "${2:condition}", "${3:type}");${4} + $this->db->join("${1:table}", "$2", "${3:type}");${4} snippet ci_db-where $this->db->where("${1:key}", "${2:value}");${3} snippet ci_db-or_where diff --git a/snippets/coffee/coffee.snippets b/snippets/coffee/coffee.snippets index f23156cc8..d07b1b624 100644 --- a/snippets/coffee/coffee.snippets +++ b/snippets/coffee/coffee.snippets @@ -2,37 +2,37 @@ snippet forindo for ${1:name} in ${2:array} do ($1) -> - ${0:// body} + $0 # Array comprehension snippet fora for ${1:name} in ${2:array} - ${0:# body...} + $0 # Object comprehension snippet foro for ${1:key}, ${2:value} of ${3:object} - ${0:# body...} + $0 # Range comprehension (inclusive) snippet forr for ${1:name} in [${2:start}..${3:finish}] - ${0:# body...} + $0 snippet forrb for ${1:name} in [${2:start}..${3:finish}] by ${4:step} - ${0:# body...} + $0 # Range comprehension (exclusive) snippet forrex for ${1:name} in [${2:start}...${3:finish}] - ${0:# body...} + $0 snippet forrexb for ${1:name} in [${2:start}...${3:finish}] by ${4:step} - ${0:# body...} + $0 # Function snippet fun (${1:args}) -> - ${0:# body...} + $0 # Function (bound) snippet bfun (${1:args}) => - ${0:# body...} + $0 # Class snippet cla class .. class ${1:`substitute(vim_snippets#Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} @@ -54,29 +54,29 @@ snippet cla class .. extends .. constructor: .. ${0} # If snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} # If __ Else snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else - ${0:# body...} + ${0} # Else if snippet eif - else if ${1:condition} + else if $1 ${0:${VISUAL}} # Ternary If -snippet ifte - if ${1:condition} then ${2:value} else ${0:other} +snippet ifte Ternary + if $1 then $2 else $0 # Unless -snippet unl - ${1:action} unless ${0:condition} +snippet unl Unless + $1 unless $0 # Switch snippet swi switch ${1:object} when ${2:value} - ${0:# body...} + $0 # Log snippet log diff --git a/snippets/cpp.snippets b/snippets/cpp.snippets index 4e4155a82..bb9528a6f 100644 --- a/snippets/cpp.snippets +++ b/snippets/cpp.snippets @@ -230,3 +230,50 @@ snippet af auto function { ${0} }; +# Range-v3 transform +snippet transform "ranges::views::transform" + ${1:${2:std::}${3:ranges::}views::}transform($4) +# Range-v3 transform +snippet filter "ranges::views::filter" + ${1:${2:std::}${3:ranges::}views::}filter($4) +# Range-v3 ranges:: +snippet r "ranges::" + ranges:: +# Range-v3 ranges::views:: +snippet rv "ranges::views::" + ranges::views:: +# Range-v3 ranges::actions:: +snippet ra "ranges::actions::" + ranges::actions:: +# STL std::ranges:: +snippet sr "std::ranges::" + std::ranges:: +# STL std::views:: +snippet sv "std::views::" + std::views:: +## +## Tests +# GTest:add main +snippet gtemain "GTest:add main" + int main(int argc, char **argv) { + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); + } +# GTest:add test +snippet gtetest "GTest:add test" + TEST(${1:SuiteName}, ${2:TestName}) { + ${0} + } +# GTest:add fixture +snippet gtefix "GTest:add fixture" + TEST_F(${1:SuiteName}, ${2:TestName}) { + ${0} + } +# GTest:add parameterized test +snippet gtepar "GTest:add parameterized test" + TEST_P(${1:SuiteName}, ${2:TestName}) { + ${0} + } +# GTest:instantiate parameterized test +snippet gteparins "GTest:instantiate parameterized test" + INSTANTIATE_TEST_SUITE_P(${1:InstantiationName}, ${2:SuiteName}, ${0}); diff --git a/snippets/crystal.snippets b/snippets/crystal.snippets index 34d254065..a5848f88e 100644 --- a/snippets/crystal.snippets +++ b/snippets/crystal.snippets @@ -1,12 +1,12 @@ snippet req require require "${1}" snippet case - case ${1:object} - when ${2:condition} + case $1 + when $2 ${0} end snippet when - when ${1:condition} + when $1 ${0} snippet def def ${1:method_name} @@ -17,17 +17,17 @@ snippet pdef ${0} end snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} end snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else ${0} end snippet wh - while ${1:condition} + while $1 ${0:${VISUAL}} end snippet cla class .. end diff --git a/snippets/dart-flutter.snippets b/snippets/dart-flutter.snippets index f51f11ca4..86775cb6c 100644 --- a/snippets/dart-flutter.snippets +++ b/snippets/dart-flutter.snippets @@ -3,6 +3,8 @@ # Flutter stateless widget snippet stless class $1 extends StatelessWidget { + const $1({super.key}); + @override Widget build(BuildContext context) { return Container( @@ -14,8 +16,10 @@ snippet stless # Flutter stateful widget snippet stful class $1 extends StatefulWidget { + const $1({super.key}); + @override - _$1State createState() => _$1State(); + State<$1> createState() => _$1State(); } class _$1State extends State<$1> { @@ -30,8 +34,10 @@ snippet stful # Flutter widget with AnimationController snippet stanim class $1 extends StatefulWidget { + const $1({super.key}); + @override - _$1State createState() => _$1State(); + State<$1> createState() => _$1State(); } class _$1State extends State<$1> @@ -85,5 +91,3 @@ snippet fsa ); } } - - diff --git a/snippets/dart.snippets b/snippets/dart.snippets index de5cb6239..30ab3d5d8 100644 --- a/snippets/dart.snippets +++ b/snippets/dart.snippets @@ -1,3 +1,10 @@ +snippet af + (${1}) {${2}}${0} +snippet pr + print(${1}); +snippet deb + debugger(); + ${0} snippet lib library ${1}; ${0} @@ -61,15 +68,15 @@ snippet fore ${0} } snippet wh - while (${1:/* condition */}) { + while ($1) { ${0} } snippet dowh do { ${0} - } while (${0:/* condition */}); + } while ($0); snippet as - assert(${0:/* condition */}); + assert($0); snippet try try { ${0:${VISUAL}} diff --git a/snippets/elixir.snippets b/snippets/elixir.snippets index ee093eb9c..37b1c0191 100644 --- a/snippets/elixir.snippets +++ b/snippets/elixir.snippets @@ -3,9 +3,9 @@ snippet do ${0:${VISUAL}} end snippet put IO.puts - IO.puts "${0}" + IO.puts("${0}") snippet ins IO.inspect - IO.inspect ${0} + IO.inspect(${0}) snippet insl IO.inspect with label IO.inspect(${0}label: "${1:label}") snippet if if .. do .. end @@ -13,29 +13,29 @@ snippet if if .. do .. end ${0:${VISUAL}} end snippet if: if .. do: .. - if ${1:condition}, do: ${0} + if $1, do: ${0} snippet ife if .. do .. else .. end - if ${1:condition} do + if $1 do ${2:${VISUAL}} else ${0} end snippet ife: if .. do: .. else: - if ${1:condition}, do: ${2}, else: ${0} + if $1, do: ${2}, else: ${0} snippet unless unless .. do .. end unless ${1} do ${0:${VISUAL}} end snippet unless: unless .. do: .. - unless ${1:condition}, do: ${0} + unless $1, do: ${0} snippet unlesse unless .. do .. else .. end - unless ${1:condition} do + unless $1 do ${2:${VISUAL}} else ${0} end snippet unlesse: unless .. do: .. else: - unless ${1:condition}, do: ${2}, else: ${0} + unless $1, do: ${2}, else: ${0} snippet cond cond do ${1} -> @@ -247,7 +247,7 @@ snippet >f pipe to filter snippet >r pipe to reduce |> Enum.reduce(${1:acc}, fn ${2}, ${3:acc} -> ${0} end) snippet >i pipe to inspect - |> IO.inspect + |> IO.inspect() snippet >il pipe to inspect with label |> IO.inspect(label: "${1:label}") snippet cs @@ -265,22 +265,27 @@ snippet genserver basic genserver structure use GenServer @doc false - def start_link do - GenServer.start_link(__MODULE__, ${1:Map.new}) + def start_link(init_args) do + GenServer.start_link(__MODULE__, init_args, name: __MODULE__) end @impl true def init(state) do {:ok, state} end -snippet genserver: basic genserver structure - use GenServer +snippet super basic supervisor structure + use Supervisor @doc false - def start_link, do: GenServer.start_link(__MODULE__, ${1:Map.new}) + def start_link(init_args) do + Supervisor.start_link(__MODULE__, init_args, name: __MODULE__) + end @impl true - def init(state), do: {:ok, state} + def init(_init_args) do + children = [${1}] + Supervisor.init(children, strategy: :one_for_one) + end snippet impl @impl true def ${1:name} do diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index 7a0a6116a..d655a9b9a 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -17,7 +17,7 @@ snippet dt erlang:display({${1}, ${0}}), # define directive snippet def - -define(${1:macro}, ${2:body}). + -define(${1:macro}, $2). # export directive snippet exp -export([${1:function}/${0:arity}]). @@ -44,17 +44,17 @@ snippet undef snippet if if ${1:guard} -> - ${0:body} + $0 end # case expression snippet case case ${1:expression} of ${2:pattern} -> - ${0:body}; + $0; end # anonymous function snippet fun - fun (${1:Parameters}) -> ${2:body} end + fun (${1:Parameters}) -> $2 end # try...catch snippet try try @@ -65,10 +65,10 @@ snippet try snippet rcv "Receive Expression" receive ${1: ${2:pattern}${3: when ${4:guard}} -> - ${5:body}} + $5 ${6:after ${7:expression} -> - ${8:body}} + $8 end # record directive snippet rec diff --git a/snippets/falcon.snippets b/snippets/falcon.snippets index c523980d6..5894fe1c3 100644 --- a/snippets/falcon.snippets +++ b/snippets/falcon.snippets @@ -19,13 +19,13 @@ snippet class # If snippet if - if ${1:condition} + if $1 ${0} end # If else snippet ife - if ${1:condition} + if $1 ${0} else ${1} @@ -33,7 +33,7 @@ snippet ife # If else if snippet eif - elif ${1:condition} + elif $1 ${0} # Switch case diff --git a/snippets/fortran.snippets b/snippets/fortran.snippets index 8cb6f9a75..a073424e4 100644 --- a/snippets/fortran.snippets +++ b/snippets/fortran.snippets @@ -64,7 +64,7 @@ snippet intent snippet / (/ $1 /) ${2:,&} ${0} snippet if - if (${1:condition}) then + if ($1) then ${0} end if snippet case @@ -78,7 +78,7 @@ snippet do ${0} end do snippet dow - do while (${1:condition}) + do while ($1) $2 end do snippet sub diff --git a/snippets/gdscript.snippets b/snippets/gdscript.snippets new file mode 100644 index 000000000..e404092ba --- /dev/null +++ b/snippets/gdscript.snippets @@ -0,0 +1,125 @@ +snippet class + class $1 extends ${2:Reference} + \t$3 + + +snippet pr + print($1) + + +snippet ready + func _ready(): + \t${1:pass} + + +snippet init + func _init(): + \t${1:pass} + + +snippet process + func _process(delta): + \t${1:pass} + + +snippet input + func _input(event): + \t${1:pass} + + +snippet inpute + func _input_event(event): + \t${1:pass} + + +snippet draw + func _draw(): + \t${1:pass} + + +snippet guii + func _gui_input(event): + \t${1:pass} + + +snippet for + for $1 in $2: + \t${3:pass} + + +snippet for + for $1 in range(${2:start}{$3:,end}): + \t${4:pass} + + +snippet if + if ${1:condition}: + \t${3:pass} + elif ${2:condition}: + \t${4:pass} + else: + \t${5:pass} + + +snippet if + if ${1:condition}: + \t${2:pass} + else: + \t${3:pass} + + +snippet if + if ${1:condition}: + \t${2:pass} + + +snippet while + while ${1:condition}: + \t${2:pass} + + +snippet func + func ${1:method}(${2:args}): + \t${3:pass} + + +snippet signal + signal ${1:signalname}(${2:args}) + + +snippet export + export(${1:type}${2:,other_configs}) var ${3:name}${4: = default}${5: setget } + + +snippet var + var ${1:name}${2: = default}${3: setget } + + +snippet onready + onready var ${1:name} = get_node($2) + + +snippet is + ${1:instance} is ${2:class} + + +snippet in + ${1:element} in ${$2:array} + + +snippet gdscript + extends ${1:BaseClass} + + # class member variables go here, for example: + # var a = 2 + # var b = \textvar\ + + func _ready(): + \t# Called every time the node is added to the scene. + \t# Initialization here + \tpass + + + +# snippet pass ##### do we really need this? +# pass diff --git a/snippets/gleam.snippets b/snippets/gleam.snippets index a01e54075..de4056976 100644 --- a/snippets/gleam.snippets +++ b/snippets/gleam.snippets @@ -1,98 +1,78 @@ snippet fn "fn" - fn ${1:function_name}(${2}) -> ${3:Nil} { - ${0:${VISUAL:todo}} - } + fn ${1:function_name}(${2}) -> ${3:Nil} { + ${0:${VISUAL:todo}} + } snippet pfn "pub fn" - pub fn ${1:function_name}(${2}) -> ${3:Nil} { - ${0:${VISUAL:todo}} - } + pub fn ${1:function_name}(${2}) -> ${3:Nil} { + ${0:${VISUAL:todo}} + } snippet test "test fn" - pub fn ${1:name}_test() { - ${0} - } + pub fn ${1:name}_test() { + ${0} + } snippet af "anonymous fn" - fn(${1}) { ${0:${VISUAL}} } + fn(${1}) { ${0:${VISUAL}} } snippet let "let binding" - let ${1} = ${0} + let ${1} = ${0} snippet l "let binding" - let ${1} = ${0} + let ${1} = ${0} snippet as "assert binding" - assert ${1} = ${0} - -snippet tr "try binding" - try ${1} = ${0} + let assert ${1} = ${0} snippet - "->" - -> ${0} + -> ${0} snippet case "case expression" - case ${1} { - ${2} -> ${0} - } + case ${1} { + ${2} -> ${0} + } snippet ty "type" - type ${1:Name} { - ${0:$1} - } + type ${1:Name} { + ${0:$1} + } snippet pty "pub type" - pub type ${1:Name} { - ${0:$1} - } + pub type ${1:Name} { + ${0:$1} + } snippet tya "type alias" - type ${1:Name} = - ${0:$1} + type ${1:Name} = + ${0:$1} snippet ptya "pub type alias" - pub type ${1:Name} = - ${0:$1} - -snippet ext "external type" - external type ${0} - -snippet pext "pub external type" - pub external type ${0} - -snippet exfn "external fn" - external fn ${1:function_name}(${2}) -> ${3} - = "${4}" "${0}" - -snippet pexfn "pub external fn" - pub external fn ${1:function_name}(${2}) -> ${3} - = "${4}" "${0}" + pub type ${1:Name} = + ${0:$1} snippet im "import" - import ${0:gleam/result} + import ${0:gleam/result} snippet im. "import exposing" - import ${1:gleam/result}.{${0}} + import ${1:gleam/result}.{${0}} snippet p "|>" - |> ${0} - -snippet tup "tuple()" - tuple(${0:${VISUAL}}) + |> ${0} snippet bl "block" - { - ${0:${VISUAL}} - } + { + ${0:${VISUAL}} + } snippet tf "fn(Type) -> Type" - fn(${1}) -> ${0} + fn(${1}) -> ${0} snippet seq "should.equal" - should.equal(${0:${VISUAL}}) + should.equal(${0:${VISUAL}}) snippet strue "should.be_true" - should.be_true(${0:${VISUAL}}) + should.be_true(${0:${VISUAL}}) snippet sfalse "should.be_false" - should.be_true(${0:${VISUAL}}) + should.be_false(${0:${VISUAL}}) diff --git a/snippets/go.snippets b/snippets/go.snippets index 722e82fd4..1c785f862 100644 --- a/snippets/go.snippets +++ b/snippets/go.snippets @@ -59,18 +59,18 @@ snippet in "interface" interface{} snippet inf "full interface " - interface ${1:name} { + type ${1:name} interface { ${2:/* methods */} } snippet if "if condition" - if ${1:/* condition */} { + if $1 { ${2:${VISUAL}} } snippet ife "if else condition" - if ${1:/* condition */} { + if $1 { ${2:${VISUAL}} } else { ${0} @@ -188,7 +188,7 @@ snippet sr "string" string snippet st "struct" - struct ${1:name} { + type ${1:name} struct { ${2:/* data */} } ${0} diff --git a/snippets/haml.snippets b/snippets/haml.snippets index b1feaa51f..798c555ee 100644 --- a/snippets/haml.snippets +++ b/snippets/haml.snippets @@ -26,12 +26,12 @@ snippet mt snippet mts = mail_to ${1:email_address}, ${2:name}, :subject => ${3}, :body => ${4} snippet ife - - if ${1:condition} + - if $1 ${2:${VISUAL}} - else ${0} snippet ifp - - if ${1:condition}.presence? + - if $1.presence? ${0:${VISUAL}} snippet ntc = number_to_currency(${1}) diff --git a/snippets/heex.snippets b/snippets/heex.snippets new file mode 100644 index 000000000..41cc260a4 --- /dev/null +++ b/snippets/heex.snippets @@ -0,0 +1 @@ +extends eelixir diff --git a/snippets/html.snippets b/snippets/html.snippets index bf7170032..5388dbc8e 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -456,7 +456,7 @@ snippet html5l ${3:link} - ${0:body} + $0 snippet i diff --git a/snippets/htmltornado.snippets b/snippets/htmltornado.snippets index 1620e11da..5dd81555e 100644 --- a/snippets/htmltornado.snippets +++ b/snippets/htmltornado.snippets @@ -24,11 +24,11 @@ snippet for snippet from {% from ${1:x} import ${0:y} %} snippet if - {% if ${1:condition} %} + {% if $1 %} ${0} {% end %} snippet eif - {% elif ${0:condition} %} + {% elif $0 %} snippet el {% else %} snippet import @@ -50,6 +50,6 @@ snippet try ${0} {% end %} snippet wh - {% while ${1:condition} %} + {% while $1 %} ${0} {% end %} diff --git a/snippets/java.snippets b/snippets/java.snippets index 997089774..d3e69684e 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -142,9 +142,9 @@ snippet ae snippet aae assertArrayEquals("${1:Failure message}", ${2:expecteds}, ${3:actuals}); snippet af - assertFalse("${1:Failure message}", ${2:condition}); + assertFalse("${1:Failure message}", $2); snippet at - assertTrue("${1:Failure message}", ${2:condition}); + assertTrue("${1:Failure message}", $2); snippet an assertNull("${1:Failure message}", ${2:object}); snippet ann diff --git a/snippets/javascript/javascript.snippets b/snippets/javascript/javascript.snippets index b34495c4b..de1ca113b 100644 --- a/snippets/javascript/javascript.snippets +++ b/snippets/javascript/javascript.snippets @@ -62,8 +62,8 @@ snippet ife "if (condition) { ... } else { ... }" ${2} } # tertiary conditional -snippet ter - ${1:/* condition */} ? ${2:/* if true */} : ${0:/* if false */} +snippet ter Ternary: `condition ? true : false` + $1 ? $2: $0 # switch snippet switch switch (${1:expression}) { @@ -117,7 +117,7 @@ snippet wht "(true) { ... }" snippet do "do { ... } while (condition)" do { ${0:${VISUAL}} - } while (${1:/* condition */}); + } while ($1); # For in loop snippet fori for (let ${1:prop} in ${2:object}) { diff --git a/snippets/liquid.snippets b/snippets/liquid.snippets index 72a78d0e4..e12bf0604 100644 --- a/snippets/liquid.snippets +++ b/snippets/liquid.snippets @@ -2,32 +2,32 @@ # https://marketplace.visualstudio.com/items?itemName=killalau.vscode-liquid-snippets snippet if - {% if ${1:condition} %} + {% if $1 %} ${0:${VISUAL}} {% endif %} snippet else {% else %} snippet elsif - {% elsif ${1:condition} %} + {% elsif $1 %} snippet ifelse - {% if ${1:condition} %} + {% if $1 %} ${2} {% else %} ${0} {% endif %} snippet unless - {% unless ${1:condition} %} + {% unless $1 %} ${0:${VISUAL}} {% endunless %} snippet case {% case ${1:variable} %} - {% when ${2:condition} %} + {% when $2 %} ${3} {% else %} ${0} {% endcase %} snippet when - {% when ${1:condition} %} + {% when $1 %} ${0:${VISUAL}} snippet cycle {% cycle '${1:odd}', '${2:even}' %} @@ -102,32 +102,32 @@ snippet javascript snippet comment- {%- comment -%}${0:${VISUAL}}{%- endcomment -%} snippet if- - {%- if ${1:condition} -%} + {%- if $1 -%} ${0:${VISUAL}} {%- endif -%} snippet else- {%- else -%} snippet elsif- - {%- elsif ${1:condition} -%} + {%- elsif $1 -%} snippet ifelse- - {%- if ${1:condition} -%} + {%- if $1 -%} ${2} {%- else -%} ${0} {%- endif -%} snippet unless- - {%- unless ${1:condition} -%} + {%- unless $1 -%} ${0:${VISUAL}} {%- endunless -%} snippet case- {%- case ${1:variable} -%} - {%- when ${2:condition} -%} + {%- when $2 -%} ${3} {%- else -%} ${0} {%- endcase -%} snippet when- - {%- when ${1:condition} -%} + {%- when $1 -%} ${0:${VISUAL}} snippet cycle- {%- cycle '${1:odd}', '${2:even}' -%} diff --git a/snippets/lpc.snippets b/snippets/lpc.snippets index 2a849efaf..3410c93b3 100644 --- a/snippets/lpc.snippets +++ b/snippets/lpc.snippets @@ -66,8 +66,8 @@ snippet elif snippet ifi if(${1:true}) ${0}; # ternary -snippet t - ${1:/* condition */} ? ${2:a} : ${3:b} +snippet t Ternary: `condition ? true : false` + $1 ? $2 : $0 # switch snippet switch switch(${1:/* variable */}) @@ -115,7 +115,7 @@ snippet forr } # while snippet wh - while(${1:/* condition */}) + while($1) { ${0:${VISUAL}} } @@ -123,7 +123,7 @@ snippet wh snippet do do{ ${0:${VISUAL}} - }while (${1:/* condition */}); + }while ($1); ## ## Functions # function definition diff --git a/snippets/ls.snippets b/snippets/ls.snippets index 7c924e64d..822119d99 100644 --- a/snippets/ls.snippets +++ b/snippets/ls.snippets @@ -54,24 +54,24 @@ snippet cla class .. extends .. constructor: .. ${5} # If snippet if - if ${1:condition} + if $1 ${2} # If __ Else snippet ife - if ${1:condition} + if $1 ${2} else ${3} # Else if snippet elif - else if ${1:condition} + else if $1 ${2} # Ternary If snippet ifte - if ${1:condition} then ${2:value} else ${3:other} + if $1 then $2 else $0 # Unless snippet unl - ${1:action} unless ${2:condition} + $1 unless $0 # Switch snippet swi switch ${1:object} diff --git a/snippets/lua.snippets b/snippets/lua.snippets index 868f2f62a..6fe3fd365 100644 --- a/snippets/lua.snippets +++ b/snippets/lua.snippets @@ -5,7 +5,7 @@ snippet local local ${1:x} = ${0:1} snippet fun function ${1:fname}(${2:...}) - ${0:-- body} + $0 end snippet for for ${1:i}=${2:1},${3:10} do @@ -13,32 +13,32 @@ snippet for end snippet forp for ${1:i},${2:v} in pairs(${3:table_name}) do - ${0:-- body} + $0 end snippet fori for ${1:i},${2:v} in ipairs(${3:table_name}) do - ${0:-- body} + $0 end snippet if - if ${1:condition} then - ${2:-- body} + if $1 then + $2 end snippet ife - if ${1:condition} then + if $1 then ${2:-- if condition} else ${0:-- else} end snippet elif - elseif ${1:condition} then - ${0:--body} + elseif $1 then + $0 snippet repeat repeat - ${1:--body} - until ${0:condition} + $1 + until $0 snippet while - while ${1:condition} do - ${0:--body} + while $1 do + $0 end snippet wh while ${1:true} do @@ -68,5 +68,5 @@ snippet fwrs io.${1:stderr}:write("$0") snippet fwrf io.${1:stderr}:write(string.format("${2:%s}"$0)) -snippet im - import "${1:import file}" +snippet req + require('${1:mod}') diff --git a/snippets/mako.snippets b/snippets/mako.snippets index 659caf77d..b2ff4052a 100644 --- a/snippets/mako.snippets +++ b/snippets/mako.snippets @@ -19,11 +19,11 @@ snippet for ${0:} % endfor snippet if if - % if ${1:condition}: + % if $1: ${0:} % endif snippet ife if/else - % if ${1:condition}: + % if $1: ${2:} % else: ${0:} diff --git a/snippets/markdown.snippets b/snippets/markdown.snippets index 364066cfa..a8b00cfb2 100644 --- a/snippets/markdown.snippets +++ b/snippets/markdown.snippets @@ -5,7 +5,7 @@ # The suffix `c` stands for "Clipboard". snippet [ - [${1:text}](https://${2:address}) + [${1:text}](${2:address}) snippet [* [${1:link}](${2:`@*`}) snippet [c @@ -67,17 +67,21 @@ snippet <* <`@*`> snippet -snippet ** - **${1:bold}** -snippet __ - __${1:bold}__ -snippet === +snippet ** Bold + **$0** +snippet __ Bold + __$0__ +snippet --- Front matter + --- + $0 + --- +snippet ==== `repeat('=', strlen(getline(line('.') - 3)))` ${0} snippet - - ${0} -snippet --- +snippet ---- `repeat('-', strlen(getline(line('.') - 3)))` ${0} @@ -142,3 +146,11 @@ snippet pullquote {% pullquote %} ${1:text} {" ${2:quote} "} ${0:text} {% endpullquote %} + +# Definition lists +snippet : Definition list + $1 + : $0 +snippet :: Alternate definition list + $1 + - $0 diff --git a/snippets/org.snippets b/snippets/org.snippets new file mode 100644 index 000000000..0559cd68a --- /dev/null +++ b/snippets/org.snippets @@ -0,0 +1,135 @@ +# Org Mode Snippets Imported from (https://github.com/doomemacs/snippets/) +# Imported by ybenel (github.com/m1ndo) + +# Begin +snippet begin + #+begin_${1:type} ${2:options} + $0 + #+end_$1 +# Begin Center +snippet snippet case case ${1:object} - when ${2:condition} + when $2 ${0} end snippet when - when ${1:condition} + when $1 ${0:${VISUAL}} snippet def def ${1:method_name} ${0} end +snippet defm + def ${1:method} + @$1 ||= ${0} + end snippet deft def test_${1:case_name} ${0} @@ -55,46 +59,46 @@ snippet descendants end end snippet if - if ${1:condition} + if $1 ${0:${VISUAL}} end snippet ife - if ${1:condition} + if $1 ${2:${VISUAL}} else ${0} end snippet eif - elsif ${1:condition} + elsif $1 ${0:${VISUAL}} snippet ifee - if ${1:condition} + if $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet unless - unless ${1:condition} + unless $1 ${0:${VISUAL}} end snippet unlesse - unless ${1:condition} + unless $1 $2 else $0 end snippet unlesee - unless ${1:condition} + unless $1 $2 - elsif ${3:condition} + elsif $3 $4 else $0 end snippet wh - while ${1:condition} + while $1 ${0:${VISUAL}} end snippet for @@ -102,7 +106,7 @@ snippet for ${0} end snippet until - until ${1:condition} + until $1 ${0:${VISUAL}} end snippet cla class .. end @@ -199,18 +203,18 @@ snippet defds snippet am alias_method :${1:new_name}, :${0:old_name} snippet app - if __FILE__ == $PROGRAM_NAME + if __FILE__ == \$PROGRAM_NAME ${0} end # usage_if() snippet usai if ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} + abort "Usage: #{\$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} end # usage_unless() snippet usau unless ARGV.${1} - abort "Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} + abort "Usage: #{\$PROGRAM_NAME} ${2:ARGS_GO_HERE}"${0} end snippet array Array.new(${1:10}) { |${2:i}| ${0} } @@ -372,6 +376,8 @@ snippet finad end snippet gre grep(${1:/pattern/}) { |${2:match}| ${0} } +snippet grepv + select { |${1:line}| $1 !~ ${2:/pattern/} }${0} snippet sub ${1:g}sub(${2:/pattern/}) { |${3:match}| ${0} } snippet sca @@ -439,7 +445,7 @@ snippet optp options = { ${0:default: 'args'} } ARGV.options do |opts| - opts.banner = "Usage: #{File.basename($PROGRAM_NAME)}" + opts.banner = "Usage: #{File.basename(\$PROGRAM_NAME)}" end snippet opt opts.on('-${1:o}', '--${2:long-option-name}', ${3:String}, '${4:Option description.}') do |${5:opt}| @@ -606,6 +612,8 @@ snippet debug18 require 'ruby-debug'; debugger snippet pry require 'pry'; binding.pry +snippet irb + binding.irb snippet strf strftime('${1:%Y-%m-%d %H:%M:%S %z}')${0} # diff --git a/snippets/rust.snippets b/snippets/rust.snippets index 5e9eb2b18..04f05dd60 100644 --- a/snippets/rust.snippets +++ b/snippets/rust.snippets @@ -147,7 +147,7 @@ snippet loop "loop {}" b ${0:${VISUAL}} } snippet wh "while loop" - while ${1:condition} { + while $1 { ${0:${VISUAL}} } snippet whl "while let (...)" diff --git a/snippets/sass.snippets b/snippets/sass.snippets index 30bac6c7e..992341e7c 100644 --- a/snippets/sass.snippets +++ b/snippets/sass.snippets @@ -13,15 +13,15 @@ snippet fun @function ${1:name}(${2:args}) ${0} snippet if - @if ${1:condition} + @if $1 ${0:${VISUAL}} snippet ife - @if ${1:condition} + @if $1 ${2:${VISUAL}} @else ${0} snippet eif - @else if ${1:condition} + @else if $1 ${0:${VISUAL}} snippet for @for ${1:$i} from ${2:1} through ${3:3} diff --git a/snippets/scheme.snippets b/snippets/scheme.snippets index 4c0c78a09..0aa137945 100644 --- a/snippets/scheme.snippets +++ b/snippets/scheme.snippets @@ -17,7 +17,7 @@ snippet * # Definition snippet def (define (${1:name}) - ${0:definition}) + ${0:definition}) # Definition with lambda snippet defl diff --git a/snippets/scss.snippets b/snippets/scss.snippets index 998a12005..475c2b387 100644 --- a/snippets/scss.snippets +++ b/snippets/scss.snippets @@ -17,17 +17,17 @@ snippet fun ${0} } snippet if - @if ${1:condition} { + @if $1 { ${0} } snippet ife - @if ${1:condition} { + @if $1 { ${2} } @else { ${0} } snippet eif - @else if ${1:condition} { + @else if $1 { ${0} } snippet for diff --git a/snippets/sh.snippets b/snippets/sh.snippets index 9c7573327..ef94e683e 100644 --- a/snippets/sh.snippets +++ b/snippets/sh.snippets @@ -1,9 +1,9 @@ -# Shebang. Executing bash via /usr/bin/env makes scripts more portable. +# Shebang snippet #! - #!/usr/bin/env sh + #!/bin/sh snippet s#! - #!/usr/bin/env sh + #!/bin/sh set -eu snippet safe @@ -18,11 +18,11 @@ snippet sbash IFS=$'\n\t' snippet if - if [ ${1:condition} ]; then + if [ $1 ]; then ${0:${VISUAL}} fi snippet elif - elif [ ${1:condition} ]; then + elif [ $1 ]; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -33,7 +33,7 @@ snippet fori ${0:${VISUAL}} done snippet wh - while [ ${1:condition} ]; do + while [ $1 ]; do ${0:${VISUAL}} done snippet wht @@ -41,7 +41,7 @@ snippet wht ${0:${VISUAL}} done snippet until - until [ ${1:condition} ]; do + until [ $1 ]; do ${0:${VISUAL}} done snippet case @@ -101,10 +101,10 @@ snippet root snippet fun-sh ${1:function_name}() { - ${0:#function_body} + $0 } snippet fun function ${1:function_name}() { - ${0:#function_body} + $0 } diff --git a/snippets/smarty.snippets b/snippets/smarty.snippets new file mode 100644 index 000000000..070fcd7e1 --- /dev/null +++ b/snippets/smarty.snippets @@ -0,0 +1,139 @@ +# snippets for smarty3 + +extends html +extends javascript +extends css + +# https://www.smarty.net/docs/en/language.function.if.tpl +snippet if "{if cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ifn "{if !cond} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {/if} + +snippet ife "{if cond} ... {else} ... {/if}" + {if ${1}} + ${0:${VISUAL}} + {else} + ${2} + {/if} + +snippet eif "{elseif cond} ... {/if}" + {elseif ${1}} + ${0:${VISUAL}} + {/if} + +snippet el "{else} ... {/if}" + {else} + ${1} + {/if} + +# https://www.smarty.net/docs/en/language.function.for.tpl +snippet for "The {for} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {/for} + +snippet forelse "The {for}{forelse} tag is used to create simple loops." + {for $${1:var}=${2:start} to ${3:end}${4: step ${5}}${6: max=${7}}} + ${0:${VISUAL}} + {forelse} + ${8} + {/for} + +# https://www.smarty.net/docs/en/language.function.foreach.tpl +snippet foreach "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {/foreach} + +snippet foreach2 "[Smarty2] {foreach} is used for looping over arrays of data." + {foreach from=$${1:collection} item='${2}'${3: key='${4}'}${5: name='${6}'}} + ${0:${VISUAL}} + {/foreach} + +snippet foreachelse "{foreach} is used for looping over arrays of data." + {foreach $${1:array_variable} as $${2:var_or_key}${3: => $${4:itemvar}}} + ${0:${VISUAL}} + {foreachelse} + ${5} + {/foreach} + +snippet wh "{while} loops in Smarty have much the same flexibility as PHP while statements, with a few added features for the template engine. Every {while} must be paired with a matching {/while}. All PHP conditionals and functions are recognized, such as ||, or, &&, and, is_array(), etc." + {while ${1}} + ${0:${VISUAL}} + {/while} + + + +# https://www.smarty.net/docs/en/language.function.append.tpl +#snippet append implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.assign.tpl +#snippet assign implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.block.tpl +snippet block "{block} is used to define a named area of template source for template inheritance." + {block name='${1}'} + ${0:${VISUAL}} + {/block} + +# https://www.smarty.net/docs/en/language.function.call.tpl +snippet call "{call} is used to call a template function defined by the {function} tag just like a plugin function." + {call name=${1}${2: assign=${3}}${4: variables}} + +# https://www.smarty.net/docs/en/language.function.capture.tpl +snippet capture "{capture} is used to collect the output of the template between the tags into a variable instead of displaying it. Any content between {capture name='foo'} and {/capture} is collected into the variable specified in the name attribute. " + {capture name='${1}'${2: assign='${3}' }${4: append='${5:array_variable}'}} + ${0:${VISUAL}} + {/capture} + +# https://www.smarty.net/docs/en/language.function.config.load.tpl +#snippet config_load implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.extends.tpl +snippet extends "{extends} tags are used in child templates in template inheritance for extending parent templates." + {extends file='${1}'} + +# https://www.smarty.net/docs/en/language.function.function.tpl +snippet function "{function} is used to create functions within a template and call them just like a plugin function. Instead of writing a plugin that generates presentational content, keeping it in the template is often a more manageable choice. It also simplifies data traversal, such as deeply nested menus." + {function name='${1}' ${2:variables}} + ${0:${VISUAL}} + {/function} + +# https://www.smarty.net/docs/en/language.function.include.tpl +#snippet include implemented in UltiSnips format + +# https://www.smarty.net/docs/en/language.function.literal.tpl +snippet literal "{literal} tags allow a block of data to be taken literally. This is typically used around Javascript or stylesheet blocks where {curly braces} would interfere with the template delimiter syntax" + {literal} + ${0:${VISUAL}} + {/literal} + +# https://www.smarty.net/docs/en/language.function.nocache.tpl +snippet nocache "{nocache} is used to disable caching of a template section. Every {nocache} must be paired with a matching {/nocache}." + {nocache} + ${0:${VISUAL}} + {/nocache} + +# https://www.smarty.net/docs/en/language.function.section.tpl +snippet section "A {section} is for looping over sequentially indexed arrays of data, unlike {foreach} which is used to loop over a single associative array. Every {section} tag must be paired with a closing {/section} tag." + {section name='${1}'${2: loop='${3}'}${4: start=${5}}${6: step=${7}}${8: max=${9}}${10: show=${11}}} + ${0:${VISUAL}} + {/section} + +# https://www.smarty.net/docs/en/language.function.setfilter.tpl +snippet setfilter "The {setfilter}...{/setfilter} block tag allows the definition of template instance's variable filters." + {setfilter ${1:filters}} + ${0:${VISUAL}} + {/setfilter} + +# https://www.smarty.net/docs/en/language.function.strip.tpl +snippet strip "Anything within {strip}{/strip} tags are stripped of the extra spaces or carriage returns at the beginnings and ends of the lines before they are displayed. This way you can keep your templates readable, and not worry about extra white space causing problems." + {strip} + ${0:${VISUAL}} + {/strip} diff --git a/snippets/systemverilog.snippets b/snippets/systemverilog.snippets index f510750d6..828a6de9c 100644 --- a/snippets/systemverilog.snippets +++ b/snippets/systemverilog.snippets @@ -71,3 +71,594 @@ snippet pkg package ${1:package_name}; ${0} endpackage : $1 + +snippet uvm_object + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_object}; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + $0 + endclass: $1 + + +snippet uvm_object_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_object}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + $0 + endclass: $1 + + +snippet uvm_component + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_component}; + \`uvm_component_utils($1); + + // Group: Configuration Object(s) + + // Var: config_obj + ${3:config_obj_t} config_obj; + + + // Group: Components + + + // Group: Variables + + + // Group: Functions + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + $0 + endclass: $1 + + +snippet uvm_component_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_component}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_component_param_utils(this_type_t); + + // Group: Configuration Object(s) + + // Var: config_obj + ${4:config_obj_t} config_obj; + + + // Group: Components + + + // Group: Variables + + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + $0 + endclass: $1 + + +snippet uvm_component_extended + // Class: $1 + // + class ${1:my_class} extends ${2:base_class}; + \`uvm_component_utils($1); + + // Group: Configuration Object(s) + + + // Group: Components + + + // Group: Variables + + + // Group: Functions + + // Constructor: new + function new(string name = "$1", uvm_component parent); + super.new(name, parent); + endfunction: new + + /*--- UVM Build Phases ---*/ + /*------------------------------------*/ + // Function: build_phase + extern function void build_phase(uvm_phase phase); + // Function: connect_phase + extern function void connect_phase(uvm_phase phase); + // Function: end_of_elaboration_phase + extern function void end_of_elaboration_phase(uvm_phase phase); + + /*--- UVM Run Phases ---*/ + /*------------------------------------*/ + // Function: start_of_simulation_phase + extern function void start_of_simulation_phase(uvm_phase phase); + // Function: reset_phase + extern task reset_phase(uvm_phase phase); + // Function: configure_phase + extern task configure_phase(uvm_phase phase); + // Function: main_phase + extern task main_phase(uvm_phase phase); + // Function: shutdown_phase + extern task shutdown_phase(uvm_phase phase); + + /*--- UVM Cleanup Phases ---*/ + /*------------------------------------*/ + // Function: extract_phase + extern function void extract_phase(uvm_phase phase); + // Function: report_phase + extern function void report_phase(uvm_phase phase); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* UVM Build Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::build_phase(uvm_phase phase); + /* note: Do not call super.build_phase() from any class that is extended from an UVM base class! */ + /* For more information see UVM Cookbook v1800.2 p.503 */ + // super.build_phase(phase); + endfunction: build_phase + + + function void $1::connect_phase(uvm_phase phase); + super.connect_phase(phase); + endfunction: connect_phase + + + function void $1::end_of_elaboration_phase(uvm_phase phase); + super.end_of_elaboration_phase(phase); + endfunction: end_of_elaboration_phase + + + /*----------------------------------------------------------------------------*/ + /* UVM Run Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::start_of_simulation_phase(uvm_phase phase); + super.start_of_simulation_phase(phase); + endfunction: start_of_simulation_phase + + + task $1::reset_phase(uvm_phase phase); + endtask: reset_phase + + + task $1::configure_phase(uvm_phase phase); + endtask: configure_phase + + + task $1::main_phase(uvm_phase phase); + endtask: main_phase + + + task $1::shutdown_phase(uvm_phase phase); + endtask: shutdown_phase + + + /*----------------------------------------------------------------------------*/ + /* UVM Cleanup Phases */ + /*----------------------------------------------------------------------------*/ + function void $1::report_phase(uvm_phase phase); + super.report_phase(phase); + endfunction: report_phase + + + function void $1::extract_phase(uvm_phase phase); + super.extract_phase(phase); + endfunction: extract_phase + + + +snippet uvm_sequence + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_sequence}; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Task: pre_start + // This task is a user-definable callback that is called before the optional + // execution of . + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of ~only~ when the sequence is started with . + // If is called with ~call_pre_post~ set to 0, ~pre_body~ is not called. + // extern virtual task pre_body(); + + // Task: pre_do + // This task is a user-definable callback task that is called ~on the parent + // sequence~, if any. The sequence has issued a wait_for_grant() call and after + // the sequencer has selected this sequence, and before the item is randomized. + // + // Although pre_do is a task, consuming simulation cycles may result in unexpected + // behavior on the driver. + // extern virtual task pre_do(bit is_item); + + // Function: mid_do + // This function is a user-definable callback function that is called after the + // sequence item has been randomized, and just before the item is sent to the + // driver. + // extern virtual function void mid_do(uvm_sequence_item this_item); + + // Task: body + // This is the user-defined task where the main sequence code resides. + extern virtual task body(); + + // Function: post_do + // This function is a user-definable callback function that is called after the + // driver has indicated that it has completed the item, using either this + // item_done or put methods. + // extern virtual function void post_do(uvm_sequence_item this_item); + + // Task: post_body + // This task is a user-definable callback task that is called after the execution + // of ~only~ when the sequence is started with . + // If is called with ~call_pre_post~ set to 0, ~post_body~ is not called. + // extern virtual task post_body(); + + // Task: post_start + // This task is a user-definable callback that is called after the optional + // execution of . + // extern virtual task post_start(); + $0 + endclass: $1 + +snippet uvm_sequence_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_sequence}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Task: pre_start + // This task is a user-definable callback that is called before the optional + // execution of . + // extern virtual task pre_start(); + + // Task: pre_body + // This task is a user-definable callback that is called before the execution + // of ~only~ when the sequence is started with . + // If is called with ~call_pre_post~ set to 0, ~pre_body~ is not called. + // extern virtual task pre_body(); + + // Task: pre_do + // This task is a user-definable callback task that is called ~on the parent + // sequence~, if any. The sequence has issued a wait_for_grant() call and after + // the sequencer has selected this sequence, and before the item is randomized. + // + // Although pre_do is a task, consuming simulation cycles may result in unexpected + // behavior on the driver. + // extern virtual task pre_do(bit is_item); + + // Function: mid_do + // This function is a user-definable callback function that is called after the + // sequence item has been randomized, and just before the item is sent to the + // driver. + // extern virtual function void mid_do(uvm_sequence_item this_item); + + // Task: body + // This is the user-defined task where the main sequence code resides. + extern virtual task body(); + + // Function: post_do + // This function is a user-definable callback function that is called after the + // driver has indicated that it has completed the item, using either this + // item_done or put methods. + // extern virtual function void post_do(uvm_sequence_item this_item); + + // Task: post_body + // This task is a user-definable callback task that is called after the execution + // of ~only~ when the sequence is started with . + // If is called with ~call_pre_post~ set to 0, ~post_body~ is not called. + // extern virtual task post_body(); + + // Task: post_start + // This task is a user-definable callback that is called after the optional + // execution of . + // extern virtual task post_start(); + $0 + endclass: $1 + +snippet uvm_sequence_functions + // task ${1:my_class::}pre_start(); + // endtask: pre_start + + + // task $1pre_body(); + // endtask: pre_body + + + // task $1pre_do(bit is_item); + // endtask: pre_do + + + // function void $1mid_do(uvm_sequence_item this_item); + // endfunction: mid_do + + + task $1body(); + $0 + endtask: body + + + // function void $1post_do(uvm_sequence_item this_item); + // endfunction: post_do + + + // task $1post_body(); + // endtask: post_body + + + // task $1post_start(); + // endtask: post_start + + +snippet uvm_sequence_item + // Class: $1 + // + class ${1:my_class} extends ${2:uvm_sequence_item}; + typedef $1 this_type_t; + \`uvm_object_utils($1); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Function: do_copy + // extern function void do_copy(uvm_object rhs); + // Function: do_compare + // extern function bit do_compare(uvm_object rhs, uvm_comparer comparer); + // Function: convert2string + // extern function string convert2string(); + // Function: do_print + // extern function void do_print(uvm_printer printer); + // Function: do_record + // extern function void do_record(uvm_recorder recorder); + // Function: do_pack + // extern function void do_pack(); + // Function: do_unpack + // extern function void do_unpack(); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* Constraints */ + /*----------------------------------------------------------------------------*/ + + + + + /*----------------------------------------------------------------------------*/ + /* Functions */ + /*----------------------------------------------------------------------------*/ + + + +snippet uvm_sequence_item_with_parameters + // Class: $1 + // + class ${1:my_class} #(${2:parameters}) extends ${3:uvm_sequence_item}; + typedef $1 #(${2/(\b(parameter|type)\s+([A-Za-z_][A-Za-z0-9_$]*)(\s*=\s*([A-Za-z0-9_$]+))?)*\b/$3/g}) this_type_t; + \`uvm_object_param_utils(this_type_t); + + // Group: Variables + + + // Group: Constraints + + + // Group: Functions + + // Constructor: new + function new(string name = "$1"); + super.new(name); + endfunction: new + + // Function: do_copy + // extern function void do_copy(uvm_object rhs); + // Function: do_compare + // extern function bit do_compare(uvm_object rhs, uvm_comparer comparer); + // Function: convert2string + // extern function string convert2string(); + // Function: do_print + // extern function void do_print(uvm_printer printer); + // Function: do_record + // extern function void do_record(uvm_recorder recorder); + // Function: do_pack + // extern function void do_pack(); + // Function: do_unpack + // extern function void do_unpack(); + $0 + endclass: $1 + + + /*----------------------------------------------------------------------------*/ + /* Constraints */ + /*----------------------------------------------------------------------------*/ + + + + + /*----------------------------------------------------------------------------*/ + /* Functions */ + /*----------------------------------------------------------------------------*/ + + + +snippet uvm_sequence_item_do_copy + function void ${1:my_class}${2:::}do_copy(uvm_object rhs); + this_type_t rhs_; + + if (!\$cast(rhs_, rhs)) begin + \`uvm_error({this.get_name(), ".do_copy()"}, "Cast failed!"); + return; + end + // \`uvm_info({this.get_name(), ".do_copy()"}, "Cast succeded.", UVM_HIGH); + + /* chain the copy with parent classes */ + super.do_copy(rhs); + + /* list of local properties to be copied */ + // ; + endfunction: do_copy$0 + + + +snippet uvm_sequence_item_do_compare + function bit ${1:my_class}${2:::}do_compare(uvm_object rhs, uvm_comparer comparer); + this_type_t rhs_; + + if (!\$cast(rhs_, rhs)) begin + \`uvm_error({this.get_name(), ".do_compare()"}, "Cast failed!"); + return; + end + // \`uvm_info({this.get_name(), ".do_compare()"}, "Cast succeded.", UVM_HIGH); + + /* chain the compare with parent classes */ + do_compare = super.do_compare(rhs, comparer); + + /* list of local properties to be compared: */ + do_compare &= ( + // && + // + ); + endfunction: do_compare$0 + + + +snippet uvm_sequence_item_convert2string + function string ${1:my_class}${2:::}convert2string(); + string s; + + /* chain the convert2string with parent classes */ + s = super.convert2string(); + + /* list of local properties to be printed: */ + // guide 0---4---8--12--16--20--24--28--32--36--40--44--48-- + // s = {s, \$sformatf("property_label : 0x%0h\n", property_name)}; + // s = {s, \$sformatf("property_label : %0d\n", property_name)}; + + return s; + endfunction: convert2string$0 + + + +snippet uvm_sequence_item_do_print + function void ${1:my_class}${2:::}do_print(uvm_printer printer) + /* chain the print with parent classes */ + super.do_print(printer); + + /* list of local properties to be printed: */ + // printer.print_string("property_label", property_name); + // printer.print_field_int("property_label", property_name, \$bits(property_name), UVM_HEX); + endfunction: do_print$0 + +snippet uvm_sequence_item_do_record + function void ${1:my_class}${2:::}do_record(uvm_recorder recorder); + /* chain the record with parent classes */ + super.do_record(recorder); + + /* list of local properties to be recorded: */ + /* note: use uvm_record_int, uvm_record_string, uvm_record_time, uvm_record_real for known basic types. */ + // \`uvm_record_string("property_label", property_name); + // \`uvm_record_int("property_label", property_name, \$bits(property_name), UVM_HEX); + endfunction: do_record$0 + +snippet uvm_sequence_item_do_pack + function void ${1:my_class}${2:::}do_pack(uvm_packer packer); + /* chain the pack with parent classes */ + super.do_pack(packer); + + /* list of local properties to be packed: */ + // note: look up the appropriate macro(s) for your properties! + // \`uvm_pack_int(property_name); + // \`uvm_pack_queue(property_name); + // \`uvm_pack_string(property_name); + endfunction: do_pack$0 + +snippet uvm_sequence_item_do_unpack + function void ${1:my_class}${2:::}do_unpack(uvm_packer packer); + /* chain the unpack with parent classes */ + super.do_unpack(packer); + + /* list of local properties to be unpacked: */ + // note: look up the appropriate macro(s) for your properties! + // \`uvm_unpack_int(property_name); + // \`uvm_unpack_queue(property_name); + // \`uvm_unpack_string(property_name); + endfunction: do_unpack$0 + diff --git a/snippets/tex.snippets b/snippets/tex.snippets index 25f8f37f7..4d54fe011 100644 --- a/snippets/tex.snippets +++ b/snippets/tex.snippets @@ -195,11 +195,21 @@ snippet par \paragraph \\paragraph{${1:paragraph name}}% \\label{par:${2:$1}} ${0} +# Paragraph* +snippet par* \paragraph* + \\paragraph*{${1:paragraph name}}% + \\label{par:${2:$1}} + ${0} # Sub Paragraph snippet subp \subparagraph \\subparagraph{${1:subparagraph name}}% \\label{subp:${2:$1}} ${0} +# Sub Paragraph* +snippet subp* \subparagraph* + \\subparagraph*{${1:subparagraph name}}% + \\label{subp:${2:$1}} + ${0} snippet ni \noindent \\noindent ${0} @@ -390,63 +400,48 @@ snippet hrefc # enquote from package csquotes snippet enq enquote \\enquote{${1:${VISUAL:text}}} ${0} - # Time derivative snippet ddt time derivative \\frac{d}{dt} {$1} {$0} - # Limit snippet lim limit \\lim_{{$1}} {{$2}} {$0} - # Partial derivative snippet pdv partial derivation \\frac{\\partial {$1}}{\\partial {$2}} {$0} - # Second order partial derivative snippet ppdv second partial derivation \\frac{\\partial^2 {$1}}{\\partial {$2} \\partial {$3}} {$0} - # Ordinary derivative snippet dv derivative \\frac{d {$1}}{d {$2}} {$0} - # Summation snippet summ summation \\sum_{{$1}} {$0} - # Shorthand for time derivative snippet dot dot \\dot{{$1}} {$0} - # Shorthand for second order time derivative snippet ddot ddot \\ddot{{$1}} {$0} - # Vector snippet vec vector \\vec{{$1}} {$0} - # Bar snippet bar bar \\bar{{$1}} {$0} - # Cross product snippet \x cross product \\times {$0} - # Dot product snippet . dot product \\cdot {$0} - # Integral snippet int integral \\int_{{$1}}^{{$2}} {$3} \\: d{$4} {$0} - # Right arrow snippet ra rightarrow \\rightarrow {$0} - # Long right arrow snippet lra longrightarrow \\longrightarrow {$0} diff --git a/snippets/yii.snippets b/snippets/yii.snippets index 1f9fc6f78..1aecad293 100644 --- a/snippets/yii.snippets +++ b/snippets/yii.snippets @@ -144,7 +144,7 @@ snippet yrp #----------------Yii Model----------------------------- #Yii Model count snippet ycountm - ${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->count($2, array('${3:key}'=>${0:value})); #Yii Model countBySql snippet ycountbs @@ -152,35 +152,35 @@ snippet ycountbs #Yii Model updateAll snippet yupdatea - ${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->updateAll(${2:array('attributes')}, $3,array('${4:key}'=>${0:value})); #Yii Model updateByPk snippet yupdatebp - ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, $4,array('${5:key}'=>${0:value})); #Yii Model deleteAll snippet ydela - ${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->deleteAll($2,array('${3:key}'=>${0:value})); #Yii Model deleteByPk snippet ydelbp - ${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->deleteByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model find snippet yfind - ${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->find($2,array('${3:key}'=>${0:value})); #Yii Model findAll snippet yfinda - ${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->findAll($2,array('${3:key}'=>${0:value})); #Yii Model findByPk snippet yfindbp - ${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findByPk(${2:pk}, $3, array('${4:key}'=>${0:value})); #Yii Model findAllByPk snippet yfindabp - ${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByPk(${2:pk}, $3,array('${4:key}'=>${0:value})); #Yii Model findBySql snippet yfindbs @@ -188,11 +188,11 @@ snippet yfindbs #Yii Model findAllByAttributes snippet yfindaba - ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${0:value})); + ${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), $4, array('${5:key}'=>${0:value})); #Yii Model exists snippet yexists - ${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${0:value})); + ${1:ModelName}::model()->exists($2, array('${3:key}'=>${0:value})); #Yii Create model class snippet ymodel diff --git a/snippets/zsh.snippets b/snippets/zsh.snippets index 63061fe8e..485766fea 100644 --- a/snippets/zsh.snippets +++ b/snippets/zsh.snippets @@ -5,17 +5,17 @@ snippet #! #!/usr/bin/env zsh snippet if - if ${1:condition}; then + if $1; then ${0:${VISUAL}} fi snippet ife - if ${1:condition}; then + if $1; then ${2:${VISUAL}} else ${0:# statements} fi snippet eif - elif ${1:condition}; then + elif $1; then ${0:${VISUAL}} snippet for for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do @@ -30,11 +30,11 @@ snippet fore ${0:${VISUAL}} done snippet wh - while ${1:condition}; do + while $1; do ${0:${VISUAL}} done snippet until - until ${1:condition}; do + until $1; do ${0:${VISUAL}} done snippet repeat