mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-22 17:05:42 +08:00
Improve the vim api (#3126)
This commit is contained in:
parent
a5c99f70c0
commit
769cc8beff
@ -74,6 +74,22 @@ if exists('*nvim_win_set_cursor')
|
|||||||
function! s:self.win_set_cursor(win, pos) abort
|
function! s:self.win_set_cursor(win, pos) abort
|
||||||
call nvim_win_set_cursor(a:win, a:pos)
|
call nvim_win_set_cursor(a:win, a:pos)
|
||||||
endfunction
|
endfunction
|
||||||
|
elseif exists('*win_execute')
|
||||||
|
function! s:self.win_set_cursor(win, pos) abort
|
||||||
|
" @fixme use g` to move to cursor line
|
||||||
|
" this seem to be a bug of vim
|
||||||
|
" https://github.com/vim/vim/issues/5022
|
||||||
|
call win_execute(a:win, ':call cursor(' . a:pos[0] . ', ' . a:pos[1] . ')')
|
||||||
|
" call win_execute(a:win, ':' . a:pos[0])
|
||||||
|
call win_execute(a:win, ':normal! g"')
|
||||||
|
endfunction
|
||||||
|
elseif has('lua')
|
||||||
|
function! s:self.win_set_cursor(win, pos) abort
|
||||||
|
lua local winindex = vim.eval("win_id2win(a:win) - 1")
|
||||||
|
lua local w = vim.window(winindex)
|
||||||
|
lua w.line = vim.eval("a:pos[0]")
|
||||||
|
lua w.col = vim.eval("a:pos[1]")
|
||||||
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:self.win_set_cursor(win, pos) abort
|
function! s:self.win_set_cursor(win, pos) abort
|
||||||
|
|
||||||
@ -84,6 +100,11 @@ if exists('*nvim_buf_line_count')
|
|||||||
function! s:self.buf_line_count(buf) abort
|
function! s:self.buf_line_count(buf) abort
|
||||||
return nvim_buf_line_count(a:buf)
|
return nvim_buf_line_count(a:buf)
|
||||||
endfunction
|
endfunction
|
||||||
|
elseif has('lua')
|
||||||
|
function! s:self.buf_line_count(buf) abort
|
||||||
|
" lua numbers are floats, so use float2nr
|
||||||
|
return float2nr(luaeval('#vim.buffer(vim.eval("a:buf"))'))
|
||||||
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:self.buf_line_count(buf) abort
|
function! s:self.buf_line_count(buf) abort
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user