mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 05:04:28 +08:00
* Fix #3616, #3903 - Use proper floating window borders in neovim * Compatibility w. length 6/7 ale_floating_window_border values
This commit is contained in:
committed by
GitHub
parent
c3f9bccb8c
commit
c8e9146049
@@ -99,48 +99,30 @@ function! s:NvimPrepareWindowContent(lines) abort
|
|||||||
let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)'))
|
let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)'))
|
||||||
let l:height = min([len(a:lines), l:max_height])
|
let l:height = min([len(a:lines), l:max_height])
|
||||||
|
|
||||||
if empty(g:ale_floating_window_border)
|
return [a:lines[0:l:height-1], l:width, l:height]
|
||||||
return [a:lines, l:width, l:height]
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Add the size of borders
|
|
||||||
let l:width += 2
|
|
||||||
let l:height += 2
|
|
||||||
|
|
||||||
let l:left = get(g:ale_floating_window_border, 0, '|')
|
|
||||||
let l:top = get(g:ale_floating_window_border, 1, '-')
|
|
||||||
let l:top_left = get(g:ale_floating_window_border, 2, '+')
|
|
||||||
let l:top_right = get(g:ale_floating_window_border, 3, '+')
|
|
||||||
let l:bottom_right = get(g:ale_floating_window_border, 4, '+')
|
|
||||||
let l:bottom_left = get(g:ale_floating_window_border, 5, '+')
|
|
||||||
let l:right = get(g:ale_floating_window_border, 6, l:left)
|
|
||||||
let l:bottom = get(g:ale_floating_window_border, 7, l:top)
|
|
||||||
|
|
||||||
let l:lines = [l:top_left . repeat(l:top, l:width - 2) . l:top_right]
|
|
||||||
|
|
||||||
for l:line in a:lines
|
|
||||||
let l:line_width = strchars(l:line)
|
|
||||||
let l:lines = add(l:lines, l:left . l:line . repeat(' ', l:width - l:line_width - 2). l:right)
|
|
||||||
endfor
|
|
||||||
|
|
||||||
" Truncate the lines
|
|
||||||
if len(l:lines) > l:max_height + 1
|
|
||||||
let l:lines = l:lines[0:l:max_height]
|
|
||||||
endif
|
|
||||||
|
|
||||||
let l:lines = add(l:lines, l:bottom_left . repeat(l:bottom, l:width - 2) . l:bottom_right)
|
|
||||||
|
|
||||||
return [l:lines, l:width, l:height]
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:NvimCreate(options) abort
|
function! s:NvimCreate(options) abort
|
||||||
|
let l:left = get(g:ale_floating_window_border, 0, '|')
|
||||||
|
let l:top = get(g:ale_floating_window_border, 1, '-')
|
||||||
|
|
||||||
let l:popup_opts = extend({
|
let l:popup_opts = extend({
|
||||||
\ 'relative': 'cursor',
|
\ 'relative': 'cursor',
|
||||||
\ 'row': 1,
|
\ 'row': 1,
|
||||||
\ 'col': 0,
|
\ 'col': 0,
|
||||||
\ 'width': 42,
|
\ 'width': 42,
|
||||||
\ 'height': 4,
|
\ 'height': 4,
|
||||||
\ 'style': 'minimal'
|
\ 'style': 'minimal',
|
||||||
|
\ 'border': empty(g:ale_floating_window_border) ? 'none' : [
|
||||||
|
\ get(g:ale_floating_window_border, 2, '+'),
|
||||||
|
\ l:top,
|
||||||
|
\ get(g:ale_floating_window_border, 3, '+'),
|
||||||
|
\ get(g:ale_floating_window_border, 6, l:left),
|
||||||
|
\ get(g:ale_floating_window_border, 4, '+'),
|
||||||
|
\ get(g:ale_floating_window_border, 7, l:top),
|
||||||
|
\ get(g:ale_floating_window_border, 5, '+'),
|
||||||
|
\ l:left,
|
||||||
|
\ ],
|
||||||
\ }, s:GetPopupOpts())
|
\ }, s:GetPopupOpts())
|
||||||
|
|
||||||
let l:buffer = nvim_create_buf(v:false, v:false)
|
let l:buffer = nvim_create_buf(v:false, v:false)
|
||||||
|
|||||||
@@ -1252,10 +1252,12 @@ g:ale_floating_preview_popup_opts *g:ale_floating_preview_popup_opts*
|
|||||||
|
|
||||||
For example, to enhance popups with a title: >
|
For example, to enhance popups with a title: >
|
||||||
|
|
||||||
function! CustomOpts() abort {
|
function! CustomOpts() abort
|
||||||
let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr(''))
|
let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr(''))
|
||||||
return {'title': ' ALE: ' . (l:loc.linter_name) . ' '}
|
return {'title': ' ALE: ' . (l:loc.linter_name) . ' '}
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let g:ale_floating_preview_popup_opts = 'g:CustomOpts'
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user