Skip to content

Commit 0c8206c

Browse files
Uzaaftazdanov
andauthored
fix(picker-lsp-mappings): Swap order of if-else branches to prefer sna… (#1455)
fix(picker-lsp-mapping): Swap order of if-else branches to prefer snacks.nvim over telescope Co-authored-by: Anton Ždanov <[email protected]>
1 parent 4a24886 commit 0c8206c

File tree

1 file changed

+28
-28
lines changed
  • lua/astrocommunity/recipes/picker-lsp-mappings

1 file changed

+28
-28
lines changed

lua/astrocommunity/recipes/picker-lsp-mappings/init.lua

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,7 @@ return {
22
"AstroNvim/astrolsp",
33
---@param opts AstroLSPOpts
44
opts = function(_, opts)
5-
if require("astrocore").is_available "telescope.nvim" then
6-
if opts.mappings.n.gd then
7-
opts.mappings.n.gd[1] = function() require("telescope.builtin").lsp_definitions { reuse_win = true } end
8-
end
9-
if opts.mappings.n.gI then
10-
opts.mappings.n.gI[1] = function() require("telescope.builtin").lsp_implementations { reuse_win = true } end
11-
end
12-
if opts.mappings.n.gy then
13-
opts.mappings.n.gy[1] = function() require("telescope.builtin").lsp_type_definitions { reuse_win = true } end
14-
end
15-
if opts.mappings.n["<Leader>lG"] then
16-
opts.mappings.n["<Leader>lG"][1] = function()
17-
vim.ui.input({ prompt = "Symbol Query: (leave empty for word under cursor)" }, function(query)
18-
if query then
19-
-- word under cursor if given query is empty
20-
if query == "" then query = vim.fn.expand "<cword>" end
21-
require("telescope.builtin").lsp_workspace_symbols {
22-
query = query,
23-
prompt_title = ("Find word (%s)"):format(query),
24-
}
25-
end
26-
end)
27-
end
28-
end
29-
if opts.mappings.n["<Leader>lR"] then
30-
opts.mappings.n["<Leader>lR"][1] = function() require("telescope.builtin").lsp_references() end
31-
end
32-
elseif require("astrocore").is_available "snacks.nvim" then
5+
if require("astrocore").is_available "snacks.nvim" then
336
opts.mappings.n.grr = {
347
function() require("snacks.picker").lsp_references() end,
358
desc = "LSP References",
@@ -58,6 +31,33 @@ return {
5831
if opts.mappings.n["<Leader>lR"] then
5932
opts.mappings.n["<Leader>lR"][1] = function() require("snacks.picker").lsp_references() end
6033
end
34+
elseif require("astrocore").is_available "telescope.nvim" then
35+
if opts.mappings.n.gd then
36+
opts.mappings.n.gd[1] = function() require("telescope.builtin").lsp_definitions { reuse_win = true } end
37+
end
38+
if opts.mappings.n.gI then
39+
opts.mappings.n.gI[1] = function() require("telescope.builtin").lsp_implementations { reuse_win = true } end
40+
end
41+
if opts.mappings.n.gy then
42+
opts.mappings.n.gy[1] = function() require("telescope.builtin").lsp_type_definitions { reuse_win = true } end
43+
end
44+
if opts.mappings.n["<Leader>lG"] then
45+
opts.mappings.n["<Leader>lG"][1] = function()
46+
vim.ui.input({ prompt = "Symbol Query: (leave empty for word under cursor)" }, function(query)
47+
if query then
48+
-- word under cursor if given query is empty
49+
if query == "" then query = vim.fn.expand "<cword>" end
50+
require("telescope.builtin").lsp_workspace_symbols {
51+
query = query,
52+
prompt_title = ("Find word (%s)"):format(query),
53+
}
54+
end
55+
end)
56+
end
57+
end
58+
if opts.mappings.n["<Leader>lR"] then
59+
opts.mappings.n["<Leader>lR"][1] = function() require("telescope.builtin").lsp_references() end
60+
end
6161
end
6262
end,
6363
}

0 commit comments

Comments
 (0)