mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nvim: make search remember last query and easy replacement of / and ?
This commit is contained in:
parent
6c05614f18
commit
e4fa75f0c3
1 changed files with 30 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ local actions = require("telescope.actions")
|
||||||
local themes = require("telescope.themes")
|
local themes = require("telescope.themes")
|
||||||
local config = require("telescope.config")
|
local config = require("telescope.config")
|
||||||
local builtin = require("telescope.builtin")
|
local builtin = require("telescope.builtin")
|
||||||
|
local state = require("telescope.state")
|
||||||
|
|
||||||
-- Clone the default Telescope configuration
|
-- Clone the default Telescope configuration
|
||||||
local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) }
|
local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) }
|
||||||
|
|
@ -21,8 +22,8 @@ telescope.setup {
|
||||||
["<C-c>"] = actions.close,
|
["<C-c>"] = actions.close,
|
||||||
},
|
},
|
||||||
i = {
|
i = {
|
||||||
["<Up>"] = actions.cycle_history_prev,
|
["<C-Up>"] = actions.cycle_history_prev,
|
||||||
["<Down>"] = actions.cycle_history_next,
|
["<C-Down>"] = actions.cycle_history_next,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
layout_config = { height = 0.4 },
|
layout_config = { height = 0.4 },
|
||||||
|
|
@ -35,13 +36,39 @@ telescope.setup {
|
||||||
current_buffer_fuzzy_find = {
|
current_buffer_fuzzy_find = {
|
||||||
layout_config = { height = 0.8 },
|
layout_config = { height = 0.8 },
|
||||||
},
|
},
|
||||||
|
lsp_references = {
|
||||||
|
layout_config = { height = 0.8 },
|
||||||
|
},
|
||||||
|
live_grep = {
|
||||||
|
layout_config = { height = 0.8 },
|
||||||
|
},
|
||||||
|
resume = {
|
||||||
|
initial_mode = "normal",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(require("telescope").load_extension, "fzf")
|
pcall(require("telescope").load_extension, "fzf")
|
||||||
|
|
||||||
vim.keymap.set("n", "/", builtin["current_buffer_fuzzy_find"])
|
-- Waiting for better state management upstream
|
||||||
|
-- Currently we have to wire the state ourselves
|
||||||
|
local buffer_picker = nil
|
||||||
|
local init_buffer_picker = function()
|
||||||
|
builtin["current_buffer_fuzzy_find"]()
|
||||||
|
local cached_pickers = state.get_global_key("cached_pickers") or {}
|
||||||
|
buffer_picker = cached_pickers[1]
|
||||||
|
end
|
||||||
|
local cached_buffer_picker = function()
|
||||||
|
if buffer_picker == nil then
|
||||||
|
init_buffer_picker()
|
||||||
|
else
|
||||||
|
builtin.resume { picker = buffer_picker }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
vim.keymap.set("n", "/", init_buffer_picker)
|
||||||
|
vim.keymap.set("n", "?", cached_buffer_picker)
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>/", builtin["find_files"])
|
vim.keymap.set("n", "<leader>/", builtin["find_files"])
|
||||||
-- vim.keymap.set("n", "<leader>g/", builtin["git_files"])
|
-- vim.keymap.set("n", "<leader>g/", builtin["git_files"])
|
||||||
vim.keymap.set("n", "<leader>?", builtin["help_tags"])
|
vim.keymap.set("n", "<leader>?", builtin["help_tags"])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue