feat: Add better mapping support

This commit is contained in:
TJ DeVries
2020-08-31 00:06:33 -04:00
parent a6fe9721ac
commit 6b066cf9e8
7 changed files with 241 additions and 102 deletions

View File

@@ -1,6 +1,7 @@
local a = vim.api
local popup = require('popup')
local actions = require('telescope.actions')
local log = require('telescope.log')
local mappings = require('telescope.mappings')
local state = require('telescope.state')
@@ -16,6 +17,18 @@ local pickers = {}
local ifnil = function(x, was_nil, was_not_nil) if x == nil then return was_nil else return was_not_nil end end
local default_mappings = {
i = {
["<C-n>"] = actions.move_selection_next,
["<C-p>"] = actions.move_selection_previous,
["<CR>"] = actions.goto_file_selection,
},
n = {
["<esc>"] = actions.close,
},
}
-- Picker takes a function (`get_window_options`) that returns the configurations required for three windows:
-- prompt
-- results
@@ -325,7 +338,8 @@ function Picker:find(opts)
finder = finder,
})
mappings.set_keymap(prompt_bufnr, results_bufnr)
-- mappings.set_keymap(prompt_bufnr, results_bufnr)
mappings.apply_keymap(prompt_bufnr, opts.mappings or default_mappings)
vim.cmd [[startinsert]]
end