refactor(gitignore.lua): replace GetProjectRoot function with require statement for

absolute.utils.get-git-root module to improve code organization and readability
feat(gitignore.lua): update keymap description to include GitIgnore prefix for
clarity and consistency with functionality provided by the keymap
This commit is contained in:
David Ibia
2024-03-03 12:02:53 +01:00
parent 6afb379fad
commit db4b8ad12c

View File

@@ -1,19 +1,11 @@
local gitignore = require("gitignore")
function GetProjectRoot()
local git_root = vim.fn.systemlist("git rev-parse --show-toplevel")[1]
if git_root == nil then
return vim.fn.getcwd()
else
return git_root
end
end
local GetProjectRoot = require("absolute.utils.get-git-root")
-- Keymaps
local opts = { noremap = true, silent = true }
opts.desc = "Generate .gitignore"
opts.desc = "GitIgnore: Generate .gitignore"
vim.keymap.set("n", "<leader>gi", function()
local path = GetProjectRoot()