Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update telescope.lua #129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions lua/theprimeagen/lazy/telescope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,25 @@ return {
require('telescope').setup({})

local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
-- search the current directory
vim.keymap.set('n', '<leader>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', '<C-p>', 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', '<leader>pws', function()
local word = vim.fn.expand("<cword>")
builtin.grep_string({ search = word })
Expand Down