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')
|
if exists('##TextChangedP')
|
||||||
autocmd TextChangedP * call s:on_text_document_did_change()
|
autocmd TextChangedP * call s:on_text_document_did_change()
|
||||||
endif
|
endif
|
||||||
|
if g:lsp_untitled_buffer_enabled
|
||||||
|
autocmd FileType * call s:on_filetype_changed(bufnr('<afile>'))
|
||||||
|
endif
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
for l:bufnr in range(1, bufnr('$'))
|
for l:bufnr in range(1, bufnr('$'))
|
||||||
@@ -228,6 +231,12 @@ function! s:unregister_events() abort
|
|||||||
doautocmd <nomodeline> User lsp_unregister_server
|
doautocmd <nomodeline> User lsp_unregister_server
|
||||||
endfunction
|
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
|
function! s:on_text_document_did_open(...) abort
|
||||||
let l:buf = a:0 > 0 ? a:1 : bufnr('%')
|
let l:buf = a:0 > 0 ? a:1 : bufnr('%')
|
||||||
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif
|
if getbufvar(l:buf, '&buftype') ==# 'terminal' | return | endif
|
||||||
|
|||||||
@@ -167,7 +167,12 @@ function! lsp#utils#get_buffer_path(...) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! lsp#utils#get_buffer_uri(...) abort
|
function! lsp#utils#get_buffer_uri(...) abort
|
||||||
return lsp#utils#path_to_uri(expand((a:0 > 0 ? '#' . a:1 : '%') . ':p'))
|
let l:name = a:0 > 0 ? bufname(a:1) : expand('%')
|
||||||
|
if empty(l:name)
|
||||||
|
let l:nr = a:0 > 0 ? a:1 : bufnr('%')
|
||||||
|
let l:name = printf('%s/__NO_NAME_%d__', getcwd(), l:nr)
|
||||||
|
endif
|
||||||
|
return lsp#utils#path_to_uri(fnamemodify(l:name, ':p'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Find a nearest to a `path` parent directory `directoryname` by traversing the filesystem upwards
|
" Find a nearest to a `path` parent directory `directoryname` by traversing the filesystem upwards
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ CONTENTS *vim-lsp-contents*
|
|||||||
g:lsp_show_message_request_enabled |g:lsp_show_message_request_enabled|
|
g:lsp_show_message_request_enabled |g:lsp_show_message_request_enabled|
|
||||||
g:lsp_work_done_progress_enabled |g:lsp_work_done_progress_enabled|
|
g:lsp_work_done_progress_enabled |g:lsp_work_done_progress_enabled|
|
||||||
g:lsp_show_message_log_level |g:lsp_show_message_log_level|
|
g:lsp_show_message_log_level |g:lsp_show_message_log_level|
|
||||||
|
g:lsp_untitled_buffer_enabled |g:lsp_untitled_buffer_enabled|
|
||||||
Functions |vim-lsp-functions|
|
Functions |vim-lsp-functions|
|
||||||
lsp#enable |lsp#enable()|
|
lsp#enable |lsp#enable()|
|
||||||
lsp#disable |lsp#disable()|
|
lsp#disable |lsp#disable()|
|
||||||
@@ -941,6 +942,13 @@ g:lsp_show_message_log_level *g:lsp_show_message_log_level*
|
|||||||
shown but `'info'` level and `'log'` level messages are not shown. Setting
|
shown but `'info'` level and `'log'` level messages are not shown. Setting
|
||||||
`'none'` disables to show messages completely.
|
`'none'` disables to show messages completely.
|
||||||
|
|
||||||
|
g:lsp_untitled_buffer_enabled *g:lsp_untitled_buffer_enabled*
|
||||||
|
Type: |Number|
|
||||||
|
Default: `1`
|
||||||
|
|
||||||
|
Determines whether or not vim-lsp plugin is enabled for untitled buffer.
|
||||||
|
Set to `0` to disable for untitled buffer.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
FUNCTIONS *vim-lsp-functions*
|
FUNCTIONS *vim-lsp-functions*
|
||||||
|
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ let g:lsp_tagfunc_source_methods = get(g:, 'lsp_tagfunc_source_methods', ['defin
|
|||||||
let g:lsp_show_message_request_enabled = get(g:, 'lsp_show_message_request_enabled', 1)
|
let g:lsp_show_message_request_enabled = get(g:, 'lsp_show_message_request_enabled', 1)
|
||||||
let g:lsp_show_message_log_level = get(g:, 'lsp_show_message_log_level', 'warning')
|
let g:lsp_show_message_log_level = get(g:, 'lsp_show_message_log_level', 'warning')
|
||||||
let g:lsp_work_done_progress_enabled = get(g:, 'lsp_work_done_progress_enabled', 0)
|
let g:lsp_work_done_progress_enabled = get(g:, 'lsp_work_done_progress_enabled', 0)
|
||||||
|
let g:lsp_untitled_buffer_enabled = get(g:, 'lsp_untitled_buffer_enabled', 1)
|
||||||
|
|
||||||
let g:lsp_get_supported_capabilities = get(g:, 'lsp_get_supported_capabilities', [function('lsp#default_get_supported_capabilities')])
|
let g:lsp_get_supported_capabilities = get(g:, 'lsp_get_supported_capabilities', [function('lsp#default_get_supported_capabilities')])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user