Only add telescope lsp mappings if available

This commit is contained in:
ViViDboarder 2022-01-24 15:39:02 -08:00
parent da77afdfb3
commit 58f049382e

View File

@ -144,13 +144,17 @@ local function get_default_attach(override_capabilities)
-- Some override some fuzzy finder bindings to use lsp sources -- Some override some fuzzy finder bindings to use lsp sources
if utils.try_require("telescope") ~= nil then if utils.try_require("telescope") ~= nil then
-- Replace some Telescope bindings with LSP versions -- Replace some Telescope bindings with LSP versions
if client.resolved_capabilities.goto_definition then
buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts) buf_set_keymap("n", "<leader>t", "<cmd>Telescope lsp_document_symbols<CR>", opts)
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts)
buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts) buf_set_keymap("n", "<leader>ft", "<cmd>Telescope lsp_dynamic_workspace_symbols<CR>", opts)
end
-- Replace some LSP bindings with Telescope ones -- Replace some LSP bindings with Telescope ones
if client.resolved_capabilities.goto_definition then
lsp_keymap("d", "<cmd>Telescope lsp_definitions<CR>") lsp_keymap("d", "<cmd>Telescope lsp_definitions<CR>")
lsp_keymap("t", "<cmd>Telescope lsp_type_definition()<CR>") lsp_keymap("t", "<cmd>Telescope lsp_type_definition()<CR>")
end
lsp_keymap("i", "<cmd>Telescope lsp_implementations<CR>") lsp_keymap("i", "<cmd>Telescope lsp_implementations<CR>")
lsp_keymap("r", "<cmd>Telescope lsp_references<CR>") lsp_keymap("r", "<cmd>Telescope lsp_references<CR>")
lsp_keymap("A", "<cmd>Telescope lsp_code_actions<CR>") lsp_keymap("A", "<cmd>Telescope lsp_code_actions<CR>")