From 2397d9015a3369d60a8f6550412a629d7f96c7be Mon Sep 17 00:00:00 2001 From: Tom Praschan Date: Fri, 11 Jun 2021 01:23:55 -0700 Subject: [PATCH 1/2] feat(providers.lsp): Add textDocument/implementation support --- lua/trouble/providers/init.lua | 1 + lua/trouble/providers/lsp.lua | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lua/trouble/providers/init.lua b/lua/trouble/providers/init.lua index 99543e35..cdc3cb99 100644 --- a/lua/trouble/providers/init.lua +++ b/lua/trouble/providers/init.lua @@ -9,6 +9,7 @@ M.providers = { lsp_workspace_diagnostics = lsp.diagnostics, lsp_document_diagnostics = lsp.diagnostics, lsp_references = lsp.references, + lsp_implementations = lsp.implementations, lsp_definitions = lsp.definitions, quickfix = qf.qflist, loclist = qf.loclist, diff --git a/lua/trouble/providers/lsp.lua b/lua/trouble/providers/lsp.lua index 2e7f5efe..4be258af 100644 --- a/lua/trouble/providers/lsp.lua +++ b/lua/trouble/providers/lsp.lua @@ -34,6 +34,24 @@ function M.references(win, buf, cb, _options) end) end +---@return Item[] +function M.implementations(win, buf, cb, _options) + local method = "textDocument/implementation" + local params = util.make_position_params(win, buf) + params.context = { includeDeclaration = true } + lsp.buf_request(buf, method, params, function(err, _method, result, _client_id, _bufnr, _config) + if err then + util.error("an error happened getting implementation: " .. err) + return cb({}) + end + if result == nil or #result == 0 then + return cb({}) + end + local ret = util.locations_to_items({ result }, 0) + cb(ret) + end) +end + ---@return Item[] function M.definitions(win, buf, cb, _options) local method = "textDocument/definition" From f37af0708707cf0e23c4544847074034387849ff Mon Sep 17 00:00:00 2001 From: Tom Praschan Date: Fri, 11 Jun 2021 01:25:31 -0700 Subject: [PATCH 2/2] Update README.md for LSP lists --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 929f0508..288feddd 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ A pretty list for showing diagnostics, references, telescope results, quickfix a * pretty list of: - LSP Diagnostics - LSP references + - LSP implementations + - LSP definitions - quickfix list - location list - [Telescope](https://github.com/nvim-telescope/telescope.nvim) search results