From 1d63fecb7b3e54be846e5381f59df15008e8f960 Mon Sep 17 00:00:00 2001 From: James Trew Date: Sat, 10 Aug 2024 23:54:52 -0400 Subject: [PATCH] clean up and catch rendering bugs --- doc/telescope.txt | 91 ++++++++++++++++------------------ lua/telescope/builtin/init.lua | 2 +- 2 files changed, 44 insertions(+), 49 deletions(-) diff --git a/doc/telescope.txt b/doc/telescope.txt index e72af944fa..51f2bdaac0 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -914,7 +914,7 @@ builtin.treesitter({opts}) *telescope.builtin.treesitter()* Lists function names, variables, and other symbols from treesitter queries • Default keymaps: • ``: show autocompletion menu to prefilter your query by kind of - ts node you want to see (i.e. `:var:` ) + ts node you want to see (i.e. `:var:`) Parameters: ~ • {opts} (`table`) @@ -1488,7 +1488,7 @@ builtin.lsp_document_symbols({opts}) Lists LSP document symbols in the current buffer • Default keymaps: • ``: show autocompletion menu to prefilter your query by type of - symbol you want to see (i.e. `:variable:` ) + symbol you want to see (i.e. `:variable:`) Parameters: ~ • {opts} (`table`) @@ -1512,7 +1512,7 @@ builtin.lsp_workspace_symbols({opts}) Lists LSP document symbols in the current workspace • Default keymaps: • ``: show autocompletion menu to prefilter your query by type of - symbol you want to see (i.e. `:variable:` ) + symbol you want to see (i.e. `:variable:`) Parameters: ~ • {opts} (`table`) @@ -1561,7 +1561,7 @@ builtin.diagnostics({opts}) *telescope.builtin.diagnostics()* `:vim.diagnostic.severity:` • Default keymaps: • ``: show autocompletion menu to prefilter your query with the - diagnostic you want to see (i.e. `:warning:` ) + diagnostic you want to see (i.e. `:warning:`) • sort_by option: • "buffer": order by bufnr (prioritizing current bufnr), severity, lnum • "severity": order by severity, bufnr (prioritizing current bufnr), @@ -1713,34 +1713,34 @@ ordered from the lowest priority to the highest priority. 2. In the |telescope.setup()| table, inside a picker with a given name, use the `mappings` key >lua require("telescope").setup { - pickers = { - find_files = { - mappings = { - n = { - ["kj"] = "close", - }, - }, - }, - }, - } + pickers = { + find_files = { + mappings = { + n = { + ["kj"] = "close", + }, + }, + }, + }, + } < 3. `attach_mappings` function for a particular picker. >lua require("telescope.builtin").find_files { - attach_mappings = function(_, map) - map("i", "asdf", function(_prompt_bufnr) - print "You typed asdf" - end) - - map({"i", "n"}, "", function(_prompt_bufnr) - print "You typed " - end, { desc = "desc for which key"}) - - -- needs to return true if you want to map default_mappings and - -- false if not - return true - end, - } + attach_mappings = function(_, map) + map("i", "asdf", function(_prompt_bufnr) + print "You typed asdf" + end) + + map({"i", "n"}, "", function(_prompt_bufnr) + print "You typed " + end, { desc = "desc for which key"}) + + -- needs to return true if you want to map default_mappings and + -- false if not + return true + end, + } < ============================================================================== @@ -2257,11 +2257,9 @@ entry) which contains the following important keys: • bufnr number (optional): will be interpreted by the default `` action as open this buffer • lnum number (optional): lnum value which will be interpreted by the default - `` - action as a jump to this line + `` action as a jump to this line • col number (optional): col value which will be interpreted by the default - `` - action as a jump to this column + `` action as a jump to this column For more information on easier displaying, see |telescope.pickers.entry_display| @@ -3145,7 +3143,7 @@ actions_layout.toggle_mirror({prompt_bufnr}) *telescope.actions_layout.cycle_layout_next()* actions_layout.cycle_layout_next({prompt_bufnr}) - Cycles to the next layout in `cycle_layout_list` . + Cycles to the next layout in `cycle_layout_list`. Note: ~ • this action is not mapped by default. @@ -3155,7 +3153,7 @@ actions_layout.cycle_layout_next({prompt_bufnr}) *telescope.actions_layout.cycle_layout_prev()* actions_layout.cycle_layout_prev({prompt_bufnr}) - Cycles to the previous layout in `cycle_layout_list` . + Cycles to the previous layout in `cycle_layout_list`. Note: ~ • this action is not mapped by default. @@ -3233,7 +3231,7 @@ actions_utils.map_selections({prompt_bufnr}, {f}) *telescope.actions_utils.get_registered_mappings()* actions_utils.get_registered_mappings({prompt_bufnr}) Utility to collect mappings of prompt buffer in array of - `{mode, keybind, name}` . + `{mode, keybind, name}`. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr @@ -3268,7 +3266,7 @@ actions_generate.which_key({opts}) • Floating window: • Appears on the opposite side of the prompt. • Resolves to minimum required number of lines to show hints with `opts` - or truncates entries at `max_height` . + or truncates entries at `max_height`. • Closes automatically on action call and can be disabled with by setting `close_with_action` to false. @@ -3391,7 +3389,7 @@ previewers.new() *telescope.previewers.new()* *telescope.previewers.new_termopen_previewer()* previewers.new_termopen_previewer({opts}) Is a wrapper around Previewer and helps with creating a new - `termopen_previewer` . + `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 @@ -3493,9 +3491,8 @@ previewers.new_buffer_previewer({opts}) For example, that buffer can be opened in a new split, rather than recreating that buffer in an action. To access the last buffer number: `require('telescope.state').get_global_key("last_preview_bufnr")` - • `get_buffer_by_name = function(self, entry)` - Allows you to set a - unique name for each buffer. This is used for caching purposes. + • `get_buffer_by_name = function(self, entry)` Allows you to set a unique + name for each buffer. This is used for caching purposes. `self.state.bufname` will be nil if the entry was never loaded or the unique name when it was loaded once. For example, useful if you have one file but multiple entries. This happens for grep and lsp builtins. So to @@ -3506,8 +3503,7 @@ previewers.new_buffer_previewer({opts}) config value `dynamic_preview_title = true` `self.state` table: - • `self.state.bufnr` - Is the current buffer number, in which you have to + • `self.state.bufnr` Is the current buffer number, in which you have to write the loaded content. Don't create a buffer yourself, otherwise it's not managed by the buffer_previewer interface and you will probably be better off writing your own interface. @@ -3544,15 +3540,14 @@ previewers.new_buffer_previewer({opts}) • If you want to use `vim.fn.search` or similar you need to run it in that specific buffer context. Do >lua vim.api.nvim_buf_call(bufnr, function() - -- for example `search` and `matchadd` - end) + -- for example `search` and `matchadd` + end) < to achieve that. • If you want to read a file into the buffer it's best to use `buffer_previewer_maker`. But access this function with - `require('telescope.config').values.buffer_previewer_maker` - - because it can be redefined by users. + `require('telescope.config').values.buffer_previewer_maker` because it + can be redefined by users. Parameters: ~ • {opts} (`table`) options @@ -3600,7 +3595,7 @@ previewers.vim_buffer_vimgrep({opts}) *telescope.previewers.vim_buffer_qflist()* previewers.vim_buffer_qflist({opts}) Is the same as `vim_buffer_vimgrep` and only exists for consistency with - `term_previewers` . + `term_previewers`. The preferred way of using this previewer is like this `require('telescope.config').values.qflist_previewer` This will respect diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 9ea1ab0d0a..9695117790 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -8,7 +8,7 @@ --- Any of these functions can just be called directly by doing: --- ```vim --- :lua require('telescope.builtin').$NAME_OF_PICKER() ---- ```` +--- ``` --- --- To use any of Telescope's default options or any picker-specific options, call 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: