Skip to content

Commit d542bbc

Browse files
thomasfaingnaertprabirshrestha
authored andcommitted
Document customization of popup window color (#415)
* Allow customizing popup window highlight group * Add documentation * Revert "Add documentation" This reverts commit 41954eb. * Revert "Allow customizing popup window highlight group" This reverts commit 625439b. * Add customization instructions to documentation
1 parent ba9e9b5 commit d542bbc

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

doc/vim-lsp.txt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,24 +170,50 @@ g:lsp_preview_float *g:lsp_preview_float*
170170
are shown in a floating window as |preview-window| at the cursor position.
171171
The |preview-window| is closed automatically on cursor moves, unless it is
172172
focused. While focused it may be closed with <esc>.
173-
After opening an autocmd User event lsp_float_opened is issued, as well as
174-
and lsp_float_closed upon closing. This can be used to alter the preview
175-
window (using lsp#ui#vim#output#getpreviewwinid() to get the window id), or
176-
setup custom bindings while a preview is open.
173+
177174
This feature requires neovim 0.4.0 (current master) or
178175
Vim8.1 with has('patch-8.1.1517').
179176

180177
Example:
178+
>
181179
" Opens preview windows as floating
182180
let g:lsp_preview_float = 1
183181
184182
" Opens preview windows as normal windows
185183
let g:lsp_preview_float = 0
184+
<
186185
186+
After opening an autocmd User event lsp_float_opened is issued, as well as
187+
and lsp_float_closed upon closing. This can be used to alter the preview
188+
window (using lsp#ui#vim#output#getpreviewwinid() to get the window id),
189+
setup custom bindings while a preview is open, or change the highlighting
190+
of the window.
191+
192+
Example of custom keybindings:
193+
>
187194
" Close preview window with <esc>
188195
autocmd User lsp_float_opened nmap <buffer> <silent> <esc>
189196
\ <Plug>(lsp-preview-close)
190197
autocmd User lsp_float_closed nunmap <buffer> <esc>
198+
<
199+
200+
Example of customising the highlighting:
201+
>
202+
highlight PopupWindow ctermbg=lightblue guibg=lightblue
203+
204+
augroup lsp_float_colours
205+
autocmd!
206+
if !has('nvim')
207+
autocmd User lsp_float_opened
208+
\ call win_execute(lsp#ui#vim#output#getpreviewwinid(),
209+
\ 'setlocal wincolor=PopupWindow')
210+
else
211+
autocmd User lsp_float_opened
212+
\ call nvim_win_set_option(lsp#ui#vim#output#getpreviewwinid(),
213+
\ 'winhighlight', 'Normal:PopupWindow')
214+
endif
215+
augroup end
216+
<
191217
192218
g:lsp_preview_autoclose *g:lsp_preview_autoclose*
193219
Type: |Number|
@@ -750,7 +776,7 @@ Closes an opened preview window
750776
Transfers focus to an opened preview window or back to the previous window if
751777
focus is already on the preview window.
752778

753-
779+
754780
===============================================================================
755781
Autocomplete *vim-lsp-autocomplete*
756782

0 commit comments

Comments
 (0)