Fix fold* snippets.
This commit is contained in:
parent
4f262c849e
commit
ac7fc9b569
@ -10,7 +10,7 @@ priority -60
|
||||
# NICE BOXES #
|
||||
##############
|
||||
global !p
|
||||
from vimsnippets import foldmarker, make_box
|
||||
from vimsnippets import foldmarker, make_box, get_comment_format
|
||||
endglobal
|
||||
|
||||
snippet box "A nice box with the current comment symbol" b
|
||||
@ -40,17 +40,17 @@ $0
|
||||
endsnippet
|
||||
|
||||
snippet fold "Insert a vim fold marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = _get_comment_format()[2]`
|
||||
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]`${2:1} `!p snip.rv = get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldc "Insert a vim fold close marker" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = _get_comment_format()[2]`
|
||||
`!p snip.rv = get_comment_format()[0]` ${2:1}`!p snip.rv = foldmarker()[1]` `!p snip.rv = get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
snippet foldp "Insert a vim fold marker pair" b
|
||||
`!p snip.rv = _get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = _get_comment_format()[2]`
|
||||
`!p snip.rv = get_comment_format()[0]` ${1:Fold description} `!p snip.rv = foldmarker()[0]` `!p snip.rv = get_comment_format()[2]`
|
||||
${2:${VISUAL:Content}}
|
||||
`!p snip.rv = _get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = _get_comment_format()[2]`
|
||||
`!p snip.rv = get_comment_format()[0]` `!p snip.rv = foldmarker()[1]` $1 `!p snip.rv = get_comment_format()[2]`
|
||||
endsnippet
|
||||
|
||||
##########################
|
||||
|
@ -58,7 +58,7 @@ def _parse_comments(s):
|
||||
except StopIteration:
|
||||
return rv
|
||||
|
||||
def _get_comment_format():
|
||||
def get_comment_format():
|
||||
""" Returns a 4-element tuple (first_line, middle_lines, end_line, indent)
|
||||
representing the comment format for the current file.
|
||||
|
||||
@ -78,7 +78,7 @@ def _get_comment_format():
|
||||
|
||||
|
||||
def make_box(twidth, bwidth=None):
|
||||
b, m, e, i = _get_comment_format()
|
||||
b, m, e, i = get_comment_format()
|
||||
bwidth_inner = bwidth - 3 - max(len(b), len(i + e)) if bwidth else twidth + 2
|
||||
sline = b + m + bwidth_inner * m[0] + 2 * m[0]
|
||||
nspaces = (bwidth_inner - twidth) // 2
|
||||
|
Loading…
Reference in New Issue
Block a user