refactor(nvim): set telescope keymaps using lua callbacks
parent
bfe282af40
commit
5ac4d1b821
|
@ -20,13 +20,28 @@ nnoremap("<leader>g", ":0Git<CR>")
|
||||||
nnoremap("<leader>G", ":GV --all<CR>")
|
nnoremap("<leader>G", ":GV --all<CR>")
|
||||||
|
|
||||||
-- telescope
|
-- telescope
|
||||||
nnoremap("<leader>ff", "<Cmd>Telescope find_files theme=dropdown<CR>")
|
local telescope = require("telescope.builtin")
|
||||||
nnoremap("<leader>fb", "<Cmd>Telescope buffers theme=dropdown<CR>")
|
local telescope_themes = require("telescope.themes")
|
||||||
nnoremap("<leader>fg", "<Cmd>Telescope git_files theme=dropdown<CR>")
|
local telescope_projects = require("telescope").extensions.projects
|
||||||
nnoremap("<leader>fp", "<Cmd>Telescope projects theme=dropdown<CR>")
|
|
||||||
nnoremap("<leader>fs", "<Cmd>Telescope lsp_dynamic_workspace_symbols theme=dropdown<CR>")
|
local function map_telescope(key, telescope_function)
|
||||||
nnoremap("<C-f>", "<Cmd>Telescope grep_string<CR>")
|
vim.api.nvim_set_keymap("n", key, "", {
|
||||||
nnoremap("<C-g>", "<Cmd>Telescope live_grep<CR>")
|
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
|
-- terminal
|
||||||
vim.api.nvim_create_autocmd("TermOpen", {
|
vim.api.nvim_create_autocmd("TermOpen", {
|
||||||
|
|
Loading…
Reference in New Issue