1
0
Fork 0

nvim: snippets: don't fail if project root not found

This commit is contained in:
tastytea 2022-08-13 01:19:25 +02:00
parent 64943d0144
commit 2ffd49532d
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM
2 changed files with 7 additions and 2 deletions

View File

@ -96,6 +96,7 @@ function MY_get_project_root()
end
end
until path == ''
return nil
end
function MY_shell_capture(command)

View File

@ -52,7 +52,9 @@ return {
},
fmt(agpl, {
project = f(function()
return MY_get_project_root():gsub('.*/', '')
local root = MY_get_project_root()
if root then return root:gsub('.*/', '') end
return 'INSERT_PROJECT'
end),
year = f(function()
return os.date('%Y')
@ -74,7 +76,9 @@ return {
},
fmt(bsd0, {
project = f(function()
return MY_get_project_root():gsub('.*/', '')
local root = MY_get_project_root()
if root then return root:gsub('.*/', '') end
return 'INSERT_PROJECT'
end),
year = f(function()
return os.date('%Y')