Skip to content

Commit 218fc2a

Browse files
authored
Fix signs for diagnostics that are reported one line past the end (#1360)
Some language servers report unexpected EOF errors on the line that's actually one past the last line of the file. Be a bit more accomodating and just show them on the last line of the buffer instead.
1 parent 4d8a275 commit 218fc2a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

autoload/lsp/internal/diagnostics/signs.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@ endfunction
129129
function! s:place_signs(server, diagnostics_response, bufnr) abort
130130
for l:item in lsp#utils#iteratable(a:diagnostics_response['params']['diagnostics'])
131131
let l:line = lsp#utils#position#lsp_line_to_vim(a:bufnr, l:item['range']['start'])
132+
133+
" Some language servers report an unexpected EOF one line past the end
134+
if l:line == getbufinfo(a:bufnr)[0].linecount + 1
135+
let l:line = l:line - 1
136+
endif
137+
132138
if has_key(l:item, 'severity') && !empty(l:item['severity'])
133139
let l:sign_name = get(s:severity_sign_names_mapping, l:item['severity'], 'LspError')
134140
let l:sign_priority = get(g:lsp_diagnostics_signs_priority_map, l:sign_name, g:lsp_diagnostics_signs_priority)

0 commit comments

Comments
 (0)