From 5fd59cd446ccd170fd6051b98aede488f69dae73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 9 Apr 2024 13:50:09 +0200 Subject: nvim/telescope: fix open with nonexistent or no file --- config/nvim/lua/mytelescopefiles.lua | 9 +++++++-- private | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/nvim/lua/mytelescopefiles.lua b/config/nvim/lua/mytelescopefiles.lua index 733a1d8..2a98505 100644 --- a/config/nvim/lua/mytelescopefiles.lua +++ b/config/nvim/lua/mytelescopefiles.lua @@ -2,10 +2,15 @@ local ts = require("telescope.builtin") local utils = require("telescope.utils") return function() - local root, ret = utils.get_os_command_output({ "git", "rev-parse", "--show-toplevel" }, vim.fn.expand("%:h")) + local dir = vim.fn.expand("%:h") + if dir == "" or not vim.fn.exists(dir) then + dir = vim.fn.getcwd() + end + local root, ret = utils.get_os_command_output({ "git", "rev-parse", "--show-toplevel" }, dir) + root = root[1] if ret == 0 then ts.git_files({ - cwd = root[1], + cwd = root, git_command = { "sh", "-c", diff --git a/private b/private index b6ba779..b0c7e86 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit b6ba779e4a9da9325df5e57e2a1898d150171c9a +Subproject commit b0c7e860ee85a97ff0939f16b34574b753a6bb8e -- cgit v1.2.3