diff --git a/lua/crentist/lazy/telescope.lua b/lua/crentist/lazy/telescope.lua index 8e56e3f..04f2c96 100644 --- a/lua/crentist/lazy/telescope.lua +++ b/lua/crentist/lazy/telescope.lua @@ -26,7 +26,8 @@ return { 'node_modules', 'galaxy-roles', 'galaxy-collections', - '.git/', + '.git', + '.terraform', } }, extensions = { @@ -45,9 +46,9 @@ return { prev = '' }, tabs = { - { name = 'Files', tele_func = builtin.find_files, tele_opts = { no_ignore = true, hidden = true } }, - { name = 'Grep', tele_func = builtin.live_grep }, - { name = 'Buffers', tele_func = builtin.buffers }, + { name = 'Files', tele_func = builtin.find_files, tele_opts = { no_ignore = true, hidden = true } }, + { name = 'Advanced Grep', tele_func = require('crentist.telescope.advanced_grep').advanced_grep }, + { name = 'Buffers', tele_func = builtin.buffers }, }, append_tabs = { -- append_tabs will add the provided tabs to the default ones { @@ -57,6 +58,13 @@ return { return vim.fn.isdirectory('.git') == 1 end }, + { + 'Stash', + builtin.git_stash, + available = function() + return vim.fn.isdirectory('.git') == 1 + end + }, }, }) diff --git a/lua/crentist/telescope/advanced_grep.lua b/lua/crentist/telescope/advanced_grep.lua new file mode 100644 index 0000000..48e1e5c --- /dev/null +++ b/lua/crentist/telescope/advanced_grep.lua @@ -0,0 +1,54 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local make_entry = require("telescope.make_entry") +local conf = require("telescope.config").values + +local M = {} + +local advanced_grep = function(opts) + opts = opts or {} + opts.cwd = opts.cwd or vim.uv.cwd() + + + local finder = finders.new_async_job({ + command_generator = function(prompt) + if not prompt or prompt == "" then + return nil + end + + local pieces = vim.split(prompt, " ") + + local args = { "rg" } + + if pieces[1] then + table.insert(args, "-e") + table.insert(args, pieces[1]) + end + + if pieces[2] then + table.insert(args, "-g") + table.insert(args, pieces[2]) + end + + return vim.iter({ args, { "--color=never", "--no-heading", "--with-filename", "--line-number", "--column", "--smart-case" } }) + :flatten() + :totable() + end, + entry_maker = make_entry.gen_from_vimgrep(opts), + cwd = opts.cwd, + }) + + pickers.new(opts, { + debounce = 100, + prompt_title = "Advanced Grep", + finder = finder, + previewer = conf.grep_previewer(opts), + sorter = require("telescope.sorters").empty(), + }):find() +end + + +M.advanced_grep = advanced_grep + +return M +