-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show diagnostics in a floating window (#700)
* fix comment * fix indent * support diagnostics in a floating window * doc: add g:lsp_diagnostics_float_{cursor,delay} * fix vint errors except unused variables * suppress vint unused variable errors * lint: use robust operator
- Loading branch information
Showing
14 changed files
with
322 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function! lsp#ui#vim#diagnostics#float#cursor_moved() abort | ||
call s:stop_cursor_moved_timer() | ||
|
||
let l:current_pos = getcurpos()[0:2] | ||
|
||
" use timer to avoid recalculation | ||
if !exists('s:last_pos') || l:current_pos != s:last_pos | ||
let s:last_pos = l:current_pos | ||
let s:cursor_moved_timer = timer_start(g:lsp_diagnostics_float_delay, function('s:float_diagnostics_under_cursor')) | ||
endif | ||
endfunction | ||
|
||
function! s:float_diagnostics_under_cursor(...) abort | ||
let l:diagnostic = lsp#ui#vim#diagnostics#get_diagnostics_under_cursor() | ||
if !empty(l:diagnostic) && has_key(l:diagnostic, 'message') | ||
let l:lines = split(l:diagnostic['message'], '\n', 1) | ||
call lsp#ui#vim#output#preview('', l:lines, { | ||
\ 'statusline': ' LSP Diagnostics' | ||
\}) | ||
let s:displaying_message = 1 | ||
elseif get(s:, 'displaying_message', 0) | ||
call lsp#ui#vim#output#closepreview() | ||
let s:displaying_message = 0 | ||
endif | ||
endfunction | ||
|
||
function! s:stop_cursor_moved_timer() abort | ||
if exists('s:cursor_moved_timer') | ||
call timer_stop(s:cursor_moved_timer) | ||
unlet s:cursor_moved_timer | ||
endif | ||
endfunction |
Oops, something went wrong.