chore(telescope.lua): refactor key mappings and add support for trouble.nvim integration

The key mappings in the telescope.lua file have been refactored to use the new mappings syntax introduced in the latest version of Telescope. Additionally, support for the trouble.nvim plugin has been added by mapping the `<C-q>` key to the `trouble.open_with_trouble` function in both insert and normal mode. This allows for easier navigation and troubleshooting within Telescope.
This commit is contained in:
David Ibia
2024-01-14 03:12:36 +01:00
parent 1305a943a1
commit 3277805e69

View File

@@ -1,11 +1,23 @@
local telescope = require("telescope") local telescope = require("telescope")
local builtin = require('telescope.builtin') local builtin = require("telescope.builtin")
local trouble = require("trouble.providers.telescope")
telescope.setup {} telescope.setup({
defaults = {
mappings = {
i = {
["<C-q>"] = trouble.open_with_trouble,
},
n = {
["<C-q>"] = trouble.open_with_trouble,
},
},
},
})
vim.keymap.set("n", '<leader>pf', builtin.find_files, { desc = "Fuzzy find files in cwd" }) vim.keymap.set("n", "<leader>pf", builtin.find_files, { desc = "Fuzzy find files in cwd" })
vim.keymap.set("n", '<leader>pr', builtin.oldfiles, { desc = "Fuzzy find recent files" }) vim.keymap.set("n", "<leader>pr", builtin.oldfiles, { desc = "Fuzzy find recent files" })
vim.keymap.set("n", '<C-p>', builtin.git_files, { desc = "Fuzzy find files in git in cwd" }) vim.keymap.set("n", "<C-p>", builtin.git_files, { desc = "Fuzzy find files in git in cwd" })
vim.keymap.set('n', '<leader>ps', function() vim.keymap.set("n", "<leader>ps", function()
builtin.grep_string({ search = vim.fn.input("Grep > ") }); builtin.grep_string({ search = vim.fn.input("Grep > ") })
end, { desc = "Find string under cursor in cwd" }) end, { desc = "Find string under cursor in cwd" })