feat: set defaults for each picker in telescope setup (#883)

This allows easier picker configuration for example:

```lua
require("telescope").setup {
  pickers = {
    buffers = {
      show_all_buffers = true,
      sort_lastused = true,
      theme = "dropdown",
      previewer = false,
      mappings = {
        i = {
          ["<c-q>"] = "smart_send_to_qflist",
        }
      }
    }
  }
}
```

This configuration will be applied when running `:Telescope buffers`
This commit is contained in:
Simon Hauser
2021-06-09 19:51:03 +02:00
committed by GitHub
parent feaed4b6e2
commit 618e0e6075
7 changed files with 202 additions and 42 deletions

View File

@@ -387,9 +387,37 @@ your desired picker by passing a lua table to the picker with all of the
options you want to use. Here's an example with the live_grep picker:
:lua require('telescope.builtin').live_grep({
prompt_title = 'find string in open buffers...',
grep_open_files = true
})
prompt_title = 'find string in open buffers...',
grep_open_files = true
})
-- or with dropdown theme
:lua require('telescope.builtin').find_files(require('telescope.themes').get_dropdown{
previewer = false
})
You can also pass default configurations to builtin pickers. These options will
also be added if the picker is executed with `Telescope find_files`.
require("telescope").setup {
pickers = {
buffers = {
show_all_buffers = true,
sort_lastused = true,
theme = "dropdown",
previewer = false,
mappings = {
i = {
["<c-d>"] = require("telescope.actions").delete_buffer,
-- or right hand side can also be a the name of the action as string
["<c-d>"] = "delete_buffer",
},
n = {
["<c-d>"] = require("telescope.actions").delete_buffer,
}
}
}
}
}
This will use the default configuration options. Other configuration options
are still in flux at the moment