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:
mattn
2021-09-27 18:22:58 +09:00
committed by GitHub
parent 9f7359303b
commit ee38eb1bc6
4 changed files with 24 additions and 1 deletions

View File

@@ -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