diff options
| author | Alvaro Muñoz <pwntester@github.com> | 2020-10-08 19:34:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-08 13:34:59 -0400 |
| commit | 6af6b4e5fd7de7ce4b6791cc8093783f1af3bd58 (patch) | |
| tree | b9158593616ef83414b54f9926c6de3b3e9ef933 /lua/telescope/pickers.lua | |
| parent | 25ed3de0ff1a4ef6e18057b1f4d59f7f1f90b8b1 (diff) | |
feat: prompt_prefix option (#154)
* enable prompt_prefix option
* add hl and default value
* default hl and prefix
* fixup: move the redraw til after prompt create
* fixup: nits
Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
Diffstat (limited to 'lua/telescope/pickers.lua')
| -rw-r--r-- | lua/telescope/pickers.lua | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lua/telescope/pickers.lua b/lua/telescope/pickers.lua index eec61a0..6efd749 100644 --- a/lua/telescope/pickers.lua +++ b/lua/telescope/pickers.lua @@ -39,6 +39,7 @@ end local ns_telescope_selection = a.nvim_create_namespace('telescope_selection') local ns_telescope_matching = a.nvim_create_namespace('telescope_matching') local ns_telescope_prompt = a.nvim_create_namespace('telescope_prompt') +local ns_telescope_prompt_prefix = a.nvim_create_namespace('telescope_prompt_prefix') local pickers = {} @@ -64,6 +65,8 @@ function Picker:new(opts) results_title = get_default(opts.results_title, "Results"), preview_title = get_default(opts.preview_title, "Preview"), + prompt_prefix = get_default(opts.prompt_prefix, config.values.prompt_prefix), + default_text = opts.default_text, get_status_text = get_default(opts.get_status_text, config.values.get_status_text), @@ -326,18 +329,20 @@ function Picker:find() local prompt_border_win = prompt_opts.border and prompt_opts.border.win_id if prompt_border_win then vim.api.nvim_win_set_option(prompt_border_win, 'winhl', 'Normal:TelescopePromptBorder') end - -- Draw the screen ASAP. This makes things feel speedier. - vim.cmd [[redraw]] - - local prompt_prefix - if false then - prompt_prefix = " > " + -- Prompt prefix + local prompt_prefix = self.prompt_prefix + if prompt_prefix ~= '' then + if not vim.endswith(prompt_prefix, ' ') then + prompt_prefix = prompt_prefix.." " + end a.nvim_buf_set_option(prompt_bufnr, 'buftype', 'prompt') vim.fn.prompt_setprompt(prompt_bufnr, prompt_prefix) - else - prompt_prefix = "" + a.nvim_buf_add_highlight(prompt_bufnr, ns_telescope_prompt_prefix, 'TelescopePromptPrefix', 0, 0, #prompt_prefix) end + -- Draw the screen ASAP. This makes things feel speedier. + vim.cmd [[redraw]] + -- First thing we want to do is set all the lines to blank. self.max_results = popup_opts.results.height @@ -425,11 +430,7 @@ function Picker:find() end local process_complete = function() - -- prompt_prefix = " hello > " - -- vim.fn.prompt_setprompt(prompt_bufnr, prompt_prefix) - -- TODO: We should either: always leave one result or make sure we actually clean up the results when nothing matches - if selection_strategy == 'row' then self:set_selection(self:get_selection_row()) elseif selection_strategy == 'follow' then |
