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_references = require('telescope.builtin.lsp').references
|
||||||
builtin.lsp_definitions = require('telescope.builtin.lsp').definitions
|
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_document_symbols = require('telescope.builtin.lsp').document_symbols
|
||||||
builtin.lsp_code_actions = require('telescope.builtin.lsp').code_actions
|
builtin.lsp_code_actions = require('telescope.builtin.lsp').code_actions
|
||||||
builtin.lsp_document_diagnostics = require('telescope.builtin.lsp').diagnostics
|
builtin.lsp_document_diagnostics = require('telescope.builtin.lsp').diagnostics
|
||||||
|
|||||||
@@ -41,11 +41,11 @@ lsp.references = function(opts)
|
|||||||
}):find()
|
}):find()
|
||||||
end
|
end
|
||||||
|
|
||||||
lsp.definitions = function(opts)
|
local function list_or_jump(action, title, opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
|
|
||||||
local params = vim.lsp.util.make_position_params()
|
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 = {}
|
local flattened_results = {}
|
||||||
for _, server_results in pairs(result) do
|
for _, server_results in pairs(result) do
|
||||||
if server_results.result then
|
if server_results.result then
|
||||||
@@ -60,7 +60,7 @@ lsp.definitions = function(opts)
|
|||||||
else
|
else
|
||||||
local locations = vim.lsp.util.locations_to_items(flattened_results)
|
local locations = vim.lsp.util.locations_to_items(flattened_results)
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt_title = 'LSP Definitions',
|
prompt_title = title,
|
||||||
finder = finders.new_table {
|
finder = finders.new_table {
|
||||||
results = locations,
|
results = locations,
|
||||||
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
entry_maker = opts.entry_maker or make_entry.gen_from_quickfix(opts),
|
||||||
@@ -71,6 +71,14 @@ lsp.definitions = function(opts)
|
|||||||
end
|
end
|
||||||
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)
|
lsp.document_symbols = function(opts)
|
||||||
local params = vim.lsp.util.make_position_params()
|
local params = vim.lsp.util.make_position_params()
|
||||||
local results_lsp = vim.lsp.buf_request_sync(0, "textDocument/documentSymbol", params, opts.timeout or 10000)
|
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",
|
["document_symbols"] = "document_symbol",
|
||||||
["references"] = "find_references",
|
["references"] = "find_references",
|
||||||
["definitions"] = "goto_definition",
|
["definitions"] = "goto_definition",
|
||||||
|
["implementations"] = "implementation",
|
||||||
["workspace_symbols"] = "workspace_symbol",
|
["workspace_symbols"] = "workspace_symbol",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user