nvim: lsp-utils: Update Deno configuration
This commit is contained in:
parent
218eff222e
commit
3f42d117b6
1 changed files with 18 additions and 23 deletions
|
@ -4,10 +4,17 @@ local M = {}
|
||||||
--
|
--
|
||||||
-- Deno specific functions
|
-- Deno specific functions
|
||||||
local buf_cache = function(bufnr, client)
|
local buf_cache = function(bufnr, client)
|
||||||
local params = {}
|
local params = {
|
||||||
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
|
command = 'deno.cache',
|
||||||
params['uris'] = {}
|
arguments = { {}, vim.uri_from_bufnr(bufnr) },
|
||||||
client.request_sync('deno/cache', params)
|
}
|
||||||
|
client.request('workspace/executeCommand', params, function(err, _result, ctx)
|
||||||
|
if err then
|
||||||
|
local uri = ctx.params.arguments[2]
|
||||||
|
vim.api.nvim_err_writeln('Cache command failed for ' .. vim.uri_to_fname(uri))
|
||||||
|
end
|
||||||
|
end, bufnr)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local virtual_text_document_handler = function(uri, res, client)
|
local virtual_text_document_handler = function(uri, res, client)
|
||||||
|
@ -25,9 +32,9 @@ local virtual_text_document_handler = function(uri, res, client)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
|
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
|
||||||
|
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'readonly' , true)
|
vim.api.nvim_set_option_value('readonly' , true, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modified' , false)
|
vim.api.nvim_set_option_value('modified' , false, { buf = bufnr })
|
||||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||||
|
|
||||||
vim.lsp.buf_attach_client(bufnr, client.id)
|
vim.lsp.buf_attach_client(bufnr, client.id)
|
||||||
end
|
end
|
||||||
|
@ -127,8 +134,6 @@ function M.deno_config()
|
||||||
imports = {
|
imports = {
|
||||||
hosts = {
|
hosts = {
|
||||||
['https://deno.land'] = true,
|
['https://deno.land'] = true,
|
||||||
['https://crux.land'] = true,
|
|
||||||
['https://x.nest.land'] = true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -138,23 +143,13 @@ function M.deno_config()
|
||||||
['textDocument/definition'] = denols_handler,
|
['textDocument/definition'] = denols_handler,
|
||||||
['textDocument/typeDefinition'] = denols_handler,
|
['textDocument/typeDefinition'] = denols_handler,
|
||||||
['textDocument/references'] = denols_handler,
|
['textDocument/references'] = denols_handler,
|
||||||
['workspace/executeCommand'] = function(err, result, context)
|
|
||||||
if context.params.command == 'deno.cache' then
|
|
||||||
buf_cache(context.bufnr, vim.lsp.get_client_by_id(context.client_id))
|
|
||||||
else
|
|
||||||
vim.lsp.handlers[context.method](err, result, context)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
commands = {
|
commands = {
|
||||||
DenolsCache = {
|
DenolsCache = {
|
||||||
function()
|
function()
|
||||||
local clients = vim.lsp.get_active_clients()
|
local clients = vim.lsp.get_clients({ bufnr = 0, name = 'denols' })
|
||||||
for _, client in ipairs(clients) do
|
if #clients > 0 then
|
||||||
if client.name == 'denols' then
|
buf_cache(0, clients[#clients])
|
||||||
buf_cache(0, client)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
description = 'Cache a module and all of its dependencies.',
|
description = 'Cache a module and all of its dependencies.',
|
||||||
|
|
Loading…
Reference in a new issue