mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
nvim: update telescope
This commit is contained in:
parent
b2fbc695cc
commit
3f5e236fe5
1 changed files with 27 additions and 30 deletions
|
|
@ -9,7 +9,7 @@ local state = require("telescope.state")
|
||||||
local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) }
|
local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) }
|
||||||
|
|
||||||
table.insert(vimgrep_arguments, "--hidden") -- search hidden
|
table.insert(vimgrep_arguments, "--hidden") -- search hidden
|
||||||
table.insert(vimgrep_arguments, "--glob") -- ignore git
|
table.insert(vimgrep_arguments, "--glob") -- ignore git
|
||||||
table.insert(vimgrep_arguments, "!**/.git/*")
|
table.insert(vimgrep_arguments, "!**/.git/*")
|
||||||
|
|
||||||
telescope.setup {
|
telescope.setup {
|
||||||
|
|
@ -29,7 +29,7 @@ telescope.setup {
|
||||||
["<Down>"] = actions.cycle_history_next,
|
["<Down>"] = actions.cycle_history_next,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
layout_config = { height = 0.4 },
|
layout_config = { height = 0.5 },
|
||||||
borderchars = { "", "", "", "│", "", "", "", "" },
|
borderchars = { "", "", "", "│", "", "", "", "" },
|
||||||
},
|
},
|
||||||
pickers = {
|
pickers = {
|
||||||
|
|
@ -37,7 +37,6 @@ telescope.setup {
|
||||||
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" },
|
||||||
},
|
},
|
||||||
current_buffer_fuzzy_find = {
|
current_buffer_fuzzy_find = {
|
||||||
layout_config = { height = 0.6 },
|
|
||||||
mappings = {
|
mappings = {
|
||||||
n = {
|
n = {
|
||||||
["n"] = actions.move_selection_next,
|
["n"] = actions.move_selection_next,
|
||||||
|
|
@ -46,11 +45,14 @@ telescope.setup {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
lsp_references = {
|
lsp_references = {
|
||||||
layout_config = { height = 0.6 },
|
layout_config = { height = 0.7 },
|
||||||
initial_mode = "normal",
|
initial_mode = "normal",
|
||||||
},
|
},
|
||||||
live_grep = {
|
live_grep = {
|
||||||
layout_config = { height = 0.6 },
|
layout_config = { height = 0.7 },
|
||||||
|
},
|
||||||
|
buffers = {
|
||||||
|
initial_mode = "normal",
|
||||||
},
|
},
|
||||||
resume = {
|
resume = {
|
||||||
initial_mode = "normal",
|
initial_mode = "normal",
|
||||||
|
|
@ -61,30 +63,25 @@ telescope.setup {
|
||||||
-- Enable telescope fzf native, if installed
|
-- Enable telescope fzf native, if installed
|
||||||
pcall(require("telescope").load_extension, "fzf")
|
pcall(require("telescope").load_extension, "fzf")
|
||||||
|
|
||||||
-- Waiting for better state management upstream
|
local function find_undercursor_in_buffer()
|
||||||
-- Currently we have to wire the state ourselves
|
builtin["current_buffer_fuzzy_find"] {
|
||||||
local buffer_picker = nil
|
layout_config = { height = 0.8 }, -- Already have word, no need to think
|
||||||
local init_buffer_picker = function()
|
default_text = vim.fn.expand("<cword>"),
|
||||||
builtin["current_buffer_fuzzy_find"]()
|
initial_mode = "normal",
|
||||||
local cached_pickers = state.get_global_key("cached_pickers") or {}
|
}
|
||||||
buffer_picker = cached_pickers[1]
|
|
||||||
end
|
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", "?", init_buffer_picker)
|
|
||||||
vim.keymap.set("n", "n", cached_buffer_picker)
|
|
||||||
vim.keymap.set("n", "N", cached_buffer_picker)
|
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>/", builtin["find_files"])
|
-- Better than builtin /
|
||||||
vim.keymap.set("n", "<leader>?", builtin["help_tags"])
|
vim.keymap.set("n", "/", builtin["current_buffer_fuzzy_find"])
|
||||||
vim.keymap.set("n", "<leader>g/", builtin["live_grep"])
|
vim.keymap.set("n", "<leader>w", find_undercursor_in_buffer)
|
||||||
vim.keymap.set("n", "<leader>G/", function() builtin["live_grep"] { default_text = vim.fn.expand("<cword>") } end)
|
|
||||||
vim.keymap.set("n", "<leader>d", builtin["diagnostics"])
|
-- Use / as prefix to avoid collision in bindings
|
||||||
vim.keymap.set("n", "<leader>b", builtin["buffers"])
|
vim.keymap.set("n", "<leader>/f", builtin["find_files"])
|
||||||
vim.keymap.set("n", "<leader>sp", builtin["spell_suggest"])
|
vim.keymap.set("n", "<leader>/?", builtin["help_tags"])
|
||||||
|
vim.keymap.set("n", "<leader>/g", builtin["live_grep"])
|
||||||
|
vim.keymap.set("n", "<leader>/d", builtin["diagnostics"])
|
||||||
|
vim.keymap.set("n", "<leader>/b", builtin["buffers"])
|
||||||
|
vim.keymap.set("n", "<leader>/p", builtin["spell_suggest"])
|
||||||
|
|
||||||
|
-- for GHC
|
||||||
|
-- grep -> refine for `.hs:` files
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue