summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRodrigodd <51273772+Rodrigodd@users.noreply.github.com>2021-09-12 06:36:28 -0300
committerGitHub <noreply@github.com>2021-09-12 11:36:28 +0200
commitd022ccaf1137fda5b6c4f09e224fd187f54324ba (patch)
tree3a08ef05a1d54838ef57d7a58b7a0d5e175b58ab
parent9d847e79046abb2f365a584be30d66957f02a1c1 (diff)
feat: lsp type definitions (#1224)
-rw-r--r--README.md25
-rw-r--r--doc/telescope.txt12
-rw-r--r--lua/telescope/builtin/init.lua6
-rw-r--r--lua/telescope/builtin/lsp.lua5
4 files changed, 36 insertions, 12 deletions
diff --git a/README.md b/README.md
index 30c1964..2b69bd5 100644
--- a/README.md
+++ b/README.md
@@ -446,18 +446,19 @@ Built-in functions. Ready to be bound to any key you like. :smile:
### Neovim LSP Pickers
-| Functions | Description |
-|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
-| `builtin.lsp_references` | Lists LSP references for word under the cursor |
-| `builtin.lsp_document_symbols` | Lists LSP document symbols in the current buffer |
-| `builtin.lsp_workspace_symbols` | Lists LSP document symbols in the current workspace |
-| `builtin.lsp_dynamic_workspace_symbols` | Dynamically Lists LSP for all workspace symbols |
-| `builtin.lsp_code_actions` | Lists any LSP actions for the word under the cursor, that can be triggered with `<cr>` |
-| `builtin.lsp_range_code_actions` | Lists any LSP actions for a given range, that can be triggered with `<cr>` |
-| `builtin.lsp_document_diagnostics` | Lists LSP diagnostics for the current buffer |
-| `builtin.lsp_workspace_diagnostics` | Lists LSP diagnostics for the current workspace if supported, otherwise searches in all open buffers |
-| `builtin.lsp_implementations` | Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope |
-| `builtin.lsp_definitions` | Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope |
+| Functions | Description |
+|---------------------------------------------|---------------------------------------------------------------------------------------------------------------------------|
+| `builtin.lsp_references` | Lists LSP references for word under the cursor |
+| `builtin.lsp_document_symbols` | Lists LSP document symbols in the current buffer |
+| `builtin.lsp_workspace_symbols` | Lists LSP document symbols in the current workspace |
+| `builtin.lsp_dynamic_workspace_symbols` | Dynamically Lists LSP for all workspace symbols |
+| `builtin.lsp_code_actions` | Lists any LSP actions for the word under the cursor, that can be triggered with `<cr>` |
+| `builtin.lsp_range_code_actions` | Lists any LSP actions for a given range, that can be triggered with `<cr>` |
+| `builtin.lsp_document_diagnostics` | Lists LSP diagnostics for the current buffer |
+| `builtin.lsp_workspace_diagnostics` | Lists LSP diagnostics for the current workspace if supported, otherwise searches in all open buffers |
+| `builtin.lsp_implementations` | Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope |
+| `builtin.lsp_definitions` | Goto the definition of the word under the cursor, if there's only one, otherwise show all options in Telescope |
+| `builtin.lsp_type_definitions` | Goto the definition of the type of the word under the cursor, if there's only one, otherwise show all options in Telescope|
#### Pre-filtering option for LSP pickers
diff --git a/doc/telescope.txt b/doc/telescope.txt
index 7ad7369..da2415b 100644
--- a/doc/telescope.txt
+++ b/doc/telescope.txt
@@ -905,6 +905,18 @@ builtin.lsp_definitions({opts}) *builtin.lsp_definitions()*
values: "tab", "split", "vsplit", "never"
+builtin.lsp_type_definitions({opts}) *builtin.lsp_type_definitions()*
+ Goto the definition of the type of the word under the cursor, if there's
+ only one, otherwise show all options in Telescope
+
+
+ Parameters: ~
+ {opts} (table) options to pass to the picker
+
+ Fields: ~
+ {jump_type} (string) how to goto definition if there is only one,
+ values: "tab", "split", "vsplit", "never"
+
builtin.lsp_implementations({opts}) *builtin.lsp_implementations()*
Goto the implementation of the word under the cursor if there's only one,
otherwise show all options in Telescope
diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua
index e790700..0f55467 100644
--- a/lua/telescope/builtin/init.lua
+++ b/lua/telescope/builtin/init.lua
@@ -355,6 +355,12 @@ builtin.lsp_references = require_on_exported_call("telescope.builtin.lsp").refer
---@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
builtin.lsp_definitions = require_on_exported_call("telescope.builtin.lsp").definitions
+--- Goto the definition of the type of the word under the cursor, if there's only one,
+--- otherwise show all options in Telescope
+---@param opts table: options to pass to the picker
+---@field jump_type string: how to goto definition if there is only one, values: "tab", "split", "vsplit", "never"
+builtin.lsp_type_definitions = require("telescope.builtin.lsp").type_definitions
+
--- Goto the implementation of the word under the cursor if there's only one, otherwise show all options in Telescope
---@param opts table: options to pass to the picker
---@field jump_type string: how to goto implementation if there is only one, values: "tab", "split", "vsplit", "never"
diff --git a/lua/telescope/builtin/lsp.lua b/lua/telescope/builtin/lsp.lua
index 056221e..e5b183e 100644
--- a/lua/telescope/builtin/lsp.lua
+++ b/lua/telescope/builtin/lsp.lua
@@ -95,6 +95,10 @@ lsp.definitions = function(opts)
return list_or_jump("textDocument/definition", "LSP Definitions", opts)
end
+lsp.type_definitions = function(opts)
+ return list_or_jump("textDocument/typeDefinition", "LSP Type Definitions", opts)
+end
+
lsp.implementations = function(opts)
return list_or_jump("textDocument/implementation", "LSP Implementations", opts)
end
@@ -403,6 +407,7 @@ local feature_map = {
["document_symbols"] = "document_symbol",
["references"] = "find_references",
["definitions"] = "goto_definition",
+ ["type_definitions"] = "type_definition",
["implementations"] = "implementation",
["workspace_symbols"] = "workspace_symbol",
}