mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
vim-patch:fa3b72348d88
Update runtime files
fa3b72348d
Co-authored-by: Bram Moolenaar <Bram@vim.org>
This commit is contained in:
parent
c61af03cd2
commit
214c9ed1e2
@ -872,35 +872,56 @@ Here is an example that counts the number of spaces with <F4>: >
|
|||||||
" doubling <F4> works on a line
|
" doubling <F4> works on a line
|
||||||
nnoremap <expr> <F4><F4> CountSpaces() .. '_'
|
nnoremap <expr> <F4><F4> CountSpaces() .. '_'
|
||||||
|
|
||||||
function CountSpaces(virtualedit = '', irregular_block = v:false, type = '') abort
|
function CountSpaces(context = {}, type = '') abort
|
||||||
if a:type == ''
|
if a:type == ''
|
||||||
let &operatorfunc = function('CountSpaces', [&virtualedit, v:false])
|
let context = #{
|
||||||
|
\ dot_command: v:false,
|
||||||
|
\ extend_block: '',
|
||||||
|
\ virtualedit: [&l:virtualedit, &g:virtualedit],
|
||||||
|
\ }
|
||||||
|
let &operatorfunc = function('CountSpaces', [context])
|
||||||
set virtualedit=block
|
set virtualedit=block
|
||||||
return 'g@'
|
return 'g@'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let cb_save = &clipboard
|
let save = #{
|
||||||
let sel_save = &selection
|
\ clipboard: &clipboard,
|
||||||
let reg_save = getreginfo('"')
|
\ selection: &selection,
|
||||||
let visual_marks_save = [getpos("'<"), getpos("'>")]
|
\ virtualedit: [&l:virtualedit, &g:virtualedit],
|
||||||
|
\ register: getreginfo('"'),
|
||||||
|
\ visual_marks: [getpos("'<"), getpos("'>")],
|
||||||
|
\ }
|
||||||
|
|
||||||
try
|
try
|
||||||
set clipboard= selection=inclusive virtualedit=
|
set clipboard= selection=inclusive virtualedit=
|
||||||
let commands = #{line: "'[V']", char: "`[v`]", block: "`[\<C-V>`]"}->get(a:type, 'v')
|
let commands = #{
|
||||||
if getpos("']")[-1] != 0 || a:irregular_block
|
\ line: "'[V']",
|
||||||
let commands ..= 'oO$'
|
\ char: "`[v`]",
|
||||||
let &operatorfunc = function('CountSpaces', [a:virtualedit, v:true])
|
\ block: "`[\<C-V>`]",
|
||||||
|
\ }[a:type]
|
||||||
|
let [_, _, col, off] = getpos("']")
|
||||||
|
if off != 0
|
||||||
|
let vcol = getline("'[")->strpart(0, col + off)->strdisplaywidth()
|
||||||
|
if vcol >= [line("'["), '$']->virtcol() - 1
|
||||||
|
let a:context.extend_block = '$'
|
||||||
|
else
|
||||||
|
let a:context.extend_block = vcol .. '|'
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
if a:context.extend_block != ''
|
||||||
|
let commands ..= 'oO' .. a:context.extend_block
|
||||||
endif
|
endif
|
||||||
let commands ..= 'y'
|
let commands ..= 'y'
|
||||||
execute 'silent noautocmd keepjumps normal! ' .. commands
|
execute 'silent noautocmd keepjumps normal! ' .. commands
|
||||||
echomsg getreg('"')->count(' ')
|
echomsg getreg('"')->count(' ')
|
||||||
finally
|
finally
|
||||||
call setreg('"', reg_save)
|
call setreg('"', save.register)
|
||||||
call setpos("'<", visual_marks_save[0])
|
call setpos("'<", save.visual_marks[0])
|
||||||
call setpos("'>", visual_marks_save[1])
|
call setpos("'>", save.visual_marks[1])
|
||||||
let &clipboard = cb_save
|
let &clipboard = save.clipboard
|
||||||
let &selection = sel_save
|
let &selection = save.selection
|
||||||
let &virtualedit = a:virtualedit
|
let [&l:virtualedit, &g:virtualedit] = get(a:context.dot_command ? save : a:context, 'virtualedit')
|
||||||
|
let a:context.dot_command = v:true
|
||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ the name, e.g. "<lambda>123". Examples:
|
|||||||
set opfunc={a\ ->\ MyOpFunc(a)}
|
set opfunc={a\ ->\ MyOpFunc(a)}
|
||||||
" set using a funcref variable
|
" set using a funcref variable
|
||||||
let Fn = function('MyTagFunc')
|
let Fn = function('MyTagFunc')
|
||||||
let &tagfunc = string(Fn)
|
let &tagfunc = Fn
|
||||||
" set using a lambda expression
|
" set using a lambda expression
|
||||||
let &tagfunc = {t -> MyTagFunc(t)}
|
let &tagfunc = {t -> MyTagFunc(t)}
|
||||||
" set using a variable with lambda expression
|
" set using a variable with lambda expression
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
" You can also use this as a start for your own set of menus.
|
" You can also use this as a start for your own set of menus.
|
||||||
"
|
"
|
||||||
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
" Maintainer: Bram Moolenaar <Bram@vim.org>
|
||||||
" Last Change: 2020 Sep 28
|
" Last Change: 2021 Dec 22
|
||||||
|
|
||||||
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
|
" Note that ":an" (short for ":anoremenu") is often used to make a menu work
|
||||||
" in all modes and avoid side effects from mappings defined by the user.
|
" in all modes and avoid side effects from mappings defined by the user.
|
||||||
@ -717,6 +717,11 @@ func s:BMCanAdd(name, num)
|
|||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" no name with control characters
|
||||||
|
if a:name =~ '[\x01-\x1f]'
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
|
||||||
" no special buffer, such as terminal or popup
|
" no special buffer, such as terminal or popup
|
||||||
let buftype = getbufvar(a:num, '&buftype')
|
let buftype = getbufvar(a:num, '&buftype')
|
||||||
if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'
|
if buftype != '' && buftype != 'nofile' && buftype != 'nowrite'
|
||||||
|
Loading…
Reference in New Issue
Block a user