lsp: Implement lsp.implementations similar to lsp.definitions (#743)
Fixes #730
This commit is contained in:
committed by
GitHub
parent
f92b9b1fae
commit
13dae8c4d9
@@ -65,6 +65,7 @@ builtin.tagstack = require('telescope.builtin.internal').tagstack
|
||||
|
||||
builtin.lsp_references = require('telescope.builtin.lsp').references
|
||||
builtin.lsp_definitions = require('telescope.builtin.lsp').definitions
|
||||
builtin.lsp_implementations = require('telescope.builtin.lsp').implementations
|
||||
builtin.lsp_document_symbols = require('telescope.builtin.lsp').document_symbols
|
||||
builtin.lsp_code_actions = require('telescope.builtin.lsp').code_actions
|
||||
builtin.lsp_document_diagnostics = require('telescope.builtin.lsp').diagnostics
|
||||
|
||||
@@ -41,11 +41,11 @@ lsp.references = function(opts)
|
||||
}):find()
|
||||
end
|
||||
|
||||
lsp.definitions = function(opts)
|
||||
local function list_or_jump(action, title, opts)
|
||||
opts = opts or {}
|
||||
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
local result = vim.lsp.buf_request_sync(0, "textDocument/definition", params, opts.timeout or 10000)
|
||||
local result = vim.lsp.buf_request_sync(0, action, params, opts.timeout or 10000)
|
||||
local flattened_results = {}
|
||||
for _, server_results in pairs(result) do
|
||||
if server_results.result then
|
||||
@@ -60,7 +60,7 @@ lsp.definitions = function(opts)
|
||||
else
|
||||
local locations = vim.lsp.util.locations_to_items(flattened_results)
|
||||
pickers.new(opts, {
|
||||
prompt_title = 'LSP Definitions',
|
||||
prompt_title = title,
|
||||
finder = finders.new_table {
|
||||
results = locations,
|
||||
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
||||
@@ -71,6 +71,14 @@ lsp.definitions = function(opts)
|
||||
end
|
||||
end
|
||||
|
||||
lsp.definitions = function(opts)
|
||||
return list_or_jump("textDocument/definition", 'LSP Definitions', opts)
|
||||
end
|
||||
|
||||
lsp.implementations = function(opts)
|
||||
return list_or_jump("textDocument/implementation", 'LSP Implementations', opts)
|
||||
end
|
||||
|
||||
lsp.document_symbols = function(opts)
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
local results_lsp = vim.lsp.buf_request_sync(0, "textDocument/documentSymbol", params, opts.timeout or 10000)
|
||||
@@ -308,6 +316,7 @@ local feature_map = {
|
||||
["document_symbols"] = "document_symbol",
|
||||
["references"] = "find_references",
|
||||
["definitions"] = "goto_definition",
|
||||
["implementations"] = "implementation",
|
||||
["workspace_symbols"] = "workspace_symbol",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user