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
|
||||
local buf_cache = function(bufnr, client)
|
||||
local params = {}
|
||||
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
|
||||
params['uris'] = {}
|
||||
client.request_sync('deno/cache', params)
|
||||
local params = {
|
||||
command = 'deno.cache',
|
||||
arguments = { {}, vim.uri_from_bufnr(bufnr) },
|
||||
}
|
||||
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
|
||||
|
||||
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_option(bufnr, 'readonly' , true)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'modified' , false)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
||||
vim.api.nvim_set_option_value('readonly' , true, { buf = bufnr })
|
||||
vim.api.nvim_set_option_value('modified' , false, { buf = bufnr })
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = bufnr })
|
||||
|
||||
vim.lsp.buf_attach_client(bufnr, client.id)
|
||||
end
|
||||
|
@ -127,8 +134,6 @@ function M.deno_config()
|
|||
imports = {
|
||||
hosts = {
|
||||
['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/typeDefinition'] = 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 = {
|
||||
DenolsCache = {
|
||||
function()
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
for _, client in ipairs(clients) do
|
||||
if client.name == 'denols' then
|
||||
buf_cache(0, client)
|
||||
break
|
||||
end
|
||||
local clients = vim.lsp.get_clients({ bufnr = 0, name = 'denols' })
|
||||
if #clients > 0 then
|
||||
buf_cache(0, clients[#clients])
|
||||
end
|
||||
end,
|
||||
description = 'Cache a module and all of its dependencies.',
|
||||
|
|
Loading…
Reference in a new issue