diff options
author | Oskar Haarklou Veileborg <ohv1020@hotmail.com> | 2023-02-21 10:25:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-21 18:25:10 +0900 |
commit | c8e914604963063b7bb827e9b6f5a6ca741dad60 (patch) | |
tree | 4270463100eadb5cdaf91abdec5a54bc01cb2fb6 | |
parent | c3f9bccb8c04b01d5d0712b8691658af0b0ddb16 (diff) | |
download | ale-c8e914604963063b7bb827e9b6f5a6ca741dad60.zip |
Fix #3616, #3903 - Use proper floating window borders in neovim (#4417)
* Fix #3616, #3903 - Use proper floating window borders in neovim
* Compatibility w. length 6/7 ale_floating_window_border values
-rw-r--r-- | autoload/ale/floating_preview.vim | 48 | ||||
-rw-r--r-- | doc/ale.txt | 4 |
2 files changed, 18 insertions, 34 deletions
diff --git a/autoload/ale/floating_preview.vim b/autoload/ale/floating_preview.vim index c2bf5b6b..d9172150 100644 --- a/autoload/ale/floating_preview.vim +++ b/autoload/ale/floating_preview.vim @@ -99,48 +99,30 @@ function! s:NvimPrepareWindowContent(lines) abort let l:width = max(map(copy(a:lines), 'strdisplaywidth(v:val)')) let l:height = min([len(a:lines), l:max_height]) - if empty(g:ale_floating_window_border) - 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] + return [a:lines[0:l:height-1], l:width, l:height] endfunction 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({ \ 'relative': 'cursor', \ 'row': 1, \ 'col': 0, \ 'width': 42, \ '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()) let l:buffer = nvim_create_buf(v:false, v:false) diff --git a/doc/ale.txt b/doc/ale.txt index 986d8e25..066ba59e 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -1252,10 +1252,12 @@ g:ale_floating_preview_popup_opts *g:ale_floating_preview_popup_opts* For example, to enhance popups with a title: > - function! CustomOpts() abort { + function! CustomOpts() abort let [l:info, l:loc] = ale#util#FindItemAtCursor(bufnr('')) return {'title': ' ALE: ' . (l:loc.linter_name) . ' '} endfunction + + let g:ale_floating_preview_popup_opts = 'g:CustomOpts' < |