telescope find with file filters

This commit is contained in:
Oliver Hartmann 2023-01-09 08:38:52 +01:00
parent dc534b5a38
commit b35136bae4

View File

@ -36,6 +36,17 @@ require('telescope').setup({
find_files = { find_files = {
theme = 'ivy', theme = 'ivy',
previewer = false, previewer = false,
mappings = {
n = {
['c'] = function(prompt_bufnr)
local selection = require("telescope.actions.state").get_selected_entry()
local dir = vim.fn.fnamemodify(selection.path, ":p:h")
require("telescope.actions").close(prompt_bufnr)
-- Depending on what you want put `cd`, `lcd`, `tcd`
vim.cmd(string.format("silent lcd %s", dir))
end
}
}
}, },
oldfiles = { oldfiles = {
theme = 'ivy', theme = 'ivy',
@ -102,6 +113,17 @@ require('legendary').keymaps(
':Telescope live_grep<CR>', ':Telescope live_grep<CR>',
description = 'Search in project', description = 'Search in project',
}, },
{
'<leader>k',
function ()
vim.ui.input({prompt = 'Glob:', default = vim.api.nvim_buf_get_name(0) },
function (glob)
require('telescope.builtin').live_grep({glob_pattern = glob})
end
)
end,
description = 'Search in project',
},
{ {
'<C-y>', '<C-y>',
':Telescope neoclip<CR>', ':Telescope neoclip<CR>',
@ -125,11 +147,19 @@ require('legendary').keymaps(
} }
) )
require('legendary').func( require('legendary').funcs(
{ {
function() {
require('telescope.builtin').live_grep({ prompt_title = 'find string in open buffers...', grep_open_files = true }) function()
end, require('telescope.builtin').live_grep({ prompt_title = 'find string in open buffers...', grep_open_files = true })
description = 'Search in open files', end,
description = 'Search in open files',
},
{
function()
require("telescope.builtin").find_files({ no_ignore = false })
end,
description = 'Find file no_ignore=false',
},
} }
) )