-
Contributing guidelines
Module(s)mini.pick Questioncsharpls-extended-lsp.nvim is a plugin which overrides
is there an easy way to make this work with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
my first attempt was this (failed)
|
Beta Was this translation helpful? Give feedback.
-
I don't use it and am not sure if I can use it on Linux. How exactly does it not work? But the basic idea of this approach looks about right and probably requires a bit more investigation about data structures. Are you sure that ...
["textDocument/definition"] = function(err, result, ctx)
if err ~= nil then error(string.format('Error code %s. %s', err.code, err.message) end
-- Process `result` into an array of items suitable for 'mini.pick'. See `:h MiniPick-source.items-common`
return MiniPick.start({ source = { items = items, names = 'Definition' } })
end,
... |
Beta Was this translation helpful? Give feedback.
-
well that was easier & at the same time, harder than I expected! local pick = require('mini.pick')
local cslsex = require('csharpls_extended')
local cslsex_utils = require("csharpls_extended.utils")
local function cslsex_handler(err, result, ctx)
local client = cslsex.get_csharpls_client()
local fetched = {}
local offset_encoding = vim.lsp.get_client_by_id(ctx.client_id).offset_encoding
local locations = cslsex.textdocument_definition_to_locations(result)
for _, loc in ipairs(locations) do
local uri = cslsex_utils.urldecode(loc.uri)
if not cslsex.is_lsp_url(uri) then
table.insert(fetched, {
path = vim.uri_to_fname(loc.uri),
lnum = loc.range.start.line + 1,
col = loc.range.start.character + 1,
-- range = loc.range,
uri = loc.uri, -- maybe use this as path i really don't have any idea
})
goto continue
end
local res, er = client.request_sync(
"csharp/metadata",
{timeout = 5000, textDocument = {uri = uri}},
10000,
0
)
if not er and res ~= nil then
local bufnr = cslsex.buf_from_metadata(res.result, client.id)
loc.uri = vim.uri_from_bufnr(bufnr)
table.insert(fetched, {
path = vim.uri_to_fname(loc.uri),
lnum = loc.range.start.line + 1,
col = loc.range.start.character + 1,
bufnr = bufnr,
uri = loc.uri,
})
end
::continue::
end
if #locations > 0 then
pick.start(({ source = { items = fetched, names = 'Definition' } }))
end
end
lspconfig['csharp_ls'].setup({
handlers = {
["textDocument/definition"] = cslsex_handler,
["textDocument/typeDefinition"] = cslsex_handler,
},
})
|
Beta Was this translation helpful? Give feedback.
well that was easier & at the same time, harder than I expected!