1
0
mirror of https://github.com/amix/vimrc synced 2025-06-17 10:55:00 +08:00

Updated plugins

This commit is contained in:
Amir Salihefendic
2019-11-16 16:28:42 +01:00
parent 96e10ed101
commit 72bdaba47e
204 changed files with 5936 additions and 1666 deletions

View File

@ -6,53 +6,43 @@ priority -50
# General Stuff #
###########################################################################
global !p
import vim
from os import path as ospath
from string import Template
import re
from collections import Counter
from vimsnippets import complete, has_cjk, display_width
from vimsnippets import complete
#http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis','literal','code','math',
'pep-reference','rfc-reference',
'strong','subscript','superscript',
'title-reference','raw']
# http://docutils.sourceforge.net/docs/ref/rst/roles.html
TEXT_ROLES = ['emphasis', 'literal', 'code', 'math',
'pep-reference', 'rfc-reference',
'strong', 'subscript', 'superscript',
'title-reference', 'raw']
TEXT_ROLES_REGEX = r'\.\.\srole::?\s(w+)'
#http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
# http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
SPECIFIC_ADMONITIONS = ["attention", "caution", "danger",
"error", "hint", "important", "note",
"tip", "warning"]
#http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['topic','sidebar','math','epigraph',
'parsed-literal','code','highlights',
'pull-quote','compound','container','table','csv-table',
'list-table','class','sectnum',
'role','default-role','unicode',
'raw']
# http://docutils.sourceforge.net/docs/ref/rst/directives.html
DIRECTIVES = ['code', 'contents', 'admonition', 'table', 'csv-table', 'list-table',
'class', 'container', 'sidebar', 'topic', 'title',
'role', 'default-role', 'raw']
NONE_CONTENT_DIRECTIVES = ['rubric', 'contents', 'header',
'footer', 'date', 'include', 'title']
# DIRECTIVES_WITHOUT_TITLE means directive arguments equal None
DIRECTIVES_WITHOUT_TITLE = ['math', 'meta', 'parsed-literal', 'line-block',
'header', 'compound', 'highlights', 'pull-quote',
'footer', 'epigraph', 'rubric', 'sectnum']
INCLUDABLE_DIRECTIVES = ['image', 'figure', 'include']
# CJK chars
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
CJK_RE = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
#http://www.pygal.org/en/stable/documentation/types/index.html
# Directives for Subsubsection Definition
DIRECTIVES_FOR_SUBSTITUTION = ['replace', 'unicode', 'date']
# http://www.pygal.org/en/stable/documentation/types/index.html
CHART_TYPES = ["Line", "StackedLine", "HorizontalLine", "Bar", "StackedBar", "HorizontalBar", "Histogram", "XY", "DateLine", "TimeLine", "TimeDeltaLine", "DateTimeLine", "Pie", "Radar", "Box", "Dot", "Funnel", "Gauge", "SolidGauge", "Pyramid", "Treemap"]
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
# i.e. "foo.bar.png will return "foo.bar"
"""
return ospath.splitext(filename)[0]
return os.path.splitext(filename)[0]
def check_file_exist(rst_path, relative_path):
"""
@ -62,23 +52,10 @@ def check_file_exist(rst_path, relative_path):
:param relative_path: path related to rst file
:return: relative file's absolute path if file exist
"""
abs_path = ospath.join(ospath.dirname(rst_path), relative_path)
if ospath.isfile(abs_path):
abs_path = os.path.join(os.path.dirname(rst_path), relative_path)
if os.path.isfile(abs_path):
return abs_path
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
def make_items(times, leading='+'):
"""
make lines with leading char multitimes
@ -130,45 +107,45 @@ def get_popular_code_type():
endglobal
snippet part "Part" b
`!p snip.rv = rst_char_len(t[1])*'#'`
`!p snip.rv = display_width(t[1])*'#'`
${1:${VISUAL:Part name}}
`!p snip.rv = rst_char_len(t[1])*'#'`
`!p snip.rv = display_width(t[1])*'#'`
$0
endsnippet
snippet chap "Chapter" b
`!p snip.rv = rst_char_len(t[1])*'*'`
`!p snip.rv = display_width(t[1])*'*'`
${1:${VISUAL:Chapter name}}
`!p snip.rv = rst_char_len(t[1])*'*'`
`!p snip.rv = display_width(t[1])*'*'`
$0
endsnippet
snippet sec "Section" b
${1:${VISUAL:Section name}}
`!p snip.rv = rst_char_len(t[1])*'='`
`!p snip.rv = display_width(t[1])*'='`
$0
endsnippet
snippet ssec "Subsection" b
${1:${VISUAL:Subsection name}}
`!p snip.rv = rst_char_len(t[1])*'-'`
`!p snip.rv = display_width(t[1])*'-'`
$0
endsnippet
snippet sssec "Subsubsection" b
${1:${VISUAL:Subsubsection name}}
`!p snip.rv = rst_char_len(t[1])*'^'`
`!p snip.rv = display_width(t[1])*'^'`
$0
endsnippet
snippet para "Paragraph" b
${1:${VISUAL:Paragraph name}}
`!p snip.rv = rst_char_len(t[1])*'"'`
`!p snip.rv = display_width(t[1])*'"'`
$0
endsnippet
@ -228,7 +205,7 @@ endsnippet
# img, inc, fig
snippet id "Includable Directives" b
`!p
real_name=real_filename(ospath.basename(t[2]))
real_name=real_filename(os.path.basename(t[2]))
di=t[1][:2]
link=""
@ -264,23 +241,30 @@ snippet di "Directives" b
$0
endsnippet
snippet nd "None Content Directives" b
.. $1`!p snip.rv=complete(t[1], NONE_CONTENT_DIRECTIVES)`:: $2
snippet dt "Directives without title" b
.. $1`!p snip.rv=complete(t[1], DIRECTIVES_WITHOUT_TITLE)`::
${2:${VISUAL:Content}}
$0
endsnippet
snippet ds "Directives for subscription" b
.. |$1| $2`!p snip.rv=complete(t[2], DIRECTIVES_FOR_SUBSTITUTION)`:: ${3:Content}
$0
endsnippet
snippet sa "Specific Admonitions" b
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`::
.. $1`!p snip.rv =complete(t[1], SPECIFIC_ADMONITIONS)`:: $2
${2:${VISUAL:Content}}
${3:${VISUAL:Content}}
$0
endsnippet
#it will be trigger at start of line or after a word
# it will be trigger at start of line or after a word
snippet ro "Text Roles" w
\ :$1`!p snip.rv=complete(t[1],
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
TEXT_ROLES+look_up_directives(TEXT_ROLES_REGEX,
path))`:\`$2\`\
endsnippet
@ -306,7 +290,7 @@ snippet chart "Pygal chart for Nikola" b
.. chart:: $1`!p snip.rv=complete(t[1], CHART_TYPES)`
:title: '${2:Browser usage evolution (in %)}'
:x_labels: [${3:"2002", "2003", "2004", "2005", "2006", "2007"}]
'Firefox', [None, None, 0, 16.6, 25, 31]
'Chrome', [None, None, None, None, None, None]
'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
@ -323,4 +307,5 @@ snippet sid "SideBar" b
${2:${VISUAL:SideBar Content}}
endsnippet
# vim:ft=snippets:
# vim:set list noet sts=0 sw=4 ts=4: