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>
This commit is contained in:
@@ -46,6 +46,8 @@ function config.set_defaults(defaults)
|
|||||||
set("results_height", 1)
|
set("results_height", 1)
|
||||||
set("results_width", 0.8)
|
set("results_width", 0.8)
|
||||||
|
|
||||||
|
set("prompt_prefix", " > ")
|
||||||
|
|
||||||
set("border", {})
|
set("border", {})
|
||||||
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ end
|
|||||||
local ns_telescope_selection = a.nvim_create_namespace('telescope_selection')
|
local ns_telescope_selection = a.nvim_create_namespace('telescope_selection')
|
||||||
local ns_telescope_matching = a.nvim_create_namespace('telescope_matching')
|
local ns_telescope_matching = a.nvim_create_namespace('telescope_matching')
|
||||||
local ns_telescope_prompt = a.nvim_create_namespace('telescope_prompt')
|
local ns_telescope_prompt = a.nvim_create_namespace('telescope_prompt')
|
||||||
|
local ns_telescope_prompt_prefix = a.nvim_create_namespace('telescope_prompt_prefix')
|
||||||
|
|
||||||
local pickers = {}
|
local pickers = {}
|
||||||
|
|
||||||
@@ -64,6 +65,8 @@ function Picker:new(opts)
|
|||||||
results_title = get_default(opts.results_title, "Results"),
|
results_title = get_default(opts.results_title, "Results"),
|
||||||
preview_title = get_default(opts.preview_title, "Preview"),
|
preview_title = get_default(opts.preview_title, "Preview"),
|
||||||
|
|
||||||
|
prompt_prefix = get_default(opts.prompt_prefix, config.values.prompt_prefix),
|
||||||
|
|
||||||
default_text = opts.default_text,
|
default_text = opts.default_text,
|
||||||
get_status_text = get_default(opts.get_status_text, config.values.get_status_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
|
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
|
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.
|
-- Prompt prefix
|
||||||
vim.cmd [[redraw]]
|
local prompt_prefix = self.prompt_prefix
|
||||||
|
if prompt_prefix ~= '' then
|
||||||
local prompt_prefix
|
if not vim.endswith(prompt_prefix, ' ') then
|
||||||
if false then
|
prompt_prefix = prompt_prefix.." "
|
||||||
prompt_prefix = " > "
|
end
|
||||||
a.nvim_buf_set_option(prompt_bufnr, 'buftype', 'prompt')
|
a.nvim_buf_set_option(prompt_bufnr, 'buftype', 'prompt')
|
||||||
vim.fn.prompt_setprompt(prompt_bufnr, prompt_prefix)
|
vim.fn.prompt_setprompt(prompt_bufnr, prompt_prefix)
|
||||||
else
|
a.nvim_buf_add_highlight(prompt_bufnr, ns_telescope_prompt_prefix, 'TelescopePromptPrefix', 0, 0, #prompt_prefix)
|
||||||
prompt_prefix = ""
|
|
||||||
end
|
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.
|
-- First thing we want to do is set all the lines to blank.
|
||||||
self.max_results = popup_opts.results.height
|
self.max_results = popup_opts.results.height
|
||||||
|
|
||||||
@@ -425,11 +430,7 @@ function Picker:find()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local process_complete = function()
|
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
|
-- 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
|
if selection_strategy == 'row' then
|
||||||
self:set_selection(self:get_selection_row())
|
self:set_selection(self:get_selection_row())
|
||||||
elseif selection_strategy == 'follow' then
|
elseif selection_strategy == 'follow' then
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ highlight default link TelescopePreviewBorder TelescopeBorder
|
|||||||
" Used for highlighting characters that you match.
|
" Used for highlighting characters that you match.
|
||||||
highlight default link TelescopeMatching NormalNC
|
highlight default link TelescopeMatching NormalNC
|
||||||
|
|
||||||
|
" Used for the prompt prefix
|
||||||
|
highlight default link TelescopePromptPrefix Identifier
|
||||||
|
|
||||||
" This is like "<C-R>" in your terminal.
|
" This is like "<C-R>" in your terminal.
|
||||||
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
|
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
|
||||||
|
|||||||
Reference in New Issue
Block a user