summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly+github@gmail.com>2022-05-26 23:41:06 -0500
committerGitHub <noreply@github.com>2022-05-27 13:41:06 +0900
commitae44f0560031d4e7c1c806247efb8797cb54dc0e (patch)
treeec276ca669e782be680721234d55a1ab57d4f1ac
parent3d7b3a654160c41c628097e1aaf8f2af8fb15756 (diff)
downloadale-ae44f0560031d4e7c1c806247efb8797cb54dc0e.zip
Allow customization of all floating window borders (#4215)
* Allow customization of all floating window borders Users may not necessarily want the same border character for top+bottom or left+right, so allow all eight border characters to be configured in g:ale_floating_window_border. For backwards compatibility, the old rules are still applied if only six elements are given. * Reorder popup border array for compatibility
-rw-r--r--README.md4
-rw-r--r--autoload/ale/floating_preview.vim34
-rw-r--r--doc/ale.txt16
-rw-r--r--plugin/ale.vim9
4 files changed, 36 insertions, 27 deletions
diff --git a/README.md b/README.md
index 793148d7..d092d8a6 100644
--- a/README.md
+++ b/README.md
@@ -931,14 +931,14 @@ If the terminal supports Unicode, you might try setting the value like below, to
make it look nicer.
```vim
-let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰']
+let g:ale_floating_window_border = ['│', '─', '╭', '╮', '╯', '╰', '│', '─']
```
Since vim's default uses nice unicode characters when possible, you can trick
ale into using that default with
```vim
-let g:ale_floating_window_border = repeat([''], 6)
+let g:ale_floating_window_border = repeat([''], 8)
```
<a name="faq-vim-lsp"></a>
diff --git a/autoload/ale/floating_preview.vim b/autoload/ale/floating_preview.vim
index e953c363..1063a2db 100644
--- a/autoload/ale/floating_preview.vim
+++ b/autoload/ale/floating_preview.vim
@@ -106,18 +106,20 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:width += 2
let l:height += 2
- let l:hor = g:ale_floating_window_border[0]
- let l:top = g:ale_floating_window_border[1]
- let l:top_left = g:ale_floating_window_border[2]
- let l:top_right = g:ale_floating_window_border[3]
- let l:bottom_right = g:ale_floating_window_border[4]
- let l:bottom_left = g:ale_floating_window_border[5]
+ 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:hor . l:line . repeat(' ', l:width - l:line_width - 2). l:hor)
+ let l:lines = add(l:lines, l:left . l:line . repeat(' ', l:width - l:line_width - 2). l:right)
endfor
" Truncate the lines
@@ -125,7 +127,7 @@ function! s:NvimPrepareWindowContent(lines) abort
let l:lines = l:lines[0:l:max_height]
endif
- let l:lines = add(l:lines, l:bottom_left . repeat(l:top, l:width - 2) . l:bottom_right)
+ 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
@@ -158,14 +160,14 @@ function! s:VimCreate(options) abort
\ 'padding': [0, 1, 0, 1],
\ 'border': [],
\ 'borderchars': empty(g:ale_floating_window_border) ? [' '] : [
- \ g:ale_floating_window_border[1],
- \ g:ale_floating_window_border[0],
- \ g:ale_floating_window_border[1],
- \ g:ale_floating_window_border[0],
- \ g:ale_floating_window_border[2],
- \ g:ale_floating_window_border[3],
- \ g:ale_floating_window_border[4],
- \ g:ale_floating_window_border[5],
+ \ get(g:ale_floating_window_border, 1, '-'),
+ \ get(g:ale_floating_window_border, 6, '|'),
+ \ get(g:ale_floating_window_border, 7, '-'),
+ \ get(g:ale_floating_window_border, 0, '|'),
+ \ get(g:ale_floating_window_border, 2, '+'),
+ \ get(g:ale_floating_window_border, 3, '+'),
+ \ get(g:ale_floating_window_border, 4, '+'),
+ \ get(g:ale_floating_window_border, 5, '+'),
\ ],
\ 'moved': 'any',
\ })
diff --git a/doc/ale.txt b/doc/ale.txt
index c969cb9e..1f5b3218 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -676,7 +676,8 @@ Hover information can be displayed in the preview window instead by setting
When using Neovim or Vim with |popupwin|, if |g:ale_hover_to_floating_preview|
or |g:ale_floating_preview| is set to 1, the hover information will show in a
-floating window. And |g:ale_floating_window_border| for the border setting.
+floating window. The borders of the floating preview window can be customized
+by setting |g:ale_floating_window_border|.
For Vim 8.1+ terminals, mouse hovering is disabled by default. Enabling
|balloonexpr| commands in terminals can cause scrolling issues in terminals,
@@ -1236,14 +1237,19 @@ g:ale_floating_preview *g:ale_floating_preview*
g:ale_floating_window_border *g:ale_floating_window_border*
Type: |List|
- Default: `['|', '-', '+', '+', '+', '+']`
+ Default: `['|', '-', '+', '+', '+', '+', '|', '-']`
When set to `[]`, window borders are disabled. The elements in the list set
- the horizontal, top, top-left, top-right, bottom-right and bottom-left
- border characters, respectively.
+ the the characters for the left side, top, top-left corner, top-right
+ corner, bottom-right corner, bottom-left corner, right side, and bottom of
+ the floating window, respectively.
If the terminal supports Unicode, you might try setting the value to
- ` ['│', '─', '╭', '╮', '╯', '╰']`, to make it look nicer.
+ ` ['│', '─', '╭', '╮', '╯', '╰', '│', '─']`, to make it look nicer.
+
+ NOTE: For compatibility with previous versions, if the list does not have
+ elements for the right side and bottom, the left side and top will be used
+ instead.
g:ale_history_enabled *g:ale_history_enabled*
diff --git a/plugin/ale.vim b/plugin/ale.vim
index 8d829ddf..12373e11 100644
--- a/plugin/ale.vim
+++ b/plugin/ale.vim
@@ -152,10 +152,11 @@ let g:ale_hover_to_floating_preview = get(g:, 'ale_hover_to_floating_preview', 0
" Detail uses floating windows in Neovim
let g:ale_detail_to_floating_preview = get(g:, 'ale_detail_to_floating_preview', 0)
-" Border setting for floating preview windows in Neovim
-" The element in the list presents - horizontal, top, top-left, top-right,
-" bottom-right and bottom-left
-let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+'])
+" Border setting for floating preview windows
+" The elements in the list set the characters for the left, top, top-left,
+" top-right, bottom-right, bottom-left, right, and bottom of the border
+" respectively
+let g:ale_floating_window_border = get(g:, 'ale_floating_window_border', ['|', '-', '+', '+', '+', '+', '|', '-'])
" This flag can be set to 0 to disable warnings for trailing whitespace
let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1)