feat: Add cool mapping for <C-R> in command mode
This commit is contained in:
@@ -11,9 +11,7 @@ local finders = {}
|
|||||||
-- JobFinder(my_job_args)
|
-- JobFinder(my_job_args)
|
||||||
|
|
||||||
---@class Finder
|
---@class Finder
|
||||||
local Finder = {
|
local Finder = {}
|
||||||
hello = "world"
|
|
||||||
}
|
|
||||||
|
|
||||||
Finder.__index = Finder
|
Finder.__index = Finder
|
||||||
Finder.__call = function(t, ... ) return t:_find(...) end
|
Finder.__call = function(t, ... ) return t:_find(...) end
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ function Picker:new(opts)
|
|||||||
|
|
||||||
return setmetatable({
|
return setmetatable({
|
||||||
prompt = opts.prompt,
|
prompt = opts.prompt,
|
||||||
|
default_text = opts.default_text,
|
||||||
|
|
||||||
finder = opts.finder,
|
finder = opts.finder,
|
||||||
sorter = opts.sorter,
|
sorter = opts.sorter,
|
||||||
@@ -384,7 +385,11 @@ function Picker:find()
|
|||||||
|
|
||||||
mappings.apply_keymap(prompt_bufnr, self.attach_mappings, default_mappings)
|
mappings.apply_keymap(prompt_bufnr, self.attach_mappings, default_mappings)
|
||||||
|
|
||||||
vim.cmd [[startinsert]]
|
if self.default_text then
|
||||||
|
vim.api.nvim_buf_set_lines(prompt_bufnr, 0, 1, false, {self.default_text})
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.cmd [[startinsert!]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function Picker:hide_preview()
|
function Picker:hide_preview()
|
||||||
|
|||||||
@@ -6,6 +6,13 @@ highlight default link TelescopeSelection Visual
|
|||||||
highlight default link TelescopeNormal Normal
|
highlight default link TelescopeNormal Normal
|
||||||
|
|
||||||
|
|
||||||
|
" This is like "<C-R>" in your terminal.
|
||||||
|
" To use it, do `cmap <C-R> <Plug>(TelescopeFuzzyCommandSearch)
|
||||||
|
cnoremap <silent> <Plug>(TelescopeFuzzyCommandSearch) <C-\>e
|
||||||
|
\ "lua require('telescope.builtin').command_history {
|
||||||
|
\ default_text = [=[" . escape(getcmdline(), '"') . "]=]
|
||||||
|
\ }"<CR><CR>
|
||||||
|
|
||||||
" let s:term_command = "rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}' --print0"
|
" let s:term_command = "rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}' --print0"
|
||||||
" let s:term_command = "rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}' > file.txt"
|
" let s:term_command = "rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}' > file.txt"
|
||||||
" let s:term_command = "(rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}')"
|
" let s:term_command = "(rg preview_quit_map -l | fzf --preview 'bat --color=always --style=grid {-1}')"
|
||||||
|
|||||||
Reference in New Issue
Block a user