Skip to content

Commit

Permalink
Update vital-vs for fixing to scroll bordererd-window (#1556)
Browse files Browse the repository at this point in the history
Co-authored-by: Prabir Shrestha <[email protected]>
  • Loading branch information
hrsh7th and prabirshrestha authored Aug 5, 2024
1 parent 396d248 commit 356254d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
52 changes: 51 additions & 1 deletion autoload/vital/_lsp/VS/Vim/Window.vim
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,55 @@ endfunction
if has('nvim')
function! s:info(winid) abort
let l:info = getwininfo(a:winid)[0]

if s:is_floating(a:winid)
let l:config = nvim_win_get_config(a:winid)
let l:config.border = get(l:config, 'border', 'none')
if type(l:config.border) !=# type([])
if index(['rounded', 'single', 'double', 'solid'], l:config.border) >= 0
let l:width_off = 2
let l:height_off = 2
elseif l:config.border ==# 'shadow'
let l:width_off = 1
let l:height_off = 1
else
let l:width_off = 0
let l:height_off = 0
endif
else
let l:has_top = v:false
let l:has_top = l:has_top || get(l:config.border, 0, '') !=# ''
let l:has_top = l:has_top || get(l:config.border, 1, '') !=# ''
let l:has_top = l:has_top || get(l:config.border, 2, '') !=# ''
let l:has_right = v:false
let l:has_right = l:has_right || get(l:config.border, 2, '') !=# ''
let l:has_right = l:has_right || get(l:config.border, 3, '') !=# ''
let l:has_right = l:has_right || get(l:config.border, 4, '') !=# ''
let l:has_bottom = v:false
let l:has_bottom = l:has_bottom || get(l:config.border, 4, '') !=# ''
let l:has_bottom = l:has_bottom || get(l:config.border, 5, '') !=# ''
let l:has_bottom = l:has_bottom || get(l:config.border, 6, '') !=# ''
let l:has_left = v:false
let l:has_left = l:has_left || get(l:config.border, 6, '') !=# ''
let l:has_left = l:has_left || get(l:config.border, 7, '') !=# ''
let l:has_left = l:has_left || get(l:config.border, 0, '') !=# ''

let l:width_off = (l:has_left ? 1 : 0) + (l:has_right ? 1 : 0)
let l:height_off = (l:has_top ? 1 : 0) + (l:has_bottom ? 1 : 0)
endif
let l:left = get(l:config, '')
let l:info.core_width = l:config.width - l:width_off
let l:info.core_height = l:config.height - l:height_off
else
let l:info.core_width = l:info.width
let l:info.core_height = l:info.height
endif

return {
\ 'width': l:info.width,
\ 'height': l:info.height,
\ 'core_width': l:info.core_width,
\ 'core_height': l:info.core_height,
\ 'topline': l:info.topline,
\ }
endfunction
Expand All @@ -58,6 +104,8 @@ else
return {
\ 'width': l:info.width,
\ 'height': l:info.height,
\ 'core_width': l:info.core_width,
\ 'core_height': l:info.core_height,
\ 'topline': l:info.firstline
\ }
endif
Expand All @@ -67,6 +115,8 @@ else
function! l:ctx.callback() abort
let self.info.width = winwidth(0)
let self.info.height = winheight(0)
let self.info.core_width = self.info.width
let self.info.core_height = self.info.height
let self.info.topline = line('w0')
endfunction
call s:do(a:winid, { -> l:ctx.callback() })
Expand Down Expand Up @@ -106,7 +156,7 @@ function! s:scroll(winid, topline) abort
function! l:ctx.callback(winid, topline) abort
let l:wininfo = s:info(a:winid)
let l:topline = a:topline
let l:topline = min([l:topline, line('$') - l:wininfo.height + 1])
let l:topline = min([l:topline, line('$') - l:wininfo.core_height + 1])
let l:topline = max([l:topline, 1])

if l:topline == l:wininfo.topline
Expand Down
2 changes: 1 addition & 1 deletion autoload/vital/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ endfunction
" @vimlint(EVL102, 0, l:__)
" @vimlint(EVL102, 0, l:_)

" s:_get_module() returns module object wihch has all script local functions.
" s:_get_module() returns module object which has all script local functions.
function! s:_get_module(name) abort dict
let funcname = s:_import_func_name(self.plugin_name(), a:name)
try
Expand Down
7 changes: 4 additions & 3 deletions autoload/vital/lsp.vital
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
lsp
b1e91b41f5028d65fa3d31a425ff21591d5d957f
969a97cb6b3e634490ba168db0f2606c410cf9a7

VS.LSP.MarkupContent
VS.Vim.Window.FloatingWindow
VS.Vim.Syntax.Markdown
VS.LSP.Text
VS.Vim.Buffer
VS.Vim.Syntax.Markdown
VS.Vim.Window
VS.Vim.Window.FloatingWindow

0 comments on commit 356254d

Please sign in to comment.