aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2024-04-09 13:50:09 +0200
committerKarel Kočí <cynerd@email.cz>2024-04-09 13:50:09 +0200
commit5fd59cd446ccd170fd6051b98aede488f69dae73 (patch)
tree83f9cfa66a215e2b67227e18c2eafe6f72417c77 /config
parentf4fa02469356088a1d7934bf1f3c7bcd83101a73 (diff)
downloadmyconfigs-5fd59cd446ccd170fd6051b98aede488f69dae73.tar.gz
myconfigs-5fd59cd446ccd170fd6051b98aede488f69dae73.tar.bz2
myconfigs-5fd59cd446ccd170fd6051b98aede488f69dae73.zip
nvim/telescope: fix open with nonexistent or no file
Diffstat (limited to 'config')
-rw-r--r--config/nvim/lua/mytelescopefiles.lua9
1 files changed, 7 insertions, 2 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",