Skip to content

Commit 698e88e

Browse files
committed
fix(mappings): fix incorrect telescope lsp mappings code
1 parent c5a9246 commit 698e88e

File tree

1 file changed

+32
-25
lines changed

1 file changed

+32
-25
lines changed

src/content/docs/recipes/mappings.mdx

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,37 +92,44 @@ return {
9292
"AstroNvim/astrolsp",
9393
---@param opts AstroLSPOpts
9494
opts = function(_, opts)
95-
opts.mappings.n.gd[1] = function()
96-
require("telescope.builtin").lsp_definitions({ reuse_win = true })
95+
if opts.mappings.n.gd then
96+
opts.mappings.n.gd[1] = function()
97+
require("telescope.builtin").lsp_definitions({ reuse_win = true })
98+
end
9799
end
98-
opts.mappings.n.gI[1] = function()
99-
require("telescope.builtin").lsp_implementations({ reuse_win = true })
100+
if opts.mappings.n.gI then
101+
opts.mappings.n.gI[1] = function()
102+
require("telescope.builtin").lsp_implementations({ reuse_win = true })
103+
end
100104
end
101-
opts.mappings.n.gr[1] = function()
102-
require("telescope.builtin").lsp_references()
105+
if opts.mappings.n.gy then
106+
opts.mappings.n.gy[1] = function()
107+
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
108+
end
103109
end
104-
opts.mappings.n.gy[1] = function()
105-
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
106-
end
107-
opts.mappings.n["<Leader>lG"][1] = function()
108-
vim.ui.input(
109-
{ prompt = "Symbol Query: (leave empty for word under cursor)" },
110-
function(query)
111-
if query then
112-
-- word under cursor if given query is empty
113-
if query == "" then
114-
query = vim.fn.expand("<cword>")
110+
if opts.mappings.n["<Leader>lG"] then
111+
opts.mappings.n["<Leader>lG"][1] = function()
112+
vim.ui.input(
113+
{ prompt = "Symbol Query: (leave empty for word under cursor)" },
114+
function(query)
115+
if query then
116+
-- word under cursor if given query is empty
117+
if query == "" then
118+
query = vim.fn.expand("<cword>")
119+
end
120+
require("telescope.builtin").lsp_workspace_symbols({
121+
query = query,
122+
prompt_title = ("Find word (%s)"):format(query),
123+
})
115124
end
116-
require("telescope.builtin").lsp_workspace_symbols({
117-
query = query,
118-
prompt_title = ("Find word (%s)"):format(query),
119-
})
120125
end
121-
end
122-
)
126+
)
127+
end
123128
end
124-
opts.mappings.n["<Leader>lR"][1] = function()
125-
require("telescope.builtin").lsp_references()
129+
if opts.mappings.n["<Leader>lR"] then
130+
opts.mappings.n["<Leader>lR"][1] = function()
131+
require("telescope.builtin").lsp_references()
132+
end
126133
end
127134
end,
128135
}

0 commit comments

Comments
 (0)