X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/5a4872f466ebd76ddd532bdf2798554421c53df4..fe3919e725e156d751069662d11e38f7b4791de1:/.vim/bundle/vim-lsp/autoload/lsp/utils/workspace_edit.vim diff --git a/.vim/bundle/vim-lsp/autoload/lsp/utils/workspace_edit.vim b/.vim/bundle/vim-lsp/autoload/lsp/utils/workspace_edit.vim new file mode 100644 index 00000000..5dafd26c --- /dev/null +++ b/.vim/bundle/vim-lsp/autoload/lsp/utils/workspace_edit.vim @@ -0,0 +1,27 @@ +" Applies WorkspaceEdit changes. +function! lsp#utils#workspace_edit#apply_workspace_edit(workspace_edit) abort + let l:loclist_items = [] + + if has_key(a:workspace_edit, 'documentChanges') + for l:text_document_edit in a:workspace_edit['documentChanges'] + let l:loclist_items += s:_apply(l:text_document_edit['textDocument']['uri'], l:text_document_edit['edits']) + endfor + elseif has_key(a:workspace_edit, 'changes') + for [l:uri, l:text_edits] in items(a:workspace_edit['changes']) + let l:loclist_items += s:_apply(l:uri, l:text_edits) + endfor + endif + + if g:lsp_show_workspace_edits + call setloclist(0, l:loclist_items, 'r') + execute 'lopen' + endif +endfunction + +" +" _apply +" +function! s:_apply(uri, text_edits) abort + call lsp#utils#text_edit#apply_text_edits(a:uri, a:text_edits) + return lsp#utils#text_edit#_lsp_to_vim_list(a:uri, a:text_edits) +endfunction