Skip to content

Commit 3af8f3b

Browse files
analizator1Krzysztof Sachanowicz
andauthored
Fix various bugs when loading many buffers (#1511)
* fix languageId incorrectly set to "ctrlspace" * remove get_line_count_buf() which incorrectly returned line('$') for hidden buffers The problem was that current buffer may not be the one requested. Later it caused vim to throw exception about invalid line number when setting text props, and that led to initialization failure for some buffers (and lsp_buffer_enabled autocommand not fired). * don't register server twice * skip registering server only if server_info matches * revert changes to lsp#register_server --------- Co-authored-by: Krzysztof Sachanowicz <[email protected]>
1 parent dbe8b17 commit 3af8f3b

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

autoload/lsp.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ endfunction
10691069
function! s:get_text_document(buf, server_name, buffer_info) abort
10701070
let l:server = s:servers[a:server_name]
10711071
let l:server_info = l:server['server_info']
1072-
let l:language_id = has_key(l:server_info, 'languageId') ? l:server_info['languageId'](l:server_info) : &filetype
1072+
let l:language_id = has_key(l:server_info, 'languageId') ? l:server_info['languageId'](l:server_info) : getbufvar(a:buf, '&filetype')
10731073
return {
10741074
\ 'uri': lsp#utils#get_buffer_uri(a:buf),
10751075
\ 'languageId': l:language_id,

autoload/lsp/ui/vim/folding.vim

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
let s:folding_ranges = {}
22
let s:textprop_name = 'vim-lsp-folding-linenr'
33

4+
" imports
5+
let s:Buffer = vital#lsp#import('VS.Vim.Buffer')
6+
47
function! s:find_servers() abort
58
return filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_folding_range_provider(v:val)')
69
endfunction
@@ -30,7 +33,7 @@ function! s:set_textprops(buf) abort
3033
" Create text property, if not already defined
3134
silent! call prop_type_add(s:textprop_name, {'bufnr': a:buf, 'priority': lsp#internal#textprop#priority('folding')})
3235

33-
let l:line_count = s:get_line_count_buf(a:buf)
36+
let l:line_count = s:Buffer.get_line_count(a:buf)
3437

3538
" First, clear all markers from the previous run
3639
call prop_remove({'type': s:textprop_name, 'bufnr': a:buf}, 1, l:line_count)
@@ -43,14 +46,6 @@ function! s:set_textprops(buf) abort
4346
endwhile
4447
endfunction
4548

46-
function! s:get_line_count_buf(buf) abort
47-
if !has('patch-8.1.1967')
48-
return line('$')
49-
endif
50-
let l:winids = win_findbuf(a:buf)
51-
return empty(l:winids) ? line('$') : line('$', l:winids[0])
52-
endfunction
53-
5449
function! lsp#ui#vim#folding#send_request(server_name, buf, sync) abort
5550
if !lsp#capabilities#has_folding_range_provider(a:server_name)
5651
return

0 commit comments

Comments
 (0)