mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1995: more functions can be used as methods
Problem: More functions can be used as methods.
Solution: Make sign functions usable as a method.
93476fd634
Make sign_placelist and sign_unplacelist accept exactly one argument.
Before, they erroneously accepted one or more arguments.
This commit is contained in:
parent
4efcb72bb7
commit
aad25ae4fc
@ -404,6 +404,9 @@ sign_define({list})
|
|||||||
\ 'text' : '!!'}
|
\ 'text' : '!!'}
|
||||||
\ ])
|
\ ])
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignList()->sign_define()
|
||||||
|
|
||||||
sign_getdefined([{name}]) *sign_getdefined()*
|
sign_getdefined([{name}]) *sign_getdefined()*
|
||||||
Get a list of defined signs and their attributes.
|
Get a list of defined signs and their attributes.
|
||||||
This is similar to the |:sign-list| command.
|
This is similar to the |:sign-list| command.
|
||||||
@ -435,6 +438,9 @@ sign_getdefined([{name}]) *sign_getdefined()*
|
|||||||
" Get the attribute of the sign named mySign
|
" Get the attribute of the sign named mySign
|
||||||
echo sign_getdefined("mySign")
|
echo sign_getdefined("mySign")
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignList()->sign_getdefined()
|
||||||
|
|
||||||
sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
|
sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
|
||||||
Return a list of signs placed in a buffer or all the buffers.
|
Return a list of signs placed in a buffer or all the buffers.
|
||||||
This is similar to the |:sign-place-list| command.
|
This is similar to the |:sign-place-list| command.
|
||||||
@ -494,6 +500,9 @@ sign_getplaced([{buf} [, {dict}]]) *sign_getplaced()*
|
|||||||
|
|
||||||
" Get a List of all the placed signs
|
" Get a List of all the placed signs
|
||||||
echo sign_getplaced()
|
echo sign_getplaced()
|
||||||
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetBufname()->sign_getplaced()
|
||||||
<
|
<
|
||||||
*sign_jump()*
|
*sign_jump()*
|
||||||
sign_jump({id}, {group}, {buf})
|
sign_jump({id}, {group}, {buf})
|
||||||
@ -510,7 +519,9 @@ sign_jump({id}, {group}, {buf})
|
|||||||
" Jump to sign 10 in the current buffer
|
" Jump to sign 10 in the current buffer
|
||||||
call sign_jump(10, '', '')
|
call sign_jump(10, '', '')
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignid()->sign_jump()
|
||||||
|
<
|
||||||
*sign_place()*
|
*sign_place()*
|
||||||
sign_place({id}, {group}, {name}, {buf} [, {dict}])
|
sign_place({id}, {group}, {name}, {buf} [, {dict}])
|
||||||
Place the sign defined as {name} at line {lnum} in file or
|
Place the sign defined as {name} at line {lnum} in file or
|
||||||
@ -560,7 +571,9 @@ sign_place({id}, {group}, {name}, {buf} [, {dict}])
|
|||||||
call sign_place(10, 'g3', 'sign4', 'json.c',
|
call sign_place(10, 'g3', 'sign4', 'json.c',
|
||||||
\ {'lnum' : 40, 'priority' : 90})
|
\ {'lnum' : 40, 'priority' : 90})
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignid()->sign_place(group, name, expr)
|
||||||
|
<
|
||||||
*sign_placelist()*
|
*sign_placelist()*
|
||||||
sign_placelist({list})
|
sign_placelist({list})
|
||||||
Place one or more signs. This is similar to the
|
Place one or more signs. This is similar to the
|
||||||
@ -620,6 +633,8 @@ sign_placelist({list})
|
|||||||
\ 'lnum' : 50}
|
\ 'lnum' : 50}
|
||||||
\ ])
|
\ ])
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignlist()->sign_placelist()
|
||||||
|
|
||||||
sign_undefine([{name}]) *sign_undefine()*
|
sign_undefine([{name}]) *sign_undefine()*
|
||||||
sign_undefine({list})
|
sign_undefine({list})
|
||||||
@ -644,6 +659,8 @@ sign_undefine({list})
|
|||||||
" Delete all the signs
|
" Delete all the signs
|
||||||
call sign_undefine()
|
call sign_undefine()
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignlist()->sign_undefine()
|
||||||
|
|
||||||
sign_unplace({group} [, {dict}]) *sign_unplace()*
|
sign_unplace({group} [, {dict}]) *sign_unplace()*
|
||||||
Remove a previously placed sign in one or more buffers. This
|
Remove a previously placed sign in one or more buffers. This
|
||||||
@ -686,6 +703,9 @@ sign_unplace({group} [, {dict}]) *sign_unplace()*
|
|||||||
|
|
||||||
" Remove all the placed signs from all the buffers
|
" Remove all the placed signs from all the buffers
|
||||||
call sign_unplace('*')
|
call sign_unplace('*')
|
||||||
|
|
||||||
|
< Can also be used as a |method|: >
|
||||||
|
GetSigngroup()->sign_unplace()
|
||||||
<
|
<
|
||||||
sign_unplacelist({list}) *sign_unplacelist()*
|
sign_unplacelist({list}) *sign_unplacelist()*
|
||||||
Remove previously placed signs from one or more buffers. This
|
Remove previously placed signs from one or more buffers. This
|
||||||
@ -715,5 +735,8 @@ sign_unplacelist({list}) *sign_unplacelist()*
|
|||||||
\ {'id' : 20, 'buffer' : 'b.vim'},
|
\ {'id' : 20, 'buffer' : 'b.vim'},
|
||||||
\ ])
|
\ ])
|
||||||
<
|
<
|
||||||
|
Can also be used as a |method|: >
|
||||||
|
GetSignlist()->sign_unplacelist()
|
||||||
|
<
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@ -326,15 +326,15 @@ return {
|
|||||||
sha256={args=1},
|
sha256={args=1},
|
||||||
shellescape={args={1, 2}},
|
shellescape={args={1, 2}},
|
||||||
shiftwidth={args={0, 1}},
|
shiftwidth={args={0, 1}},
|
||||||
sign_define={args={1, 2}},
|
sign_define={args={1, 2}, base=1},
|
||||||
sign_getdefined={args={0, 1}},
|
sign_getdefined={args={0, 1}, base=1},
|
||||||
sign_getplaced={args={0, 2}},
|
sign_getplaced={args={0, 2}, base=1},
|
||||||
sign_jump={args={3, 3}},
|
sign_jump={args=3, base=1},
|
||||||
sign_place={args={4, 5}},
|
sign_place={args={4, 5}, base=1},
|
||||||
sign_placelist={args={1}},
|
sign_placelist={args=1, base=1},
|
||||||
sign_undefine={args={0, 1}},
|
sign_undefine={args={0, 1}, base=1},
|
||||||
sign_unplace={args={1, 2}},
|
sign_unplace={args={1, 2}, base=1},
|
||||||
sign_unplacelist={args={1}},
|
sign_unplacelist={args=1, base=1},
|
||||||
simplify={args=1},
|
simplify={args=1},
|
||||||
sin={args=1, base=1, func="float_op_wrapper", data="&sin"},
|
sin={args=1, base=1, func="float_op_wrapper", data="&sin"},
|
||||||
sinh={args=1, base=1, func="float_op_wrapper", data="&sinh"},
|
sinh={args=1, base=1, func="float_op_wrapper", data="&sinh"},
|
||||||
|
@ -393,7 +393,7 @@ func Test_sign_funcs()
|
|||||||
|
|
||||||
" Tests for sign_define()
|
" Tests for sign_define()
|
||||||
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
||||||
call assert_equal(0, sign_define("sign1", attr))
|
call assert_equal(0, "sign1"->sign_define(attr))
|
||||||
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error',
|
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error',
|
||||||
\ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined())
|
\ 'linehl' : 'Search', 'text' : '=>'}], sign_getdefined())
|
||||||
|
|
||||||
@ -404,13 +404,13 @@ func Test_sign_funcs()
|
|||||||
call Sign_define_ignore_error("sign2", attr)
|
call Sign_define_ignore_error("sign2", attr)
|
||||||
call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange',
|
call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange',
|
||||||
\ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}],
|
\ 'linehl' : 'DiffAdd', 'text' : '!!', 'icon' : 'sign2.ico'}],
|
||||||
\ sign_getdefined("sign2"))
|
\ "sign2"->sign_getdefined())
|
||||||
|
|
||||||
" Test for a sign name with digits
|
" Test for a sign name with digits
|
||||||
call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'}))
|
call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'}))
|
||||||
call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}],
|
call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}],
|
||||||
\ sign_getdefined(0002))
|
\ sign_getdefined(0002))
|
||||||
call sign_undefine(0002)
|
eval 0002->sign_undefine()
|
||||||
|
|
||||||
" Tests for invalid arguments to sign_define()
|
" Tests for invalid arguments to sign_define()
|
||||||
call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:')
|
call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:')
|
||||||
@ -434,7 +434,7 @@ func Test_sign_funcs()
|
|||||||
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
||||||
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
||||||
\ 'priority' : 10}]}],
|
\ 'priority' : 10}]}],
|
||||||
\ sign_getplaced('%', {'lnum' : 20}))
|
\ '%'->sign_getplaced({'lnum' : 20}))
|
||||||
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
||||||
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
||||||
\ 'priority' : 10}]}],
|
\ 'priority' : 10}]}],
|
||||||
@ -490,10 +490,10 @@ func Test_sign_funcs()
|
|||||||
\ 'E745:')
|
\ 'E745:')
|
||||||
|
|
||||||
" Tests for sign_unplace()
|
" Tests for sign_unplace()
|
||||||
call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
|
eval 20->sign_place('', 'sign2', 'Xsign', {"lnum" : 30})
|
||||||
call assert_equal(0, sign_unplace('',
|
call assert_equal(0, sign_unplace('',
|
||||||
\ {'id' : 20, 'buffer' : 'Xsign'}))
|
\ {'id' : 20, 'buffer' : 'Xsign'}))
|
||||||
call assert_equal(-1, sign_unplace('',
|
call assert_equal(-1, ''->sign_unplace(
|
||||||
\ {'id' : 30, 'buffer' : 'Xsign'}))
|
\ {'id' : 30, 'buffer' : 'Xsign'}))
|
||||||
call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
|
call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
|
||||||
call assert_fails("call sign_unplace('',
|
call assert_fails("call sign_unplace('',
|
||||||
@ -1693,7 +1693,7 @@ func Test_sign_jump_func()
|
|||||||
let r = sign_jump(5, '', 'foo')
|
let r = sign_jump(5, '', 'foo')
|
||||||
call assert_equal(2, r)
|
call assert_equal(2, r)
|
||||||
call assert_equal(2, line('.'))
|
call assert_equal(2, line('.'))
|
||||||
let r = sign_jump(6, 'g1', 'foo')
|
let r = 6->sign_jump('g1', 'foo')
|
||||||
call assert_equal(5, r)
|
call assert_equal(5, r)
|
||||||
call assert_equal(5, line('.'))
|
call assert_equal(5, line('.'))
|
||||||
let r = sign_jump(5, '', 'bar')
|
let r = sign_jump(5, '', 'bar')
|
||||||
@ -1921,8 +1921,7 @@ func Test_sign_funcs_multi()
|
|||||||
\ 'group' : 'g1', 'priority' : 10}], s[0].signs)
|
\ 'group' : 'g1', 'priority' : 10}], s[0].signs)
|
||||||
|
|
||||||
" Change an existing sign without specifying the group
|
" Change an existing sign without specifying the group
|
||||||
call assert_equal([5], sign_placelist([
|
call assert_equal([5], [{'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]->sign_placelist())
|
||||||
\ {'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]))
|
|
||||||
let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''})
|
let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''})
|
||||||
call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11,
|
call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11,
|
||||||
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
||||||
@ -1955,7 +1954,7 @@ func Test_sign_funcs_multi()
|
|||||||
\ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}]))
|
\ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}]))
|
||||||
|
|
||||||
" Invalid arguments
|
" Invalid arguments
|
||||||
call assert_equal([], sign_unplacelist([]))
|
call assert_equal([], []->sign_unplacelist())
|
||||||
call assert_fails('call sign_unplacelist({})', "E714:")
|
call assert_fails('call sign_unplacelist({})', "E714:")
|
||||||
call assert_fails('call sign_unplacelist([[]])', "E715:")
|
call assert_fails('call sign_unplacelist([[]])', "E715:")
|
||||||
call assert_fails('call sign_unplacelist(["abc"])', "E715:")
|
call assert_fails('call sign_unplacelist(["abc"])', "E715:")
|
||||||
|
Loading…
Reference in New Issue
Block a user