mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Fix borderchars and debug=throw (#1178)
This commit is contained in:
@@ -206,7 +206,7 @@ function! s:register_events() abort
|
|||||||
autocmd BufReadPost * call s:on_text_document_did_open()
|
autocmd BufReadPost * call s:on_text_document_did_open()
|
||||||
autocmd BufWritePost * call s:on_text_document_did_save()
|
autocmd BufWritePost * call s:on_text_document_did_save()
|
||||||
autocmd BufWinLeave * call s:on_text_document_did_close()
|
autocmd BufWinLeave * call s:on_text_document_did_close()
|
||||||
autocmd BufWipeout * call s:on_buf_wipeout(bufnr('<afile>'))
|
autocmd BufWipeout * call s:on_buf_wipeout(expand('<afile>'))
|
||||||
autocmd InsertLeave * call s:on_text_document_did_change()
|
autocmd InsertLeave * call s:on_text_document_did_change()
|
||||||
autocmd TextChanged * call s:on_text_document_did_change()
|
autocmd TextChanged * call s:on_text_document_did_change()
|
||||||
if exists('##TextChangedP')
|
if exists('##TextChangedP')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
function! s:_SID() abort
|
function! s:_SID() abort
|
||||||
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
return matchstr(expand('<sfile>'), '<SNR>\zs\d\+\ze__SID$')
|
||||||
endfunction
|
endfunction
|
||||||
execute join(['function! vital#_lsp#VS#Vim#Buffer#import() abort', printf("return map({'get_line_count': '', 'do': '', 'create': '', 'load': ''}, \"vital#_lsp#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
execute join(['function! vital#_lsp#VS#Vim#Buffer#import() abort', printf("return map({'get_line_count': '', 'do': '', 'create': '', 'pseudo': '', 'ensure': '', 'load': ''}, \"vital#_lsp#function('<SNR>%s_' . v:key)\")", s:_SID()), 'endfunction'], "\n")
|
||||||
delfunction s:_SID
|
delfunction s:_SID
|
||||||
" ___vital___
|
" ___vital___
|
||||||
let s:Do = { -> {} }
|
let s:Do = { -> {} }
|
||||||
@@ -36,29 +36,43 @@ endif
|
|||||||
"
|
"
|
||||||
function! s:create(...) abort
|
function! s:create(...) abort
|
||||||
let g:___VS_Vim_Buffer_id += 1
|
let g:___VS_Vim_Buffer_id += 1
|
||||||
let l:bufnr = bufnr(printf('VS.Vim.Buffer: %s: %s',
|
let l:bufname = printf('VS.Vim.Buffer: %s: %s',
|
||||||
\ g:___VS_Vim_Buffer_id,
|
\ g:___VS_Vim_Buffer_id,
|
||||||
\ get(a:000, 0, 'VS.Vim.Buffer.Default')
|
\ get(a:000, 0, 'VS.Vim.Buffer.Default')
|
||||||
\ ), v:true)
|
\ )
|
||||||
call s:load(l:bufnr)
|
return s:load(l:bufname)
|
||||||
return l:bufnr
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
" ensure
|
||||||
|
"
|
||||||
|
function! s:ensure(expr) abort
|
||||||
|
if !bufexists(a:expr)
|
||||||
|
if type(a:expr) == type(0)
|
||||||
|
throw printf('VS.Vim.Buffer: `%s` is not valid expr.', l:bufnr)
|
||||||
|
else
|
||||||
|
badd `=a:expr`
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
return bufnr(a:expr)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
"
|
"
|
||||||
" load
|
" load
|
||||||
"
|
"
|
||||||
if exists('*bufload')
|
if exists('*bufload')
|
||||||
function! s:load(bufnr_or_path) abort
|
function! s:load(expr) abort
|
||||||
let l:bufnr = bufnr(a:bufnr_or_path, v:true)
|
let l:bufnr = s:ensure(a:expr)
|
||||||
silent call bufload(l:bufnr)
|
if !bufloaded(l:bufnr)
|
||||||
|
call bufload(l:bufnr)
|
||||||
|
endif
|
||||||
return l:bufnr
|
return l:bufnr
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:load(bufnr_or_path) abort
|
function! s:load(expr) abort
|
||||||
let l:curr_bufnr = bufnr('%')
|
let l:curr_bufnr = bufnr('%')
|
||||||
|
|
||||||
try
|
try
|
||||||
let l:bufnr = bufnr(a:bufnr_or_path, v:true)
|
let l:bufnr = s:ensure(a:expr)
|
||||||
execute printf('keepalt keepjumps silent %sbuffer', l:bufnr)
|
execute printf('keepalt keepjumps silent %sbuffer', l:bufnr)
|
||||||
catch /.*/
|
catch /.*/
|
||||||
echomsg string({ 'exception': v:exception, 'throwpoint': v:throwpoint })
|
echomsg string({ 'exception': v:exception, 'throwpoint': v:throwpoint })
|
||||||
@@ -89,3 +103,25 @@ function! s:do(bufnr, func) abort
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
"
|
||||||
|
" pseudo
|
||||||
|
"
|
||||||
|
function! s:pseudo(filepath) abort
|
||||||
|
if !filereadable(a:filepath)
|
||||||
|
throw printf('VS.Vim.Buffer: `%s` is not valid filepath.', a:filepath)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" create pseudo buffer
|
||||||
|
let l:bufname = printf('VSVimBufferPseudo://%s', a:filepath)
|
||||||
|
if bufexists(l:bufname)
|
||||||
|
return s:ensure(l:bufname)
|
||||||
|
endif
|
||||||
|
|
||||||
|
let l:bufnr = s:ensure(l:bufname)
|
||||||
|
let l:group = printf('VS_Vim_Buffer_pseudo:%s', l:bufnr)
|
||||||
|
execute printf('augroup %s', l:group)
|
||||||
|
execute printf('autocmd BufReadCmd <buffer=%s> call setline(1, readfile(bufname("%")[20 : -1])) | try | filetype detect | catch /.*/ | endtry | augroup %s | autocmd! | augroup END', l:bufnr, l:group)
|
||||||
|
augroup END
|
||||||
|
return l:bufnr
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,11 @@ endif
|
|||||||
"
|
"
|
||||||
if has('nvim')
|
if has('nvim')
|
||||||
function! s:_exists(winid) abort
|
function! s:_exists(winid) abort
|
||||||
return type(a:winid) == type(0) && nvim_win_is_valid(a:winid) && nvim_win_get_number(a:winid) != -1
|
try
|
||||||
|
return type(a:winid) == type(0) && nvim_win_is_valid(a:winid) && nvim_win_get_number(a:winid) != -1
|
||||||
|
catch /.*/
|
||||||
|
return v:false
|
||||||
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
function! s:_exists(winid) abort
|
function! s:_exists(winid) abort
|
||||||
@@ -442,7 +446,11 @@ endfunction
|
|||||||
if has('nvim')
|
if has('nvim')
|
||||||
function! s:_resolve_border(style) abort
|
function! s:_resolve_border(style) abort
|
||||||
if !empty(get(a:style, 'border', v:null))
|
if !empty(get(a:style, 'border', v:null))
|
||||||
let a:style.border = ['┌', '─', '┐', '│', '┘', '─', '└', '│']
|
if &ambiwidth ==# 'single'
|
||||||
|
let a:style.border = ['┌', '─', '┐', '│', '┘', '─', '└', '│']
|
||||||
|
else
|
||||||
|
let a:style.border = ['+', '-', '+', '|', '+', '-', '+', '|']
|
||||||
|
endif
|
||||||
elseif has_key(a:style, 'border')
|
elseif has_key(a:style, 'border')
|
||||||
unlet a:style.border
|
unlet a:style.border
|
||||||
endif
|
endif
|
||||||
@@ -451,7 +459,11 @@ if has('nvim')
|
|||||||
else
|
else
|
||||||
function! s:_resolve_border(style) abort
|
function! s:_resolve_border(style) abort
|
||||||
if !empty(get(a:style, 'border', v:null))
|
if !empty(get(a:style, 'border', v:null))
|
||||||
let a:style.border = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
if &ambiwidth ==# 'single'
|
||||||
|
let a:style.border = ['─', '│', '─', '│', '┌', '┐', '┘', '└']
|
||||||
|
else
|
||||||
|
let a:style.border = ['-', '|', '-', '|', '+', '+', '+', '+']
|
||||||
|
endif
|
||||||
elseif has_key(a:style, 'border')
|
elseif has_key(a:style, 'border')
|
||||||
unlet a:style.border
|
unlet a:style.border
|
||||||
endif
|
endif
|
||||||
@@ -468,7 +480,7 @@ function! s:_init() abort
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let s:has_init = v:true
|
let s:has_init = v:true
|
||||||
augroup printf('<sfile>')
|
augroup printf('VS_Vim_Window_FloatingWindow:%s', expand('<sfile>'))
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd WinEnter * call <SID>_notify_closed()
|
autocmd WinEnter * call <SID>_notify_closed()
|
||||||
augroup END
|
augroup END
|
||||||
|
|||||||
Reference in New Issue
Block a user