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