-
Notifications
You must be signed in to change notification settings - Fork 20
/
comrade.vim
52 lines (49 loc) · 2.03 KB
/
comrade.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
"=============================================================================
" AUTHOR: beeender <chenmulong at gmail.com>
" License: GPLv3
"=============================================================================
" Called by JetBrains to set the code insight result.
" insight_map format:
" { start_line_number :
" [
" {id: , s_line: , e_line: , s_col: , e_col: , severity: }
" {id: , s_line: , e_line: , s_col: , e_col: , severity: }
" ]
" }
" Line number is 0 based.
function! comrade#SetInsights(channel, buf, insight_map)
let l:channel = comrade#bvar#get(a:buf, 'channel')
if l:channel == a:channel
call comrade#bvar#set(a:buf, 'insight_map', a:insight_map)
call comrade#sign#SetSigns(a:buf)
call comrade#highlight#SetHighlights(a:buf)
endif
endfunction
" Called by python when deoplete wants do completion.
function! comrade#RequestCompletion(buf, param)
if comrade#bvar#has(a:buf, 'channel')
try
let result = call('rpcrequest', [comrade#bvar#get(a:buf, 'channel'), 'comrade_complete', a:param])
return result
catch /./ " The channel has been probably closed
call comrade#util#TruncatedEcho('Failed to send completion request to JetBrains instance. \n' . v:exception)
call comrade#bvar#remove(a:buf, 'channel')
endtry
endif
return []
endfunction
function! comrade#RequestQuickFix(buf, insight, fix) abort
if comrade#bvar#has(a:buf, 'channel')
try
let result = call('rpcrequest', [comrade#bvar#get(a:buf, 'channel'), 'comrade_quick_fix',
\ {'buf' : a:buf, 'insight' : a:insight, 'fix' : a:fix}])
if !empty(result)
call comrade#util#TruncatedEcho(result)
endif
catch /./ " The channel has been probably closed
call comrade#util#TruncatedEcho('Failed to send completion request to JetBrains instance. \n' . v:exception)
call comrade#bvar#remove(a:buf, 'channel')
endtry
endif
return []
endfunction