コード例 #1
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import setpypath

from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

bsnip("pre", "pre", r"""
<pre>
$0
</pre>
""")

wsnip("code", "code", r"""
<code>$1</code>$0
""")
コード例 #2
0
        prevPath = path
        path = os.path.dirname(path)

addSnipUtilDir()


from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

$0
""", flags="!")


bsnip("screrr", "ScriptError", r"""
class ScriptError(Exception):
    pass

$0
""", aliases=['se'])

wsnip("xrange", "xrange", r"""
xrange($1)$0
""", aliases = ['xr'])

bsnip("rre", "raise RuntimeError()", r"""
raise RuntimeError($1)$0
""")
コード例 #3
0
bsnip("ghcode", "github code block", r"""
\`\`\`${1:python}
$0
\`\`\`
""")

bsnip("cimg", "centered image", r"""
<center>
 <img src="${1:/path/to/img.png}" alt="${2:description}" />
</center>
$0
""")

wsnip("lit", "literal (code) markup", r"""
\`${1:literal}\`$0
""", aliases=['f', 'cmd'])

wsnip("link", "link markup", r"""
[${1:text}](${2:link})$0
""")

wsnip("ln", "link markup with id", r"""
[${1:text}][${2:id}]$0
""")

bsnip("le", "link entry", r"""
[${1:id}]: ${0:url}
""")

wsnip("fn", "footnote", r"""
コード例 #4
0
ファイル: rst.snippets.py プロジェクト: randyransier/vimfiles
bsnip("warn", "Warning Admonition", r"""
.. warning::

  $0
""")

bsnip("note", "Note Admonition", r"""
.. note::

  $0
""")

# Markup.

wsnip("f", "File markup", r"""
:file:\`${1:`!p betterVisual(snip, default='filename')`}\`$0
""")

wsnip("r", "Ref markup", r"""
:ref:\`${1:`!p betterVisual(snip, default='label')`}\`$0
""")

wsnip("cmd", "Command markup", r"""
:command:\`${1:`!p betterVisual(snip, default='command')`}\`$0
""")

wsnip("lit", "literal (code) markup", r"""
\`\`${1:`!p betterVisual(snip)`}\`\`$0
""")

wsnip("m", "inline math", r"""
コード例 #5
0
ファイル: make.snippets.py プロジェクト: drmikehenry/vimfiles
import re
import setpypath

from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

put(r"""
priority -5
""")

wsnip(
    "ca",
    "$(call ",
    """
$(call $0
""",
    aliases=["call"],
)

wsnip(
    "cs",
    "$(call S.",
    """
$(call S.$0
""",
    aliases=[],
)

wsnip(
    "v",
コード例 #6
0
""")

bsnip("python",
      "python code block",
      r"""
\`\`\`python
$0
\`\`\`
""",
      aliases=['py'])

bsnip("ruby", "ruby code block", r"""
\`\`\`ruby
$0
\`\`\`
""")

bsnip("rust", "rust code block", r"""
\`\`\`rust
$0
\`\`\`
""")

bsnip("text", "text code block", r"""
\`\`\`
$0
\`\`\`
""")

wsnip("date", "today's date", r"""`!v strftime("%Y-%m-%d")`""")
コード例 #7
0
bsnip(
    "cimg",
    "centered image",
    r"""
<center>
 <img src="${1:/path/to/img.png}" alt="${2:description}" />
</center>
$0
""",
)

wsnip(
    "lit",
    "literal (code) markup",
    r"""
\`${1:`!p betterVisual(snip)`}\`$0
""",
    aliases=["f", "cmd"],
)

wsnip(
    "link",
    "link markup",
    r"""
[${1:text}](${2:link})$0
""",
)

wsnip(
    "ln",
    "link markup with id",
コード例 #8
0
snippet err "printf('...', ...);" w
System.err.printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet

""")

# 'if' snippets.
bsnip("if", "if (...) {...}", r"""
if ($1) {
    `!p betterVisual(snip)`$0
}
""")

wsnip("else", "else {...}", r"""
else {
    `!p betterVisual(snip)`$0
}
""", aliases=["el"])

wsnip("elif", "else if (...) {...}", r"""
else if ($1) {
    `!p betterVisual(snip)`$0
}
""", aliases = ["ei"])

bsnip("for", "for (i = 0; i < N; i++) {...}", (
r"""for (${1:i}""" +
r"""${1/(.*;.*)|(.*=.*)|(.+)|.*/(?1::(?2:;:(?3: = 0;:;)))/} """ +
r"""${1/\s*[=;].*//}""" +
r"""${2/(.*;.*)|(^[<>!=].*)|.*/(?1::(?2: : < ))/}""" +
r"""${2:N}""" +
コード例 #9
0
ファイル: rst.snippets.py プロジェクト: dbernard/vimfiles
Not Ready to Act On
-------------------


Not Fully Determined
^^^^^^^^^^^^^^^^^^^^


Other Issues
------------
""")

bsnip("sh", "sh code block", r"""
.. code-block:: sh

    $0
""", flags="!")

bsnip("text", "text code block", r"""
.. code-block:: text

    $0
""", flags="!")

# Markup

wsnip("lit", "literal (code) markup", r"""
\`\`${1:literal}\`\`$0
""")
コード例 #10
0
ファイル: rst.snippets.py プロジェクト: dbernard/vimfiles
$0
""")

# Admonitions.

bsnip("warn", "Warning Admonition", r"""
.. warning::

    $0
""")

bsnip("note", "Note Admonition", r"""
.. note::

    $0
""")

# Markup.

wsnip("f", "File markup", r"""
:file:\`${1:path}\`$0
""")

wsnip("r", "Ref markup", r"""
:ref:\`${1:label}\`$0
""")

wsnip("cmd", "Command markup", r"""
:command:\`${1:command}\`$0
""")
コード例 #11
0
from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

put(
    r"""
priority -5
"""
)

wsnip(
    "ca",
    "$(call ",
    """
$(call $0
""",
    aliases=["call"],
)

wsnip(
    "cs",
    "$(call S.",
    """
$(call S.$0
""",
    aliases=[],
)

wsnip(
    "v",
コード例 #12
0
#!/usr/bin/env python
# vim:set fileencoding=utf8: #

from sniputil import wsnip

####################
# Django Templates #
####################
wsnip('{{', 'Django template var', r'''
{{ ${1:variable} }}
''')

wsnip('{%', 'Django logic tag', r'''
{% ${1:expression} %}
''')

wsnip('{{|', 'Django filter', r'''
{{ ${1:variable}|${2:filter} }}
''')
コード例 #13
0
endforeach()""", aliases=["fore"])

bsnip("while", "while", r"""
while(${1:expr})
    $0
endwhile()""")

bsnip("mss", "message(STATUS ...)", r"message(STATUS $0)", aliases=["info"])
bsnip("msf", "message(FATAL_ERROR ...)", r"message(FATAL_ERROR $0)")
bsnip("set", "set(...)", r"set($0)")

bsnip("gfc", "get_filename_component(...)", r"""
get_filename_component(${1:VAR} ${2:FROM} ${0:PATH|ABSOLUTE|NAME|EXT|NAME_WE|REALPATH})
""")

wsnip("var", "${...}", r"${$0}")

bsnip("inc", "include()", r"include($1)")

bsnip("if", "if(...)", r"""
if($1)
    $0
endif()""")

bsnip("func", "function(...)", r"""
function(${1:name and args})
$0
endfunction()""")

bsnip("dump-variables", "dump all variables", r"""
get_cmake_property(_variableNames VARIABLES)
コード例 #14
0
import setpypath

from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

bsnip("pre", "pre", r"""
<pre>
$0
</pre>
""")

wsnip("code", "code", r"""
<code>$1</code>$0
""")

wsnip("dd", "dd", "<dd>$0</dd>")

bsnip("template_html", "skeleton html doc", r"""
<!DOCTYPE html>
<html>
	<head lang="en">
		<meta charset="UTF-8">
		<title>${1:Title}</title>
	</head>
	<body>
		$0
	</body>
</html>
コード例 #15
0
ファイル: python.snippets.py プロジェクト: hhymarco/vimfiles
bsnip("ifmain", "if __name__ == '__main__':...", r"""
if __name__ == '__main__':
    ${1:main()}
""")

## @todo Include arguments in docstring.
bsnip("def", "def func(...):...", r'''
def ${1:funcName}($2):
    """${3:Description of function $1.}"""
    ${4:pass}
''', aliases=["func"])

# @todo Consider other __xxx__ words for popup menu, or perhaps
# just one with "__$1{init}__".
wsnip("__", "__init__", "__${1:init}__")

# try/except/finally

bsnip("try", "try/except", r"""
try:
    ${1:pass}
except ${2:Exception}, e:
    ${3:raise e}
""", aliases=["trye"])

bsnip("tryf", "try/finally", r"""
try:
    ${1:pass}
finally:
    ${2:pass}
コード例 #16
0
ファイル: make.snippets.py プロジェクト: hhymarco/vimfiles
import sys
import re
import setpypath

from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

put(r"""
priority -5
""")

wsnip("call", "$(call )","""
$(call $0)
""", aliases=["c"])

wsnip("v", "$()","""
$($0)
""", aliases=[])

bsnip("def", "define funcName...endef $(call S.def,funcName)","""
define $1
  $0
endef
$(call S.def,$1)
""", aliases=[])

put(r"""
global !p
コード例 #17
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

from sniputil import bsnip
from sniputil import wsnip

###########
# General #
###########

wsnip('lc', 'List comprehension', r'''
[${1:x} for ${2:x} in ${3:iter}]
''')

bsnip('def', 'Define function', r'''
def ${1:func_name}(${2:args}):
    ${3:pass}
''')

bsnip(
    'class', 'Define a class', r'''
class ${1:MyClass}(${2:inherits}):
    def __init__(self, ${3:args}):
        ${4:pass}
''')

##########
# Django #
##########
bsnip('setUpTestData',
      'Django testing setUpTestData',
コード例 #18
0
#                 (some.package [subpkg1 :as p1]
#                               [subpkg2 :as p2])})}${4:
#   (:use ${5:[some.package :only [foo bar]]
#             foo.bar})})

# $0
# """)

bsnip("c", "comment", r"""
(comment
  $0
  )
""")

wsnip("condp", "condp", r"""
(condp ${1:pred} ${2:expr}
  $0)
""")

bsnip("defm", "defmethod", r"""
(defmethod ${1:name} ${2:match}
  [${3:args}]
  $0)
""")

bsnip("defmm", "defmulti", r"""
(defmulti ${1:name} ${2:dispatch-fn})
$0
""")

bsnip("defn", "defn", r"""
(defn ${1:name} ${2:
コード例 #19
0
    "cimg",
    "centered image",
    r"""
.. image:: ${1:path.*}
    :align: center

$0
""",
)

# Markup

wsnip(
    "lit",
    "literal (code) markup",
    r"""
\`\`${1:literal}\`\`$0
""",
)

wsnip(
    "m",
    "inline math",
    r"""
:math:\`$1\`$0
""",
)

wsnip(
    "sup",
    "superscript",
コード例 #20
0
$0
""")

# Admonitions.

bsnip("warn", "Warning Admonition", r"""
.. warning::

    $0
""")

bsnip("note", "Note Admonition", r"""
.. note::

    $0
""")

# Markup.

wsnip("f", "File markup", r"""
:file:\`${1:path}\`$0
""")

wsnip("r", "Ref markup", r"""
:ref:\`${1:label}\`$0
""")

wsnip("cmd", "Command markup", r"""
:command:\`${1:command}\`$0
""")
コード例 #21
0
.. image:: ${1:path.*}

$0
""")

bsnip("cimg", "centered image", r"""
.. image:: ${1:path.*}
    :align: center

$0
""")

# Markup

wsnip("lit", "literal (code) markup", r"""
\`\`${1:`!p betterVisual(snip)`}\`\`$0
""")

wsnip("m", "inline math", r"""
:math:\`$1\`$0
""")

wsnip("sup", "superscript", r"""
:sup:\`$1\`$0
""")

wsnip("link", "link markup", r"""
\`${1:text} <${2:`!p betterVisual(snip)`}>\`_$0
""")

wsnip("title", "title reference", r"""
コード例 #22
0
bsnip(
    "pfn", "pub fn name(?) -> ? {}", r"""
pub fn ${1:function_name}($2)${3/..*/ -> /}${3:Result<${4:()}, Box<dyn std::error::Error>>} {
    `!p betterVisual(snip)`$0
}
""")

bsnip("new", "pub fn new(?) -> Self {}", r"""
pub fn new($1) -> Self {
    Self { $0 }
}
""")

wsnip(
    "pr", "println!(...)", r"""
println!("$1"${1/[^{]*({)?.*/(?1:, :\);)/}$2${1/[^{]*({)?.*/(?1:\);:)/}
""")

wsnip(
    "pri", "print!(...)", r"""
print!("$1"${1/[^{]*({)?.*/(?1:, :\);)/}$2${1/[^{]*({)?.*/(?1:\);:)/}
""")

wsnip(
    "fmt", "format!(...)", r"""
format!("$1"${1/[^{]*({)?.*/(?1:, :\);)/}$2${1/[^{]*({)?.*/(?1:\);:)/}
""")

# 'if' snippets.
wsnip("if", "if (...) {...}", r"""
if ($1) {
コード例 #23
0

Not Fully Determined
^^^^^^^^^^^^^^^^^^^^


Other Issues
------------
""")

bsnip("sh", "sh code block", r"""
.. code-block:: sh

    $0
""", flags="!")

bsnip("text",
      "text code block",
      r"""
.. code-block:: text

    $0
""",
      flags="!")

# Markup

wsnip("lit", "literal (code) markup", r"""
\`\`${1:literal}\`\`$0
""")
コード例 #24
0
bsnip("ifmain", "if __name__ == '__main__':...", r"""
if __name__ == '__main__':
    ${1:main()}
""")

## @todo Include arguments in docstring.
bsnip("def", "def func(...):...", r'''
def ${1:funcName}($2):
    """${3:Description of function $1}`!p snip.rv = autoPeriod(t[3])`"""
    ${4:pass}
''', aliases=["func"])

# @todo Consider other __xxx__ words for popup menu, or perhaps
# just one with "__$1{init}__".
wsnip("__", "__init__", "__${1:init}__")

# try/except/finally

bsnip("try", "try/except", r"""
try:
    ${1:pass}
except ${2:Exception}, e:
    ${3:raise e}
""", aliases=["trye"])

bsnip("tryf", "try/finally", r"""
try:
    ${1:pass}
finally:
    ${2:pass}
コード例 #25
0
ファイル: c.snippets.py プロジェクト: dtshepherd/vimfiles
""")

def printf_fmt_varargs(fmt_tabstop_num):
    t1 = str(fmt_tabstop_num)
    t2 = str(fmt_tabstop_num + 1)
    # Capture group 2 will be non-empty if format string contains any
    # format specifiers (``%d``, ``%s``, ...) that require varargs:
    if_varargs_cap2 = r"([^%]|%%)*(%.)?.*"

    fmt = r'"${' + t1 + r':%s}\n"'
    after_fmt = r"${" + t1 + r"/" + if_varargs_cap2 + r"/(?2:, :\);)/}$" + t2
    rest = r"${" + t1 + r"/" + if_varargs_cap2 + r"/(?2:\);)/}"
    return fmt + after_fmt + rest

wsnip("printf", """printf('...', ...);""",
    r"printf(" + printf_fmt_varargs(1),
    aliases=["pr"])

wsnip("dprintf", """dprintf(fd, '...', ...);""",
    r"dprintf(${1:fd}, " + printf_fmt_varargs(2),
    aliases=["dpr"])

wsnip("fprintf", """fprintf(FILE, '...', ...);""",
    r"fprintf(${1:stderr}, " + printf_fmt_varargs(2),
    aliases=["fpr"])

wsnip("sprintf", """sprintf(buf, '...', ...);""",
    r"sprintf(${1:buf}, " + printf_fmt_varargs(2),
    aliases=["spr"])

wsnip("snprintf", """snprintf(buf, sizeof(buf), '...', ...);""",
コード例 #26
0
import setpypath

from sniputil import put

from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr

bsnip("foreach", "for (var i in VAR)", r"""
for (var ${1:i} in ${2:VAR}) {
    $0
}""")

bsnip("func", "function func()", r"""
function ${1:name}($2) {
    $0
}""")

wsnip("anon", "anonymous fn", r"""
function(${1:args}) {
    $0
}""", aliases=["fn"])

bsnip("var", "var VAR = EXPR", r"""
var ${1:name} = $0
""")

wsnip("emfn", "empty function", r"""
function(${1:args}) {};
""")
コード例 #27
0
$0
""")

# Admonitions.

bsnip("warn", "Warning Admonition", r"""
.. warning::

    $0
""")

bsnip("note", "Note Admonition", r"""
.. note::

    $0
""")

# Markup.

wsnip("f", "File markup", r"""
:file:\`${1:`!p betterVisual(snip)`}\`$0
""")

wsnip("r", "Ref markup", r"""
:ref:\`${1:label}\`$0
""")

wsnip("cmd", "Command markup", r"""
:command:\`${1:`!p betterVisual(snip)`}\`$0
""")