Exemple #1
1
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


# Section heading
bsnip("sect", "section heading (===)", r"""
" =============================================================
" ${1:Section Heading}
" =============================================================

$0
""")

# Subsection heading
bsnip("subsec", "subsection heading (---)", r"""
" -------------------------------------------------------------
" ${1:Subsection Heading}
" -------------------------------------------------------------

$0
""")
Exemple #2
0
# vim:set fileencoding=utf8:

import os
import sys
import re
import setpypath

from sniputil import put

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

bsnip("docstring", "docstring for func or type", r"""
/**
 *  ${1:Brief description.}
 *
 *  ${0:Full description.}
 */
""", flags="b!", aliases=["doc", "/**"])

# Javadoc.
wabbr("@param",     "@param ${1:inParam}  ${0:@todo Description of $1.}",
        aliases=["@p", "@pi", "@po", "@pio"])
wabbr("@return",    "@return ", aliases=["@re", "@ret", "@retval", "@rv"])
wabbr("todo",  "/** @todo ${1:Description of what's TO DO.} */")
wabbr("bug",   "/** @bug ${1:Description of BUG.} */")

put(r"""
snippet printf "printf('...', ...);" w!
System.out.printf("${1:%s}\n"${1/([^%]|%%)*(%.)?.*/(?2:, :\);)/}$2${1/([^%]|%%)*(%.)?.*/(?2:\);)/}
endsnippet
Exemple #3
0
put(r"""
priority -5

global !p
from sniputil import betterVisual
endglobal
""")

put(r"""
extends c
""")

bsnip(
    "str",
    r"""std::string""",
    r"""
std::string $0
""",
)

bsnip(
    "vec",
    r"""std::vector<xxx> """,
    r"""
std::vector<$1> $0
""",
)

bsnip(
    "cout",
    r"""std::cout << XXX << std::endl;""",
#!/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


# Section heading
bsnip("sect", "section heading (===)", r"""
" =============================================================
" ${1:Section Heading}
" =============================================================

$0
""")

# Subsection heading
bsnip("subsec", "subsection heading (---)", r"""
" -------------------------------------------------------------
" ${1:Subsection Heading}
" -------------------------------------------------------------

$0
""")

bsnip("func", "function()", r"""
function! ${1:name}($2)
    snip(trigger, desc, body, flags, aliases=aliases, trimBody=trimBody)


tsnip("part", "Part title", "#", aliases=['h9'], withOverline=True)
tsnip("chap", "Chapter title", "*", aliases=['h0'], withOverline=True)
tsnip("sect", "Section", "=", aliases=["h1"])
tsnip("subsec", "Subsection", "-", aliases=["h2"])
tsnip("subsubsec", "Sub-subsection", "^", aliases=["h3"])
tsnip("para", "Paragraph", '"', aliases=["h4"])

# Directives.

bsnip("centered", "centered:: ...", r"""
.. centered:: ${1:line of text}

$0
""")

bsnip("code", "code block", r"""
.. code-block:: ${1:python}

  $0
""")

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

  $0
""")
Exemple #6
0
from sniputil import abbr, babbr, wabbr


put(r"""
priority -5

global !p
from sniputil import betterVisual
from sniputil import autoPeriod
endglobal
""")

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

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

bsnip("elif", "else if (...) {...}", r"""
else if ($1)
{
    `!p betterVisual(snip)`$0
}
from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr
from sniputil import put

put(r"""
priority -5

global !p
from sniputil import betterVisual
endglobal
""")

bsnip("code", "code block", r"""
\`\`\`${1:python}
$0
\`\`\`
""")

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

bsnip("python",
      "python code block",
      r"""
\`\`\`python
$0
\`\`\`
Exemple #8
0

# bsnip("ns", "(ns ...)", r"""
# (ns ${1:package.name}
#   ${2:(:require ${3:[some.package :as pkg]
#                 (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"""
Exemple #9
0
sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


#-------------------------------------------------------
# Basic Fail and Ignore
#-------------------------------------------------------

bsnip("utfm", "TEST_FAIL_MESSAGE(message)", r"""
TEST_FAIL_MESSAGE(${1:message});
""")

bsnip("utf", "TEST_FAIL()", r"""
TEST_FAIL(${1:});
""")

bsnip("utim", "TEST_IGNORE_MESSAGE(message)", r"""
TEST_IGNORE_MESSAGE(${1:message});
""")

bsnip("uti", "TEST_IGNORE()", r"""
TEST_IGNORE(${1:});
""")

bsnip("uto", "TEST_ONLY()", r"""
Exemple #10
0
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


# Snippets are now cleared in "clearsnippets" directory.
#put("clearsnippets\n")

# 'if' snippets.
bsnip("ns", "(ns ...)", r"""
(ns ${1:package.name}
  ${2:(:require ${3:[some.package :as pkg]
                (some.package [subpkg1 :as p1]
                              [subpkg2 :as p2])})}${4:
  (:use ${5:[some.package :only [foo bar]]
            foo.bar})})

$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("foreach", "foreach", r"""
foreach(${1:SRC} ${${2:SRCS}})
    $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)")
Exemple #12
0
sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


bsnip("defn", "public func decl", r"""
/**
    ${2:brief description}

    full description.
*/
${4:void}
${1:func_name}(${5:void});$0
""", flags="b!", aliases=["def"])

bsnip("func", "type func(...) {...}", r"""
${3:void}
${1:func_name}(${4:void})
{
    $0
}
""", flags="b!")

bsnip("switch", "switch (...) { ... }", r"""
switch (${1:var})
Exemple #13
0
from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr


put(r"""
priority -5

global !p
from sniputil import betterVisual
endglobal
""")

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

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

bsnip("elif", "else if (...) {...}", r"""
else if ($1)
{
    `!p betterVisual(snip)`$0
}
Exemple #14
0
sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
                 'UltiSnips'))

from sniputil import put

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

bsnip("defn",
      "public func decl",
      r"""
/**
    ${2:brief description}

    full description.
*/
${4:void}
${1:func_name}(${5:void});$0
""",
      flags="b!",
      aliases=["def"])

bsnip("func",
      "type func(...) {...}",
      r"""
${3:void}
${1:func_name}(${4:void})
{
    $0
}
Exemple #15
0
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


# Templates

bsnip("template_python.snippets.py", "new snippet template", r"""
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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

$0
""", flags="!")
Exemple #16
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


bsnip("com", "/* comment */", r"""
/* $1 */
""", flags="b!")
from sniputil import put

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

put(r"""
global !p
from sniputil import betterVisual
endglobal
""")

bsnip("docstring", "docstring for func or type", r"""
/**
 *  ${1:Brief description.}
 *
 *  ${0:Full description.}
 */
""", flags="b", aliases=["doc", "/**"])

# Javadoc.
wabbr("@param",     "@param ${1:inParam}  ${0:@todo Description of $1.}",
        aliases=["@p", "@pi", "@po", "@pio"])
wabbr("@return",    "@return ", aliases=["@re", "@ret", "@retval", "@rv"])
wabbr("todo",  "/** @todo ${1:Description of what's TO DO.} */")
wabbr("bug",   "/** @bug ${1:Description of BUG.} */")

bsnip("pl", "System.out.println()", r"""
System.out.println($1);
""", flags="b")
wsnip(
    "fo",
    "$(filter-out ",
    """
$(filter-out $0
""",
    aliases=[],
)


bsnip(
    "def",
    "define ...endef",
    """
define $0
endef
""",
    aliases=[],
)

put(
    r"""
global !p
def makeParamComments(nameAndArgs):
    numArgs = len(nameAndArgs.split(",")) - 1

    s = ""
    for i in range(numArgs):
        s += "\n#   $%d - " % (i + 1)
Exemple #19
0
)

wsnip(
    "fo",
    "$(filter-out ",
    """
$(filter-out $0
""",
    aliases=[],
)

bsnip(
    "def",
    "define ...endef",
    """
define $0
endef
""",
    aliases=[],
)

put(r"""
global !p
def makeParamComments(nameAndArgs):
    numArgs = len(nameAndArgs.split(",")) - 1

    s = ""
    for i in range(numArgs):
        s += "\n#   $%d - " % (i + 1)

    return s
Exemple #20
0
import sys
import re

sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', '..', 'UltiSnips'))

from sniputil import put

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

# Section heading
bsnip(
    "sect", "section heading (===)", r"""
" =============================================================
" ${1:Section Heading}
" =============================================================

$0
""")

# Subsection heading
bsnip(
    "subsec", "subsection heading (---)", r"""
" -------------------------------------------------------------
" ${1:Subsection Heading}
" -------------------------------------------------------------

$0
""")
Exemple #21
0
            sys.path.insert(0, os.path.dirname(snipUtilPath))
            break

        prevPath = path
        path = os.path.dirname(path)

addSnipUtilDir()


from sniputil import put

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

bsnip("chap", "Chapter/Title", r"""
# $0
""")

bsnip("sect", "Section", r"""
## $0
""", aliases=["h1"])

bsnip("subsec", "Subsection", r"""
### $0
""", aliases=["h2"])

bsnip("subsubsec", "Sub-subsection", r"""
#### $0
""", aliases=["h3"])

bsnip("para", "Paragraph", r"""
Exemple #22
0
# Status template
bsnip("status", "status template", r"""
`!v strftime("%d %b")` - `!v strftime("%d %b", localtime()+604800)`
===============


Accomplishments
---------------

* $0


Pending
^^^^^^^


Future
------


Issues
------

* None.


Time Off
--------

* None.
""")
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re
import setpypath

from sniputil import put

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

put("extends markdown\n")

bsnip("ab", "Acked-by: ...", r"""
Acked-by: John Szakmeister <*****@*****.**>
""")

bsnip("sob", "Signed-off-by: ...", r"""
Signed-off-by: John Szakmeister <*****@*****.**>
""")

bsnip("rb", "Reviewed-by: ...", r"""
Reviewed-by: John Szakmeister <*****@*****.**>
""")
Exemple #24
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', '..', 'UltiSnips'))

from sniputil import put

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

# Snippets are now cleared in "clearsnippets" directory.
#put("clearsnippets\n")

# 'if' snippets.
bsnip(
    "ns", "(ns ...)", r"""
(ns ${1:package.name}
  ${2:(:require ${3:[some.package :as pkg]
                (some.package [subpkg1 :as p1]
                              [subpkg2 :as p2])})}${4:
  (:use ${5:[some.package :only [foo bar]]
            foo.bar})})

$0
""")
Exemple #25
0
sys.path.append(
    os.path.join(os.path.dirname(__file__), '..', '..', '..', '..',
                 'UltiSnips'))

from sniputil import put

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

#-------------------------------------------------------
# Basic Fail and Ignore
#-------------------------------------------------------

bsnip("utfm", "TEST_FAIL_MESSAGE(message)", r"""
TEST_FAIL_MESSAGE(${1:message});
""")

bsnip("utf", "TEST_FAIL()", r"""
TEST_FAIL(${1:});
""")

bsnip("utim", "TEST_IGNORE_MESSAGE(message)", r"""
TEST_IGNORE_MESSAGE(${1:message});
""")

bsnip("uti", "TEST_IGNORE()", r"""
TEST_IGNORE(${1:});
""")

bsnip("uto", "TEST_ONLY()", r"""
Exemple #26
0
    snip(trigger, desc, body, flags, aliases=aliases, trimBody=trimBody)


tsnip("part",       "Part title",        "#", withOverline=True)
tsnip("chap",       "Chapter title",     "*", withOverline=True)
tsnip("sect",       "Section",           "=", aliases=["h1"])
tsnip("subsec",     "Subsection",        "-", aliases=["h2"])
tsnip("subsubsec",  "Sub-subsection",    "^", aliases=["h3"])
tsnip("para",       "Paragraph",         '"', aliases=["h4"])


# Directives.

bsnip("centered", "centered:: ...", r"""
.. centered:: ${1:line of text}

$0
""")

bsnip("code", "code block", r"""
.. code-block:: ${1:python}

    $0
""")

bsnip("l", "reference label", r"""
.. _${1:label}:
$0
""")

# Admonitions.
Exemple #27
0
bsnip("template_python.snippets.py", "new snippet template", r"""
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re

def addSnipUtilDir():
    prevPath = None
    path = os.path.abspath(os.path.dirname(__file__))

    while path != prevPath:
        snipUtilPath = os.path.join(path, 'UltiSnips/sniputil.py')
        if os.path.exists(snipUtilPath):
            sys.path.insert(0, os.path.dirname(snipUtilPath))
            break

        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="!")
Exemple #28
0
import sys
import re
import setpypath

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

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

bsnip("#!", "#!/usr/bin/env python...", r"""
#!/usr/bin/env python
# vim:set fileencoding=utf8: #

""")

# 'if' snippets.

bsnip("if", "if ...:<CR>", r"""
if $1:
    $0
""")

bsnip("else", "else:<CR>", r"""
else:
    $0
""", aliases=["el"])
#!/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
""")

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
#!/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',
      r'''
Exemple #31
0
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
def makeParamComments(nameAndArgs):
    numArgs = len(nameAndArgs.split(",")) - 1

    s = ""
    for i in range(numArgs):
        s += "\n#   $%d - " % (i + 1)

    return s
endglobal
""")
Exemple #32
0
from sniputil import put

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

# Templates

bsnip("template_python.snippets.py",
      "new snippet template",
      r"""
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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

$0
""",
      flags="!")
Exemple #33
0
import sys
import re

from sniputil import put

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


# Snippets are now cleared in "clearsnippets" directory.
#put("clearsnippets\n")

# 'if' snippets.
bsnip("if", "if ... then ... end if;", r"""
if $1 then
    $0
end if;
""")

bsnip("ifclk", "if clk'event and clk = '1' then ... end if;", r"""
if clk'event and clk = '1' then
    $0
end if;
""")

bsnip("else", "else ...", r"""
else
    $0
""", aliases=["el"])

bsnip("elsif", "elsif ... {...}", r"""
Exemple #34
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re
import setpypath

from sniputil import put

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


bsnip("com", "/* comment */", r"""
/* $1 */
""", flags="b!")
#!/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


# Section heading
bsnip("sect", "Section", r"""
------------------------------------------------------------------------------
${1:NAME}`!p snip.rv = (57-len(t[1]))*' '+'*notes_'+t[1].lower()+'*'`
  ${2:Short description}`!p snip.rv = (55-len(t[2]))*' '`|${3:doc-ref}|

${0:Information goes here.}

Version ${4:version} from ${5:url}

Installation:
- Follow bundle installation instructions (|bundle_installation|).

""")
Exemple #36
0
bsnip(
    "status",
    "status template",
    r"""
`!v strftime("%d %b")` - `!v strftime("%d %b", localtime()+604800)`
===============


Accomplishments
---------------

* $0


Pending
^^^^^^^


Future
------


Issues
------

* None.


Time Off
--------

* None.
""",
)
Exemple #37
0
from sniputil import put

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

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

# 'if' snippets.
bsnip(
    "if",
    "if ... then ... end if;",
    r"""
if $1 then
    $0
end if;
""",
)

bsnip(
    "ifclk",
    "if clk'event and clk = '1' then ... end if;",
    r"""
if clk'event and clk = '1' then
    $0
end if;
""",
)
# Status template
bsnip("status", "status template", r"""
`!v strftime("%d %b")` - `!v strftime("%d %b", localtime()+604800)`
===============


Accomplishments
---------------

* $0


Pending
^^^^^^^


Future
------


Issues
------

* None.


Time Off
--------

* None.
""")
Exemple #39
0
    snip(trigger, desc, body, flags, aliases=aliases, trimBody=trimBody)


tsnip("part", "Part title", "#", withOverline=True)
tsnip("chap", "Chapter title", "*", withOverline=True)
tsnip("sect", "Section", "=", aliases=["h1"])
tsnip("subsec", "Subsection", "-", aliases=["h2"])
tsnip("subsubsec", "Sub-subsection", "^", aliases=["h3"])
tsnip("para", "Paragraph", '"', aliases=["h4"])

# Directives.

bsnip("centered", "centered:: ...", r"""
.. centered:: ${1:line of text}

$0
""")

bsnip("code", "code block", r"""
.. code-block:: ${1:python}

    $0
""")

bsnip("l", "reference label", r"""
.. _${1:label}:
$0
""")

# Admonitions.
Exemple #40
0
bsnip(
    "status", "status template", r"""
`!v strftime("%d %b")` - `!v strftime("%d %b", localtime()+604800)`
===============


Accomplishments
---------------

* $0


Pending
^^^^^^^


Future
------


Issues
------

* None.


Time Off
--------

* None.
""")
from sniputil import put

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

put(r"""
priority -5

global !p
from sniputil import betterVisual
endglobal
""")

bsnip(
    "fn", "fn name(?) -> ? {}", r"""
fn ${1:function_name}($2)${3/..*/ -> /}${3:Result<${4:()}, Box<dyn std::error::Error>>} {
    `!p betterVisual(snip)`$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 }
}
""")
Exemple #42
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re
import setpypath

from sniputil import put

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


bsnip("template_vim..syntastic_c_config", "syntastic c config template", r"""
let s:include_dirs = [$0]
let g:syntastic_c_include_dirs =
            \ map(s:include_dirs, 'expand("<sfile>:p:h") . "/" . v:val'
""")
#!/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("com", "/* comment */", r"""
/* $1 */
""", flags="b")

bsnip("cb", "compiler barrier (gcc)", r"""
asm volatile("": : :"memory")
""")

bsnip("docstring", "docstring for func or type", r"""
/**
    ${1:Brief description.}

    ${0:Full description.}
*/
""", flags="b", aliases=["doc"])

bsnip("ts", "typedef struct name { ... }", r"""
typedef struct ${1:name}
{
    $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("ifeq", "ifeq (...) / endif", r"""
ifeq ($1,$2)
    $0
endif
""")

bsnip("ifneq", "ifneq (...) / endif", r"""
ifneq ($1,$2)
    $0
endif
""")

bsnip("ifdef", "ifdef var / endif", r"""
ifdef $1
    $0
endif
""")

bsnip("ifndef", "ifndef var / endif", r"""
ifndef $1
    $0
Exemple #45
0
#!/usr/bin/env python
# vim:set fileencoding=utf8:

import os
import sys
import re
import setpypath

from sniputil import put

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

bsnip("ifeq", "ifeq (...) / endif", r"""
ifeq ($1,$2)
    $0
endif
""", flags="!")

bsnip("ifneq", "ifneq (...) / endif", r"""
ifneq ($1,$2)
    $0
endif
""", flags="!")

bsnip("ifdef", "ifdef var / endif", r"""
ifdef $1
    $0
endif
""", flags="!")
Exemple #46
0
    for i, line in enumerate(text.splitlines()):
        if i == 0:
            snip.rv = snip.mkline(line)
            snip.shift(contIndentLevel)
        elif line.strip():
            snip += line
        else:
            # Avoid indentation for empty lines.
            snip.rv += "\n"
endglobal
""")

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

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

bsnip("elif",
      "else if (...) {...}",
Exemple #47
0
from sniputil import snip, bsnip, wsnip
from sniputil import abbr, babbr, wabbr
from sniputil import put

put(r"""
priority -5

global !p
from sniputil import autoPeriod
endglobal
""")

bsnip("#!", "#!/usr/bin/env python...", r"""
#!/usr/bin/env python
# vim:set fileencoding=utf8: #

""")

# 'if' snippets.

bsnip("if", "if ...:<CR>", r"""
if $1:
    $0
""")

bsnip("else", "else:<CR>", r"""
else:
    $0
""", aliases=["el"])
Exemple #48
0
from sniputil import abbr, babbr, wabbr


put(r"""
priority -5

global !p
from sniputil import betterVisual
from sniputil import autoPeriod
endglobal
""")

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

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

bsnip("elif", "else if (...) {...}", r"""
else if ($1)
{
    `!p betterVisual(snip)`$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("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}) {};
Exemple #50
0
# vim:set fileencoding=utf8:

import os
import sys
import re

sys.path.append(
        os.path.join(os.path.dirname(__file__),
                     '..', '..', '..', 'UltiSnips'))

from sniputil import put

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


# Section heading
bsnip("sect", "Section", r"""
------------------------------------------------------------------------------
${1:NAME}`!p snip.rv = (57-len(t[1]))*' '+'*notes_'+t[1].lower()+'*'`
  ${2:Short description}`!p snip.rv = (55-len(t[2]))*' '`|${3:doc-ref}|

${0:Information goes here.}

Version ${4:version} from ${5:url}

Installation:
- Follow bundle installation instructions (|bundle_installation|).

""")