@@ -4,6 +4,17 @@ let s:servers = {} " { lsp_id, server_info, init_callbacks, init_result, buffers
4
4
5
5
let s: notification_callbacks = [] " { name, callback }
6
6
7
+ " This hold previous content for each language servers to make
8
+ " DidChangeTextDocumentParams. The key is buffer numbers:
9
+ " {
10
+ " 1: {
11
+ " "golsp": [ "first-line", "next-line", ... ],
12
+ " "bingo": [ "first-line", "next-line", ... ]
13
+ " },
14
+ " 2: {
15
+ " "pyls": [ "first-line", "next-line", ... ]
16
+ " }
17
+ " }
7
18
let s: file_content = {}
8
19
9
20
" do nothing, place it here only to avoid the message
@@ -221,14 +232,14 @@ function! s:on_text_document_did_close() abort
221
232
call lsp#log (' s:on_text_document_did_close()' , l: buf )
222
233
endfunction
223
234
224
- function ! lsp# get_last_file_content (server_name, buf ) abort
235
+ function ! s: get_last_file_content (server_name, buf ) abort
225
236
if has_key (s: file_content , a: buf ) && has_key (s: file_content [a: buf ], a: server_name )
226
237
return s: file_content [a: buf ][a: server_name ]
227
238
endif
228
239
return []
229
240
endfunction
230
241
231
- function ! lsp# update_file_content (server_name, buf , new ) abort
242
+ function ! s: update_file_content (server_name, buf , new ) abort
232
243
if ! has_key (s: file_content , a: buf )
233
244
let s: file_content [a: buf ] = {}
234
245
endif
@@ -237,9 +248,7 @@ endfunction
237
248
238
249
function ! s: on_buf_wipeout (buf ) abort
239
250
if has_key (s: file_content , a: buf )
240
- for l: server_name in lsp#get_whitelisted_servers ()
241
- call remove (s: file_content [a: buf ], l: server_name )
242
- endfor
251
+ call remove (s: file_content , a: buf )
243
252
endif
244
253
endfunction
245
254
@@ -436,16 +445,16 @@ function! s:text_changes(server_name, buf) abort
436
445
" When syncKind is Incremental and previous content is saved.
437
446
if l: sync_kind == 2 && has_key (s: file_content , a: buf )
438
447
" compute diff
439
- let l: old_content = lsp# get_last_file_content (a: server_name , a: buf )
448
+ let l: old_content = s: get_last_file_content (a: server_name , a: buf )
440
449
let l: new_content = getbufline (a: buf , 1 , ' $' )
441
450
let l: changes = lsp#utils#diff#compute (l: old_content , l: new_content )
442
- call lsp# update_file_content (a: server_name , a: buf , l: new_content )
451
+ call s: update_file_content (a: server_name , a: buf , l: new_content )
443
452
return [l: changes ]
444
453
endif
445
454
446
455
let l: new_content = getbufline (a: buf , 1 , ' $' )
447
456
let l: changes = {' text' : join (l: new_content , " \n " )}
448
- call lsp# update_file_content (a: server_name , a: buf , l: new_content )
457
+ call s: update_file_content (a: server_name , a: buf , l: new_content )
449
458
return [l: changes ]
450
459
endfunction
451
460
0 commit comments