Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Follow latest denols implmention #3007

Merged
merged 2 commits into from
Feb 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions lua/lspconfig/server_configurations/denols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ local util = require 'lspconfig.util'
local lsp = vim.lsp

local function buf_cache(bufnr, client)
local params = {}
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
params['uris'] = {}
client.request('deno/cache', params, function(err, _result, ctx)
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.referrer.uri
local uri = ctx.params.arguments[2]
vim.api.nvim_err_writeln('cache command failed for ' .. vim.uri_to_fname(uri))
end
end, bufnr)
Expand Down Expand Up @@ -90,24 +91,14 @@ return {
['textDocument/definition'] = denols_handler,
['textDocument/typeDefinition'] = denols_handler,
['textDocument/references'] = denols_handler,
['workspace/executeCommand'] = function(err, result, context, config)
if context.params.command == 'deno.cache' then
buf_cache(context.bufnr, vim.lsp.get_client_by_id(context.client_id))
else
lsp.handlers[context.method](err, result, context, config)
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_active_clients { name = 'denols' }
if #clients > 0 then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think there should find out the client which current buffer attached.

buf_cache(0, clients[#clients])
end
end,
description = 'Cache a module and all of its dependencies.',
Expand Down
Loading