From bd3bc006e8cfc46ca20427d377a106ab551d5cc9 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Thu, 16 Jan 2025 12:34:51 +0100 Subject: [PATCH] Prefer git root of current buffer for telescope bindings --- nvim/lua/plugins/telescope.lua | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index 9e55fe2..7939edc 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -6,10 +6,34 @@ return { keys = { { "f", "Telescope find_files", desc = "Find Files" }, { "F", "Telescope ripgrep theme=ivy", desc = "Grep" }, - { "gl", "Telescope git_commits", desc = "Git log" }, - { "gh", "Telescope git_bcommits", desc = "Git history" }, - { "gB", "Telescope git_branches", desc = "Git branches" }, - { "gs", "Telescope git_status", desc = "Git status" }, + { + "gl", + function() + require("telescope.builtin").git_commits({ cwd = vim.fs.root(0, ".git") }) + end, + desc = "Git log" + }, + { + "gh", + function() + require("telescope.builtin").git_bcommits({ cwd = vim.fs.root(0, ".git") }) + end, + desc = "Git history" + }, + { + "gB", + function() + require("telescope.builtin").git_branches({ cwd = vim.fs.root(0, ".git") }) + end, + desc = "Git branches" + }, + { + "gs", + function() + require("telescope.builtin").git_status({ cwd = vim.fs.root(0, ".git") }) + end, + desc = "Git status" + }, { "zh", "Telescope help_tags", desc = "Read help" }, }, after = function()