-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.vim
59 lines (54 loc) · 1.67 KB
/
functions.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
" Gets Errors and Warnings for buffer plus the Status message from coc.nvim
function! StatusDiagnosticForBuffer() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'error', 0)
call add(msgs, '✘' . info['error'])
endif
if get(info, 'warning', 0)
call add(msgs, '' . info['warning'])
endif
return join(msgs, ' ')
endfunction
" Gets Errors and Warnings for the entire workspace from coc.nvim
function! StatusDiagnosticForWorkspace() abort
let diagnostics = CocAction('diagnosticList')
if type(diagnostics) == v:t_list
let errors = []
let warnings = []
for diagnostic in diagnostics
if diagnostic['severity'] == 'Error'
call add(errors, diagnostic)
endif
if diagnostic['severity'] == 'Warning'
call add(warnings, diagnostic)
endif
endfor
return " ✘ " . string(len(errors)) . " " . string(len(warnings)) . " "
endif
endfunction
" Just gets the status message from coc.nvim
function! CocMinimalStatus() abort
return get(g:, 'coc_status', '')
endfunction
" Just gets the errors from the current buffer
function! CocMinimalErrors() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'error', 0)
call add(msgs, '✘' . info['error'])
endif
return join(msgs)
endfunction
" Just gets the warnings from the current buffer
function! CocMinimalWarnings() abort
let info = get(b:, 'coc_diagnostic_info', {})
if empty(info) | return '' | endif
let msgs = []
if get(info, 'warning', 0)
call add(msgs, '' . info['warning'])
endif
return join(msgs)
endfunction