From 8e036d571bb0398822252da10607fcf9562e2274 Mon Sep 17 00:00:00 2001 From: Milly Date: Thu, 28 Mar 2024 18:04:32 +0900 Subject: [PATCH] use `deno.cache` and `deno.reloadImportRegistries` command Deno v1.40.3, removed `deno/cache` and `deno/reloadImportRegistries` --- settings/deno.vim | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/settings/deno.vim b/settings/deno.vim index 453595bb..fd596d69 100644 --- a/settings/deno.vim +++ b/settings/deno.vim @@ -273,37 +273,40 @@ function! s:status(in_preview, ...) abort endfunction function! s:handle_deno_cache(data) abort - if lsp#client#is_error(a:data['response']) || !has_key(a:data['response'], 'result') + if lsp#client#is_error(a:data['response']) || get(a:data['response'], 'result') != v:true redraw! - call lsp#utils#error('deno v1.7.5 or later is required to use cache') + call lsp#utils#error('deno v1.32.2 or later is required to use cache') return endif - if a:data['response']['result'] == v:true - " Cache file would be enabled after reload buffer. - let l:curpos = getcurpos() - execute 'edit ' . expand('%:p') - call setpos('.', l:curpos) - echo 'Cache file installed' - endif + " Cache file would be enabled after reload buffer. + let l:curpos = getcurpos() + execute 'edit ' . expand('%:p') + call setpos('.', l:curpos) + echo 'Cache file installed' endfunction function! s:handle_reload_import_registries(data) abort - if a:data['response']['result'] == v:true - echo 'Import registries reloaded' + if lsp#client#is_error(a:data['response']) || get(a:data['response'], 'result') != v:true + redraw! + call lsp#utils#error('deno v1.37.0 or later is required to use import registries') + return endif + echo 'Import registries reloaded' endfunction function! s:cache() abort let l:is_download_cache = input('Download all cache files?(y/n) ', 'y') if l:is_download_cache =~# 'y' + let l:specifiers = [] + let l:referrer = lsp#utils#get_buffer_uri() call lsp#send_request('deno', { - \ 'method': 'deno/cache', - \ 'params': { - \ 'referrer': lsp#get_text_document_identifier(), - \ 'uris': [], - \ }, - \ 'on_notification': function('s:handle_deno_cache', []) - \ }) + \ 'method': 'workspace/executeCommand', + \ 'params': { + \ 'command': 'deno.cache', + \ 'arguments': [l:specifiers, l:referrer], + \ }, + \ 'on_notification': function('s:handle_deno_cache', []) + \ }) endif endfunction @@ -311,10 +314,9 @@ function! s:reload_import_registries() abort let l:is_download_cache = input('Do you reload import registries?(y/n) ', 'y') if l:is_download_cache =~# 'y' call lsp#send_request('deno', { - \ 'method': 'deno/reloadImportRegistries', + \ 'method': 'workspace/executeCommand', \ 'params': { - \ 'referrer': lsp#get_text_document_identifier(), - \ 'uris': [], + \ 'command': 'deno.reloadImportRegistries', \ }, \ 'on_notification': function('s:handle_reload_import_registries', []) \ })