mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Support untitled buffer (#1152)
* Support untitled buffer * Enable opt out * Add documentation * Add documentation * Use correct buffer names * Wipeout file contents
This commit is contained in:
@@ -212,6 +212,9 @@ function! s:register_events() abort
|
||||
if exists('##TextChangedP')
|
||||
autocmd TextChangedP * call s:on_text_document_did_change()
|
||||
endif
|
||||
if g:lsp_untitled_buffer_enabled
|
||||
autocmd FileType * call s:on_filetype_changed(bufnr('<afile>'))
|
||||
endif
|
||||
augroup END
|
||||
|
||||
for l:bufnr in range(1, bufnr('$'))
|
||||
@@ -228,6 +231,12 @@ function! s:unregister_events() abort
|
||||
doautocmd <nomodeline> User lsp_unregister_server
|
||||
endfunction
|
||||
|
||||
function! s:on_filetype_changed(buf) abort
|
||||
call s:on_buf_wipeout(a:buf)
|
||||
" TODO: stop unused servers
|
||||
call s:on_text_document_did_open()
|
||||
endfunction
|
||||
|
||||
function! s:on_text_document_did_open(...) abort
|
||||
let l:buf = a:0 > 0 ? a:1 : bufnr('%')
|
||||
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif
|
||||
|
||||
Reference in New Issue
Block a user