-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VS.Vim.Window.FloatingWindow: Support on_opened
/on_closed
as call…
#3
Conversation
01375e3
to
c57cc2b
Compare
The widget api is experimental. I will want to change the API later... |
\ '```', | ||
\ ]) | ||
call l:markup_content.close() | ||
End |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm... the border is complex to calculate position and size...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are multiple implementations for border.
https://github.com/nvim-lua/popup.nvim
https://github.com/lambdalisue/loupe.vim/blob/master/autoload/loupe/viewer/nvim.vim#L24-L105
neovim in vim-lsp doesn't support border so might be we can implement borders later? That way I can at least try converting in vim-lsp neovim to use this floatingwindow.
5f64035
to
49e6e12
Compare
" | ||
" scroll | ||
" | ||
" NOTE: We can't test it because it uses timer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious any reason we use timer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it will use with mapping.
inoremap <expr><C-f> vital#vital#import('VS.Vim.Window').scroll(+4)
inoremap <expr><C-u> vital#vital#import('VS.Vim.Window').scroll(-4)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You review is insightful to me. I've change the design.
if s:scrollable(l:win) | ||
let l:ctx = {} | ||
function! l:ctx.callback(win, delta) abort | ||
let l:height = line('w$') - line('w0') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is a callback due to timer, the window could be deleted. should there be some guard on win exist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. I will add it.
" @param {string[]} contents | ||
" | ||
function! s:MarkupContent.open(row, col, contents) abort | ||
call deletebufline(self.bufnr, '^', '$') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required now but neovim has an api to do bulk edits. not sure if it is already in master or in pr.
|
cd59582
to
4aef838
Compare
I decided to remove The Widget API is very difficult to design. |
- Add Buffer.load
0d1769e
to
b956d45
Compare
67120a2
to
014fda7
Compare
In this branch, The window can be scrolled by the below codes. nnoremap <expr> <C-f> <SID>scroll(+4)
nnoremap <expr> <C-u> <SID>scroll(-4)
inoremap <expr> <C-f> <SID>scroll(+4)
inoremap <expr> <C-u> <SID>scroll(-4)
function! s:scroll(count) abort
let l:ctx = {}
function! l:ctx.callback() abort closure
let l:Window = vital#vital#import('VS.Vim.Window')
for l:winid in l:Window.find({ winid -> getwinvar(winid, 'lsp_scrollable') == 1 })
let l:info = l:Window.info(l:winid)
call l:Window.scroll(l:winid, l:info.topline + a:count)
endfor
endfunction
call timer_start(0, { -> l:ctx.callback() })
return "\<Ignore>"
endfunction |
Currently, the border is not supported but It can be merged now, I think. |
…back
TODO