1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 01:25:00 +08:00

Updated plugins

This commit is contained in:
amix
2014-08-03 23:02:51 +01:00
parent b92f0f2eb1
commit 2a9908e4f0
88 changed files with 2839 additions and 2014 deletions

View File

@ -42,18 +42,9 @@ INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
def has_cjk(char):
"""
Detect char contains CJK character
:param char: characters needs to be detect
"""
try:
CJK_RE.finditer(char).next()
except StopIteration:
return False
else:
return True
def has_cjk(s):
"""Detect if s contains CJK characters."""
return CJK_RE.search(s) is not None
def real_filename(filename):
"""pealeextension name off if possible
@ -74,15 +65,17 @@ def check_file_exist(rst_path, relative_path):
return abs_path
def rst_char_len(char):
"""
return len of string which fit in rst
For instance:chinese "我" decode as only one character,
However, the rst interpreter needs 2 "=" instead of 1.
try:
rst_char_len = vim.strwidth # Requires Vim 7.3+
except AttributeError:
from unicodedata import east_asian_width
def rst_char_len(s):
"""Return the required over-/underline length for s."""
result = 0
for c in s:
result += 2 if east_asian_width(c) in ('W', 'F') else 1
return result
:param: char needs to be count
"""
return len(re.findall(r'[^\u4e00-\u9fff\s]', char))+len(char)
def make_items(times, leading='+'):
"""
@ -94,7 +87,7 @@ def make_items(times, leading='+'):
times = int(times)
if leading == 1:
msg = ""
for x in xrange(1, times+1):
for x in range(1, times+1):
msg += "%s. Item\n" % x
return msg
else:
@ -136,43 +129,43 @@ endglobal
snippet part "Part" b
`!p snip.rv = rst_char_len(t[1])*'#'`
${1:Part name}
${1:${VISUAL:Part name}}
`!p snip.rv = rst_char_len(t[1])*'#'`
$0
endsnippet
snippet sec "Section" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:Section name}
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet chap "Chapter" b
`!p snip.rv = rst_char_len(t[1])*'*'`
${1:Chapter name}
${1:${VISUAL:Chapter name}}
`!p snip.rv = rst_char_len(t[1])*'*'`
$0
endsnippet
snippet sec "Section" b
${1:${VISUAL:Section name}}
`!p snip.rv = rst_char_len(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:${VISUAL:Subsection name}}
`!p snip.rv = rst_char_len(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:${VISUAL:Subsubsection name}}
`!p snip.rv = rst_char_len(t[1])*'^'`
$0
endsnippet
snippet para "Paragraph" b
${1:Paragraph name}
${1:${VISUAL:Paragraph name}}
`!p snip.rv = rst_char_len(t[1])*'"'`
$0
@ -180,7 +173,7 @@ endsnippet
snippet em "Emphasize string" i
`!p
# dirty but works with CJK charactor detection
# dirty but works with CJK character detection
if has_cjk(vim.current.line):
snip.rv ="\ "`*${1:${VISUAL:Em}}*`!p
if has_cjk(vim.current.line):
@ -224,7 +217,7 @@ endsnippet
snippet cb "Code Block" b
.. code-block:: ${1:`!p snip.rv = get_popular_code_type()`}
${2:code}
${2:${VISUAL:code}}
$0
endsnippet
@ -247,7 +240,10 @@ if di == 'fi':
:alt: {0}
{0}""".format(real_name)
`
..`!p snip.rv = " %s" % link if link else ""` $1`!p snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)`:: ${2:file}`!p if content:
..`!p snip.rv = " %s" % link if link else ""` $1`!p
snip.rv=complete(t[1], INCLUDABLE_DIRECTIVES)
`:: ${2:${VISUAL:file}}`!p
if content:
snip.rv +=" "+content`
`!p
# Tip of whether file is exist in comment type
@ -261,7 +257,7 @@ endsnippet
snippet di "Directives" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES)`:: $2
${3:Content}
${3:${VISUAL:Content}}
$0
endsnippet
@ -273,7 +269,7 @@ endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
${2:Content}
${2:${VISUAL:Content}}
$0
endsnippet
@ -292,6 +288,6 @@ endsnippet
snippet sid "SideBar" b
.. sidebar:: ${1:SideBar Title}
${2:SideBar Content}
${2:${VISUAL:SideBar Content}}
endsnippet
# vim:ft=snippets: