mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-09 09:20:06 +08:00
chore(fold): add code fold marker
This commit is contained in:
parent
6674432dc4
commit
1eb887032d
@ -156,17 +156,20 @@ function! s:self.filter_do(expr) abort
|
|||||||
endfor
|
endfor
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if exists('*nvim_buf_line_count')
|
" define self.line_count(buf)
|
||||||
|
" use nvim_buf_line_count if possible
|
||||||
|
if exists('*nvim_buf_line_count') " {{{
|
||||||
function! s:self.line_count(buf) abort
|
function! s:self.line_count(buf) abort
|
||||||
return nvim_buf_line_count(a:buf)
|
return nvim_buf_line_count(a:buf)
|
||||||
endfunction
|
endfunction " }}}
|
||||||
elseif get(g:, '_spacevim_if_lua', 0)
|
" if +lua is enabled.
|
||||||
|
elseif get(g:, '_spacevim_if_lua', 0) " {{{
|
||||||
" @vimlint(EVL103, 1, a:buf)
|
" @vimlint(EVL103, 1, a:buf)
|
||||||
function! s:self.line_count(buf) abort
|
function! s:self.line_count(buf) abort
|
||||||
" lua numbers are floats, so use float2nr
|
" lua numbers are floats, so use float2nr
|
||||||
return float2nr(luaeval('#vim.buffer(vim.eval("a:buf"))'))
|
return float2nr(luaeval('#vim.buffer(vim.eval("a:buf"))'))
|
||||||
endfunction
|
endfunction
|
||||||
" @vimlint(EVL103, 0, a:buf)
|
" @vimlint(EVL103, 0, a:buf) }}}
|
||||||
else
|
else
|
||||||
function! s:self.line_count(buf) abort
|
function! s:self.line_count(buf) abort
|
||||||
return len(getbufline(a:buf, 1, '$'))
|
return len(getbufline(a:buf, 1, '$'))
|
||||||
@ -174,15 +177,19 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
" just same as nvim_buf_set_lines
|
" buffer.buf_set_lines(buffer, start, end, strict_indexing, replacement)
|
||||||
|
"
|
||||||
|
" this function is just same as nvim_buf_set_lines.
|
||||||
function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement) abort
|
function! s:self.buf_set_lines(buffer, start, end, strict_indexing, replacement) abort
|
||||||
if !bufexists(a:buffer)
|
if !bufexists(a:buffer)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let ma = getbufvar(a:buffer, '&ma')
|
let ma = getbufvar(a:buffer, '&ma')
|
||||||
call setbufvar(a:buffer,'&ma', 1)
|
call setbufvar(a:buffer,'&ma', 1)
|
||||||
if exists('*nvim_buf_set_lines')
|
" if the function `nvim_buf_set_lines` exists
|
||||||
|
if exists('*nvim_buf_set_lines') " {{{
|
||||||
call nvim_buf_set_lines(a:buffer, a:start, a:end, a:strict_indexing, a:replacement)
|
call nvim_buf_set_lines(a:buffer, a:start, a:end, a:strict_indexing, a:replacement)
|
||||||
|
" }}}
|
||||||
elseif exists('*deletebufline') && exists('*bufload')
|
elseif exists('*deletebufline') && exists('*bufload')
|
||||||
" patch-8.1.0039 deletebufline()
|
" patch-8.1.0039 deletebufline()
|
||||||
" patch-8.1.0037 appendbufline()
|
" patch-8.1.0037 appendbufline()
|
||||||
|
Loading…
Reference in New Issue
Block a user