summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2020-10-30 18:36:34 -0400
committerTJ DeVries <devries.timothyj@gmail.com>2020-10-30 18:36:34 -0400
commit37c4f1b355d843e95ba41f2a73d83de58fb74dae (patch)
tree1a7af5e06e3a0ab2530bb729a3552387f516e049
parenta37e4699c42284c819f8487afacf55e5d0c8cccf (diff)
fix: Update documentation about setting custom maps for a picker
-rw-r--r--README.md20
1 files changed, 18 insertions, 2 deletions
diff --git a/README.md b/README.md
index 4a3580d..45a505d 100644
--- a/README.md
+++ b/README.md
@@ -184,8 +184,6 @@ To see the full list of mappings, check out `lua/telescope/mappings.lua` and the
To override ALL of the default mappings, you can use the `default_mappings` key in the `setup` table.
-To override only SOME of the default mappings, you can use the `mappings` key in the `setup` table.
-
```
To disable a keymap, put [map] = false
@@ -226,6 +224,24 @@ require('telescope').setup {
}
```
+To override only SOME of the default mappings, you can use the `attach_mappings` key in the `setup` table. For example:
+
+```lua
+function my_custom_picker(results)
+ pickers.new(opts, {
+ prompt_title = 'Custom Picker',
+ finder = finders.new_table(results),
+ sorter = sorters.fuzzy_with_index_bias(),
+ attach_mappings = function(_, map)
+ -- Map "<CR>" in insert mode to the funciton, actions.set_command_line
+ map('i', '<CR>', actions.set_command_line)
+
+ return true
+ end,
+ }):find()
+end
+```
+
Additionally, the prompt's filetype will be `TelescopePrompt`. You can customize the filetype as you would normally.
## Status (Unstable API)