[vim] Clean up the gitTopLevelDirectory() method

Mostly change double quotes to single quotes. Add a nil check.
This commit is contained in:
Eryn Wells 2024-08-02 18:29:39 -07:00
parent 4b566050af
commit a4883068de

View file

@ -1,14 +1,14 @@
-- Eryn Wells <eryn@erynwells.me> -- Eryn Wells <eryn@erynwells.me>
require "os" require 'os'
function gitTopLevelDirectory() function gitTopLevelDirectory()
local handle = io.popen("git rev-parse --show-toplevel") local handle = io.popen('git rev-parse --show-toplevel')
if handle == nil then if handle == nil then
return nil return nil
end end
local gitRepoTopLevelDirectoryPath = vim.fn.trim(handle:read("*a")) local gitRepoTopLevelDirectoryPath = vim.fn.trim(handle:read('*a'))
handle:close() handle:close()
return gitRepoTopLevelDirectoryPath return gitRepoTopLevelDirectoryPath
@ -30,7 +30,7 @@ end
function addGitTopLevelDirectoryToRuntimePath() function addGitTopLevelDirectoryToRuntimePath()
local gitTopLevelPath = gitTopLevelDirectory() local gitTopLevelPath = gitTopLevelDirectory()
if string.len(gitTopLevelPath) == 0 then if gitTopLevelPath == nil or string.len(gitTopLevelPath) == 0 then
return return
end end