From 812fae1d718e276e18784a0d054b16d39ba0208c Mon Sep 17 00:00:00 2001 From: Christopher Laidler <43636691+claidler@users.noreply.github.com> Date: Tue, 16 Mar 2021 21:50:06 +0000 Subject: [PATCH] fix: related to #13 telescope-project, enter insert mode on prompt close (#637) * fix: related to #13 telescope-project, enter insert mode on prompt close * fix: related to #13 telescope-project, enter insert mode on prompt close * revert changes made in error * fix PR issue * fix: undefined variable do_close * use action_state as actions is deprecated * [docgen] Update doc/telescope.txt skip-checks: true Co-authored-by: Github Actions --- doc/telescope.txt | 294 ++++++++++++++++----------------- lua/telescope/actions/init.lua | 6 +- 2 files changed, 150 insertions(+), 150 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index b86f4c0..cd3374a 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -12,30 +12,6 @@ https://github.com/nvim-telescope/telescope.nvim :h telescope.layout :h telescope.actions -telescope.extensions() *telescope.extensions()* - Use telescope.extensions to reference any extensions within your - configuration. - While the docs currently generate this as a function, it's actually a - table. Sorry. - - - -telescope.load_extension({name}) *telescope.load_extension()* - Load an extension. - - - Parameters: ~ - {name} (string) Name of the extension - - -telescope.register_extension({mod}) *telescope.register_extension()* - Register an extension. To be used by plugin authors. - - - Parameters: ~ - {mod} (table) Module - - telescope.setup({opts}) *telescope.setup()* Setup function to be run by user. Configures the defaults, extensions and other aspects of telescope. @@ -90,6 +66,30 @@ telescope.setup({opts}) *telescope.setup()* {opts} (table) Configuration opts. Keys: defaults, extensions +telescope.register_extension({mod}) *telescope.register_extension()* + Register an extension. To be used by plugin authors. + + + Parameters: ~ + {mod} (table) Module + + +telescope.load_extension({name}) *telescope.load_extension()* + Load an extension. + + + Parameters: ~ + {name} (string) Name of the extension + + +telescope.extensions() *telescope.extensions()* + Use telescope.extensions to reference any extensions within your + configuration. + While the docs currently generate this as a function, it's actually a + table. Sorry. + + + ================================================================================ *telescope.builtin* @@ -116,22 +116,6 @@ builtin.live_grep() *builtin.live_grep()* Actions functions that are useful for people creating their own mappings. -actions.add_selection({prompt_bufnr}) *actions.add_selection()* - Add current entry to multi select - - - Parameters: ~ - {prompt_bufnr} (number) The prompt bufnr - - -actions.move_selection_better({prompt_bufnr})*actions.move_selection_better()* - Move the selection to the entry that has a better score - - - Parameters: ~ - {prompt_bufnr} (number) The prompt bufnr - - actions.move_selection_next({prompt_bufnr}) *actions.move_selection_next()* Move the selection to the next entry @@ -156,16 +140,8 @@ actions.move_selection_worse({prompt_bufnr}) *actions.move_selection_worse()* {prompt_bufnr} (number) The prompt bufnr -actions.move_to_bottom({prompt_bufnr}) *actions.move_to_bottom()* - Move to the bottom of the picker - - - Parameters: ~ - {prompt_bufnr} (number) The prompt bufnr - - -actions.move_to_middle({prompt_bufnr}) *actions.move_to_middle()* - Move to the middle of the picker +actions.move_selection_better({prompt_bufnr})*actions.move_selection_better()* + Move the selection to the entry that has a better score Parameters: ~ @@ -180,10 +156,29 @@ actions.move_to_top({prompt_bufnr}) *actions.move_to_top()* {prompt_bufnr} (number) The prompt bufnr -actions.open_qflist() *actions.open_qflist()* - Open the quickfix list +actions.move_to_middle({prompt_bufnr}) *actions.move_to_middle()* + Move to the middle of the picker + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + + +actions.move_to_bottom({prompt_bufnr}) *actions.move_to_bottom()* + Move to the bottom of the picker + + + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + + +actions.add_selection({prompt_bufnr}) *actions.add_selection()* + Add current entry to multi select + + + Parameters: ~ + {prompt_bufnr} (number) The prompt bufnr + actions.remove_selection({prompt_bufnr}) *actions.remove_selection()* Remove current entry from multi select @@ -201,6 +196,11 @@ actions.toggle_selection({prompt_bufnr}) *actions.toggle_selection()* {prompt_bufnr} (number) The prompt bufnr +actions.open_qflist() *actions.open_qflist()* + Open the quickfix list + + + ================================================================================ *telescope.previewers* @@ -257,16 +257,31 @@ previewers.Previewer() *previewers.Previewer()* -previewers.buffer_previewer_maker({filepath}, {bufnr}, {opts})*previewers.buffer_previewer_maker()* - A universal way of reading a file into a buffer previewer. It handles async - reading, cache, highlighting, displaying directories and provides a - callback which can be used, to jump to a line in the buffer. +previewers.new() *previewers.new()* + A shorthand for creating a new Previewer. The provided table will be + forwarded to `Previewer:new(...)` - Parameters: ~ - {filepath} (string) String to the filepath, will be expanded - {bufnr} (number) Where the content will be written - {opts} (table) keys: `use_ft_detect`, `bufname` and `callback` + +previewers.new_termopen_previewer() *previewers.new_termopen_previewer()* + Is a wrapper around Previewer and helps with creating a new + `termopen_previewer`. + + It requires you to specify one table entry `get_command(entry, status)`. + This `get_command` function has to return the terminal command that will be + executed for each entry. Example: get_command = function(entry, status) + return { 'bat', entry.path } end + + It's an easy way to get your first previewer going and it integrates well + with `bat` and `less`. Providing out of the box scrolling if the command + uses less. + + Furthermore, it will forward all `config.set_env` environment variables to + that terminal process. + + While this interface is a good start, it was replaced with the way more + flexible `buffer_previewer` and is now deprecated. + previewers.cat() *previewers.cat()* @@ -282,18 +297,30 @@ previewers.cat() *previewers.cat()* -previewers.display_content() *previewers.display_content()* - A deprecated way of displaying content more easily. Was written at a time, - where the buffer_previewer interface wasn't present. Nowadays it's easier - to just use this. We will keep it around for backwards compatibility - because some extensions use it. It doesn't use cache or some other clever - tricks. +previewers.vimgrep() *previewers.vimgrep()* + Provides a `termopen_previewer` which has the ability to display files at + the provided line. It has support for `bat`(prioritized) and `cat`. Each + entry has to provide either the field `path` or `filename` and a `lnum` + field in order to make this previewer work. + + The preferred way of using this previewer is like this + `require('telescope.config').values.grep_previewer` This will respect user + configuration and will use `buffer_previewers` in case it's configured that + way. -previewers.new() *previewers.new()* - A shorthand for creating a new Previewer. The provided table will be - forwarded to `Previewer:new(...)` +previewers.qflist() *previewers.qflist()* + Provides a `termopen_previewer` which has the ability to display files at + the provided line or range. It has support for `bat`(prioritized) and + `cat`. Each entry has to provide either the field `path` or `filename`, + `lnum` and a `start` and `finish` range in order to make this previewer + work. + + The preferred way of using this previewer is like this + `require('telescope.config').values.qflist_previewer` This will respect + user configuration and will use buffer previewers in case it's configured + that way. @@ -385,39 +412,16 @@ previewers.new_buffer_previewer() *previewers.new_buffer_previewer()* -previewers.new_termopen_previewer() *previewers.new_termopen_previewer()* - Is a wrapper around Previewer and helps with creating a new - `termopen_previewer`. - - It requires you to specify one table entry `get_command(entry, status)`. - This `get_command` function has to return the terminal command that will be - executed for each entry. Example: get_command = function(entry, status) - return { 'bat', entry.path } end - - It's an easy way to get your first previewer going and it integrates well - with `bat` and `less`. Providing out of the box scrolling if the command - uses less. - - Furthermore, it will forward all `config.set_env` environment variables to - that terminal process. - - While this interface is a good start, it was replaced with the way more - flexible `buffer_previewer` and is now deprecated. +previewers.buffer_previewer_maker({filepath}, {bufnr}, {opts})*previewers.buffer_previewer_maker()* + A universal way of reading a file into a buffer previewer. It handles async + reading, cache, highlighting, displaying directories and provides a + callback which can be used, to jump to a line in the buffer. - -previewers.qflist() *previewers.qflist()* - Provides a `termopen_previewer` which has the ability to display files at - the provided line or range. It has support for `bat`(prioritized) and - `cat`. Each entry has to provide either the field `path` or `filename`, - `lnum` and a `start` and `finish` range in order to make this previewer - work. - - The preferred way of using this previewer is like this - `require('telescope.config').values.qflist_previewer` This will respect - user configuration and will use buffer previewers in case it's configured - that way. - + Parameters: ~ + {filepath} (string) String to the filepath, will be expanded + {bufnr} (number) Where the content will be written + {opts} (table) keys: `use_ft_detect`, `bufname` and `callback` previewers.vim_buffer_cat() *previewers.vim_buffer_cat()* @@ -431,6 +435,18 @@ previewers.vim_buffer_cat() *previewers.vim_buffer_cat()* +previewers.vim_buffer_vimgrep() *previewers.vim_buffer_vimgrep()* + A previewer that is used to display a file and jump to the provided line. + It uses the `buffer_previewer` interface. To integrate this one into your + own picker make sure that the field `path` or `filename` and `lnum` is set + in each entry. If the latter is not present, it will default to the first + line. The preferred way of using this previewer is like this + `require('telescope.config').values.grep_previewer` This will respect user + configuration and will use `termopen_previewer` in case it's configured + that way. + + + previewers.vim_buffer_qflist() *previewers.vim_buffer_qflist()* Is the same as `vim_buffer_vimgrep` and only exist for consistency with `term_previewers`. @@ -442,28 +458,12 @@ previewers.vim_buffer_qflist() *previewers.vim_buffer_qflist()* -previewers.vim_buffer_vimgrep() *previewers.vim_buffer_vimgrep()* - A previewer that is used to display a file and jump to the provided line. - It uses the `buffer_previewer` interface. To integrate this one into your - own picker make sure that the field `path` or `filename` and `lnum` is set - in each entry. If the latter is not present, it will default to the first - line. The preferred way of using this previewer is like this - `require('telescope.config').values.grep_previewer` This will respect user - configuration and will use `termopen_previewer` in case it's configured - that way. - - - -previewers.vimgrep() *previewers.vimgrep()* - Provides a `termopen_previewer` which has the ability to display files at - the provided line. It has support for `bat`(prioritized) and `cat`. Each - entry has to provide either the field `path` or `filename` and a `lnum` - field in order to make this previewer work. - - The preferred way of using this previewer is like this - `require('telescope.config').values.grep_previewer` This will respect user - configuration and will use `buffer_previewers` in case it's configured that - way. +previewers.display_content() *previewers.display_content()* + A deprecated way of displaying content more easily. Was written at a time, + where the buffer_previewer interface wasn't present. Nowadays it's easier + to just use this. We will keep it around for backwards compatibility + because some extensions use it. It doesn't use cache or some other clever + tricks. @@ -524,6 +524,20 @@ horizontal and vertical layouts): - scroll_speed: - Change the scrolling speed of the previewer +layout_strategies.horizontal() *layout_strategies.horizontal()* + Horizontal previewer + + +-------------+--------------+ + | | | + | Results | | + | | Preview | + | | | + +-------------| | + | Prompt | | + +-------------+--------------+ + + + layout_strategies.center() *layout_strategies.center()* Centered layout wih smaller default sizes (I think) @@ -539,31 +553,6 @@ layout_strategies.center() *layout_strategies.center()* -layout_strategies.flex() *layout_strategies.flex()* - Swap between `horizontal` and `vertical` strategies based on the window - width - - Supports `vertical` or `horizontal` features - - Uses: - - flip_columns - - flip_lines - - - -layout_strategies.horizontal() *layout_strategies.horizontal()* - Horizontal previewer - - +-------------+--------------+ - | | | - | Results | | - | | Preview | - | | | - +-------------| | - | Prompt | | - +-------------+--------------+ - - - layout_strategies.vertical() *layout_strategies.vertical()* Vertical perviewer stacks the items on top of each other. @@ -581,5 +570,16 @@ layout_strategies.vertical() *layout_strategies.vertical()* +layout_strategies.flex() *layout_strategies.flex()* + Swap between `horizontal` and `vertical` strategies based on the window + width + - Supports `vertical` or `horizontal` features + + Uses: + - flip_columns + - flip_lines + + + vim:tw=78:ts=8:ft=help:norl: diff --git a/lua/telescope/actions/init.lua b/lua/telescope/actions/init.lua index 8b5174d..9eca442 100644 --- a/lua/telescope/actions/init.lua +++ b/lua/telescope/actions/init.lua @@ -196,7 +196,7 @@ function actions.close_pum(_) end end -local do_close = function(prompt_bufnr, keepinsert) +actions._close = function(prompt_bufnr, keepinsert) local picker = action_state.get_current_picker(prompt_bufnr) local prompt_win = state.get_status(prompt_bufnr).prompt_win local original_win_id = picker.original_win_id @@ -217,7 +217,7 @@ local do_close = function(prompt_bufnr, keepinsert) end function actions.close(prompt_bufnr) - do_close(prompt_bufnr, false) + actions._close(prompt_bufnr, false) end actions.edit_command_line = function(prompt_bufnr) @@ -276,7 +276,7 @@ end actions.run_builtin = function(prompt_bufnr) local entry = action_state.get_selected_entry(prompt_bufnr) - do_close(prompt_bufnr, true) +actions._close(prompt_bufnr, true) require('telescope.builtin')[entry.text]() end