An extension for Telescope that registers handlers for
textDocument/declarationtextDocument/definitiontextDocument/implementationtextDocument/typeDefinitiontextDocument/referencestextDocument/documentSymbolworkspace/symbolcallHierarchy/incomingCallscallHierarchy/outgoingCallstextDocument/codeAction
- I wanted to learn how to extend Telescope
- I wanted to learn how to extend Neovim's built-in LSP handlers
- I wanted to use
vim.lsp.buf.*commands instead ofTelescope lsp_*ones so I wouldn't need to rely on Telescope replicating utility functions that are already part of Neovim's built-in LSP - Telescope's built-in LSP functions do not push items to the tagstack when picked manually, these handlers do
Install this plugin with your favorite package manager and then load it with Telescope:
telescope.load_extension('lsp_handlers')Then proceed to use the built-in API for supported requests.
It is possible to customize handlers in Telescope's setup phase. The following configuration is the default one:
telescope.setup({
extensions = {
lsp_handlers = {
disable = {},
location = {
telescope = {},
no_results_message = 'No references found',
},
symbol = {
telescope = {},
no_results_message = 'No symbols found',
},
call_hierarchy = {
telescope = {},
no_results_message = 'No calls found',
},
code_action = {
telescope = {},
no_results_message = 'No code actions available',
prefix = '',
},
},
}
})I personally like to have the following settings, which gives me a cute dropdown for code actions:
telescope.setup({
extensions = {
lsp_handlers = {
code_action = {
telescope = require('telescope.themes').get_dropdown({}),
},
},
},
}telescope.setup({
extensions = {
lsp_handlers = {
disable = {
['textDocument/codeAction'] = true,
},
},
},
}