refactor(nvim): set telescope keymaps using lua callbacks

main
mandlm 2022-11-23 15:20:09 +01:00
parent bfe282af40
commit 5ac4d1b821
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
1 changed files with 22 additions and 7 deletions

View File

@ -20,13 +20,28 @@ nnoremap("<leader>g", ":0Git<CR>")
nnoremap("<leader>G", ":GV --all<CR>")
-- telescope
nnoremap("<leader>ff", "<Cmd>Telescope find_files theme=dropdown<CR>")
nnoremap("<leader>fb", "<Cmd>Telescope buffers theme=dropdown<CR>")
nnoremap("<leader>fg", "<Cmd>Telescope git_files theme=dropdown<CR>")
nnoremap("<leader>fp", "<Cmd>Telescope projects theme=dropdown<CR>")
nnoremap("<leader>fs", "<Cmd>Telescope lsp_dynamic_workspace_symbols theme=dropdown<CR>")
nnoremap("<C-f>", "<Cmd>Telescope grep_string<CR>")
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
local telescope = require("telescope.builtin")
local telescope_themes = require("telescope.themes")
local telescope_projects = require("telescope").extensions.projects
local function map_telescope(key, telescope_function)
vim.api.nvim_set_keymap("n", key, "", {
noremap = true,
callback = function()
local theme = telescope_themes.get_dropdown({ layout_config = { width = 0.9 } })
telescope_function(theme)
end,
})
end
map_telescope("<leader>ff", telescope.find_files)
map_telescope("<leader>fb", telescope.buffers)
map_telescope("<leader>fg", telescope.git_files)
map_telescope("<leader>fp", telescope_projects.projects)
map_telescope("<leader>fs", telescope.lsp_dynamic_workspace_symbols)
map_telescope("<C-f>", telescope.grep_string)
map_telescope("<C-g>", telescope.live_grep)
-- terminal
vim.api.nvim_create_autocmd("TermOpen", {