feat: Actions can now be summed up and center action (#204)
Closes: #182 * Actions can now be summed up and center action * fix: Make some complicated changes for metatable * Update documentation Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
This commit is contained in:
49
README.md
49
README.md
@@ -184,23 +184,28 @@ 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 disable a keymap, put [map] = false
|
||||
```lua
|
||||
-- To disable a keymap, put [map] = false
|
||||
-- So, to not map "<C-n>", just put
|
||||
["<C-n>"] = false,
|
||||
-- Into your config.
|
||||
|
||||
So, to not map "<C-n>", just put
|
||||
-- Otherwise, just set the mapping to the function that you want it to be.
|
||||
["<C-i>"] = actions.goto_file_selection_split,
|
||||
|
||||
...,
|
||||
["<C-n>"] = false,
|
||||
...,
|
||||
|
||||
Into your config.
|
||||
|
||||
Otherwise, just set the mapping to the function that you want it to be.
|
||||
|
||||
...,
|
||||
["<C-i>"] = actions.goto_file_selection_split
|
||||
...,
|
||||
-- You can also define your own functions, which then can be mapped to a key
|
||||
local function test_action(prompt_bufnr)
|
||||
print("Action was attached with prompt_bufnr: ", prompt_bufnr)
|
||||
-- Enter your function logic here. You can take inspiration from lua/telescope/actions.lua
|
||||
end
|
||||
["<C-i>"] = test_action,
|
||||
|
||||
-- If you want your function to run after another action you should define it as follows
|
||||
local test_action = actions._transform_action(function(prompt_bufnr)
|
||||
print("This function ran after another action. Prompt_bufnr: " .. prompt_bufnr)
|
||||
-- Enter your function logic here. You can take inspiration from lua/telescope/actions.lua
|
||||
end)
|
||||
["<C-i>"] = actions.goto_file_selection_split + test_action
|
||||
|
||||
```
|
||||
|
||||
@@ -209,6 +214,12 @@ A full example:
|
||||
```lua
|
||||
local actions = require('telescope.actions')
|
||||
|
||||
-- If you want your function to run after another action you should define it as follows
|
||||
local test_action = actions._transform_action(function(prompt_bufnr)
|
||||
print("This function ran after another action. Prompt_bufnr: " .. prompt_bufnr)
|
||||
-- Enter your function logic here. You can take inspiration from lua/telescope/actions.lua
|
||||
end)
|
||||
|
||||
require('telescope').setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
@@ -218,6 +229,12 @@ require('telescope').setup {
|
||||
|
||||
-- Create a new <c-s> mapping
|
||||
["<c-s>"] = actions.goto_file_selection_split,
|
||||
|
||||
-- Add up multiple actions
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center,
|
||||
|
||||
-- You can perform as many actions in a row as you like
|
||||
["<CR>"] = actions.goto_file_selection_edit + actions.center + test_action,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -379,7 +396,7 @@ Use the telescope.
|
||||
|
||||
## Themes
|
||||
|
||||
Common groups of settings can be setup to allow for themes. We have some built in themes but are looking for more cool options.
|
||||
Common groups of settings can be setup to allow for themes. We have some built in themes but are looking for more cool options.
|
||||
|
||||
### Dropdown
|
||||
|
||||
@@ -395,7 +412,7 @@ Then you can put your configuration into `get_dropdown({})`
|
||||
nnoremap <Leader>f :lua require'telescope.builtin'.find_files(require('telescope.themes').get_dropdown({ winblend = 10 }))<cr>
|
||||
```
|
||||
|
||||
Themes should work with every `telescope.builtin` function.
|
||||
Themes should work with every `telescope.builtin` function.
|
||||
|
||||
If you wish to make theme, check out `lua/telescope/themes.lua`. If you need more features, make an issue :).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user