diff --git a/lua/theprimeagen/lazy/telescope.lua b/lua/theprimeagen/lazy/telescope.lua index 185e3533..1927326a 100644 --- a/lua/theprimeagen/lazy/telescope.lua +++ b/lua/theprimeagen/lazy/telescope.lua @@ -11,8 +11,25 @@ return { require('telescope').setup({}) local builtin = require('telescope.builtin') - vim.keymap.set('n', 'pf', builtin.find_files, {}) - vim.keymap.set('n', '', builtin.git_files, {}) + -- search the current directory + vim.keymap.set('n', 'pp', function() + local Cdir = vim.fn.expand('%:p') + if Cdir == "" then + builtin.find_files() + else + Cdir = string.gsub(Cdir, "oil://", ""); + Cdir = string.gsub(Cdir, "[^/]+%.%w+$", ""); + print(Cdir); + builtin.find_files({ cwd = Cdir }) + end + end, {}) + -- fixed so even if you use this: nvim /path/to/your/project, git will be detected + vim.keymap.set('n', '', function() + local Cdir = vim.fn.expand("%:p") + Cdir = string.gsub(Cdir, "oil://", "") + Cdir = string.gsub(Cdir, "[^/]+%.%w+$", "") + builtin.git_files({ cwd = Cdir }) + end, {}) vim.keymap.set('n', 'pws', function() local word = vim.fn.expand("") builtin.grep_string({ search = word })