Skip to content

Commit a9be5f0

Browse files
committed
fix(mappings): change telescope lsp mappings to enabling
1 parent 838f056 commit a9be5f0

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

src/content/docs/recipes/mappings.mdx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,32 +70,46 @@ return {
7070
}
7171
```
7272

73-
### Disable Telescope LSP Mappings
73+
### Enable Telescope LSP Mappings
7474

75-
We use Telescope for some of the LSP mappings, but this can be easily disabled through AstroLSP. Here is an example specification that can be added to your plugins:
75+
Telescope proivdes functionality for using the picker for tasks such as getting references and symbols. This can be easily enabled through AstroLSP. Here is an example specification that can be added to your plugins:
7676

77-
```lua title="lua/plugins/astrolsp.lua"
77+
```lua title="lua/plugins/telescope_lsp_mappings.lua"
7878
return {
7979
"AstroNvim/astrolsp",
8080
---@param opts AstroLSPOpts
8181
opts = function(_, opts)
8282
opts.mappings.n.gd[1] = function()
83-
vim.lsp.buf.definition()
83+
require("telescope.builtin").lsp_definitions({ reuse_win = true })
8484
end
8585
opts.mappings.n.gI[1] = function()
86-
vim.lsp.buf.implementation()
86+
require("telescope.builtin").lsp_implementations({ reuse_win = true })
8787
end
8888
opts.mappings.n.gr[1] = function()
89-
vim.lsp.buf.references()
89+
require("telescope.builtin").lsp_references()
9090
end
9191
opts.mappings.n.gy[1] = function()
92-
vim.lsp.buf.type_definition()
92+
require("telescope.builtin").lsp_type_definitions({ reuse_win = true })
9393
end
9494
opts.mappings.n["<Leader>lG"][1] = function()
95-
vim.lsp.buf.workspace_symbol()
95+
vim.ui.input(
96+
{ prompt = "Symbol Query: (leave empty for word under cursor)" },
97+
function(query)
98+
if query then
99+
-- word under cursor if given query is empty
100+
if query == "" then
101+
query = vim.fn.expand("<cword>")
102+
end
103+
require("telescope.builtin").lsp_workspace_symbols({
104+
query = query,
105+
prompt_title = ("Find word (%s)"):format(query),
106+
})
107+
end
108+
end
109+
)
96110
end
97111
opts.mappings.n["<Leader>lR"][1] = function()
98-
vim.lsp.buf.references()
112+
require("telescope.builtin").lsp_references()
99113
end
100114
end,
101115
}

0 commit comments

Comments
 (0)