Neovim plugin to automatically adjust git env vars when syncing dotfiles using the "bare git repo" method

feat: Adding "is_enabled" lua function

Changed files
+13 -8
lua
+1
README.md
···
## Functions
- `require("baredot").info()` - Print current status
- `require("baredot").toggle()` - Manually toggle the env vars on / off
- `require("baredot").set(boolean)` - Set the env vars on / off
···
## Functions
- `require("baredot").info()` - Print current status
+
- `require("baredot").is_enabled()` - Returns current status as boolean
- `require("baredot").toggle()` - Manually toggle the env vars on / off
- `require("baredot").set(boolean)` - Set the env vars on / off
+8 -8
lua/baredot/commands.lua
···
end
end
function Commands.toggle()
-
if vim.env.GIT_DIR == nil or vim.env.GIT_WORK_TREE == nil then
-
Commands.set(true)
-
else
-
Commands.set(false)
-
end
Commands.info()
end
function Commands.info()
-
if vim.env.GIT_DIR == nil or vim.env.GIT_WORK_TREE == nil then
-
vim.notify("Baredot mode off", vim.log.levels.INFO, { title = "baredot.nvim" });
-
else
vim.notify(
"Baredot mode on: GIT_DIR=" .. vim.env.GIT_DIR .. " GIT_WORK_TREE=" .. vim.env.GIT_WORK_TREE,
vim.log.levels.INFO,
{ title = "baredot.nvim" }
);
end
end
···
end
end
+
function Commands.is_enabled()
+
return vim.env.GIT_DIR ~= nil and vim.env.GIT_WORK_TREE ~= nil
+
end
+
function Commands.toggle()
+
Commands.set(not Commands.is_enabled())
Commands.info()
end
function Commands.info()
+
if Commands.is_enabled() then
vim.notify(
"Baredot mode on: GIT_DIR=" .. vim.env.GIT_DIR .. " GIT_WORK_TREE=" .. vim.env.GIT_WORK_TREE,
vim.log.levels.INFO,
{ title = "baredot.nvim" }
);
+
else
+
vim.notify("Baredot mode off", vim.log.levels.INFO, { title = "baredot.nvim" });
end
end
+4
lua/baredot/init.lua
···
function Baredot.toggle()
return commands.toggle()
end
return Baredot
···
function Baredot.toggle()
return commands.toggle()
end
+
---@return boolean
+
function Baredot.is_enabled()
+
return commands.is_enabled()
+
end
return Baredot