From c4e9f54a746e6b01e743538d24527d357ccd262b Mon Sep 17 00:00:00 2001 From: Imbus <> Date: Wed, 4 Dec 2024 06:35:14 +0100 Subject: [PATCH] Linter fix --- lua/autocmd.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/autocmd.lua b/lua/autocmd.lua index 802b83f..fd250a4 100644 --- a/lua/autocmd.lua +++ b/lua/autocmd.lua @@ -27,8 +27,12 @@ vim.api.nvim_create_autocmd('TextYankPost', { vim.api.nvim_create_user_command('CDToGitRoot', function() local handle = io.popen 'git rev-parse --show-toplevel 2>/dev/null' - local git_root = handle:read('*a'):gsub('\n', '') - handle:close() + local git_root + + if handle then + git_root = handle:read('*a'):gsub('\n', '') + handle:close() + end if git_root == '' then print 'Not in a Git repository'