summaryrefslogtreecommitdiff
path: root/lua/telescope/actions/state.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-02-22 11:30:57 -0500
committerGitHub <noreply@github.com>2021-02-22 11:30:57 -0500
commitd7c02e3b52b5a13265e071d0de2d6a989110a515 (patch)
tree165f83bac6ffbb8594f6afb53905bc7bc64a4359 /lua/telescope/actions/state.lua
parent1c5e42a6a5a6d29be8fbf8dcefb0d8da535eac9a (diff)
feat: Action improvements (#472)
* feat: replace_map * feat: Add action_set and action_state * fix: Move all actions.get_ to action_state.get_ * fix: replace all internal references of _goto_file_selection_edit * feat: add some docs * fix: lint * feat: actions.select * remove mentions and usage of goto_file_selection APIs * feat: special case attach_mappings to be overridable and defaultable * Having goto_file_selection mappings will cause a error as well as replacing deprecated goto_file_selection methodes For config and replacing use this instead: - actions.select_default - actions.select_horizonal - actions.select_vertical - actions.select_tab Only replacing: - actions.set.edit -- for replacing all select functions * adds actions.state.select_key_to_edit_key Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
Diffstat (limited to 'lua/telescope/actions/state.lua')
-rw-r--r--lua/telescope/actions/state.lua30
1 files changed, 30 insertions, 0 deletions
diff --git a/lua/telescope/actions/state.lua b/lua/telescope/actions/state.lua
new file mode 100644
index 0000000..0752171
--- /dev/null
+++ b/lua/telescope/actions/state.lua
@@ -0,0 +1,30 @@
+local global_state = require('telescope.state')
+
+local action_state = {}
+
+--- Get the current entry
+function action_state.get_selected_entry()
+ return global_state.get_global_key('selected_entry')
+end
+
+--- Gets the current line
+function action_state.get_current_line()
+ return global_state.get_global_key('current_line')
+end
+
+--- Gets the current picker
+function action_state.get_current_picker(prompt_bufnr)
+ return global_state.get_status(prompt_bufnr).picker
+end
+
+local select_to_edit_map = {
+ default = "edit",
+ horizontal = "new",
+ vertical = "vnew",
+ tab = "tabedit",
+}
+function action_state.select_key_to_edit_key(type)
+ return select_to_edit_map[type]
+end
+
+return action_state