Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/declancm/git-scripts.nvim
🤖 Automated async git commit and async git pull functions. Optional asynchronous 'commit-on-save'.
https://github.com/declancm/git-scripts.nvim
git github lua neovim nvim vim
Last synced: 1 day ago
JSON representation
🤖 Automated async git commit and async git pull functions. Optional asynchronous 'commit-on-save'.
- Host: GitHub
- URL: https://github.com/declancm/git-scripts.nvim
- Owner: declancm
- Created: 2022-02-22T11:05:39.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-25T00:26:00.000Z (8 months ago)
- Last Synced: 2024-03-25T01:31:40.641Z (8 months ago)
- Topics: git, github, lua, neovim, nvim, vim
- Language: Lua
- Homepage:
- Size: 47.9 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# git-scripts.nvim 📜
## Features
### Automated Async Commit
✨ __Look at the commits for this repo to see the automated commit in action.__ ✨
The async commit is extremely effortless and can be very useful for quick
commits to your repositories (such as a '.dotfiles' repo), because time is money
💵.### Automated Async Pull
The async pull is very versatile and can be setup in your config for any
directory to ensure you are always up-to-date.```vim
" Pull on entry to a specific repository:
autocmd BufEnter /** lua require('git-scripts').async_pull('')" Pull on entry to every repository:
autocmd BufEnter * lua require('git-scripts').async_pull(expand('%:p:h'))" Pull on nvim entry:
autocmd VimEnter * lua require('git-scripts').async_pull()
```### Commit-On-Save
Take the auto commits a step further and use the 'commit-on-save' feature to get
the completely automated experience 🤖.## Installation
Install with your favorite package manager. Plenary is needed for the
asynchronous functions and the Bash unix shell is needed for running the shell
scripts.### Packer
```lua
use {
'declancm/git-scripts.nvim',
requires = 'nvim-lua/plenary.nvim',
}
```## Usage
### Functions List
```lua
-- Function Arguments-- message: The commit message that will be used. The default value is:
-- "Auto Commit: " .. os.date('!%b %d %H:%M:%S %Y') .. " UTC".
-- An empty string ('') input will use the default value.-- directory: The path for the directory in which the git commands will be
-- executed. The default value is the current working directory.-- Git commit and push with full error information on failure.
require("git-scripts").git_commit(message)-- Git pull with full error information on failure.
require("git-scripts").git_pull()-- Git commit and push asynchronously. Error details are written to a log file.
require("git-scripts").async_commit(message, directory)-- Git pull asynchronously. Error details are written to a log file.
require("git-scripts").async_pull(directory)-- Toggle automatic asynchronous commit on save.
require("git-scripts").toggle_auto_commit()-- Enable automatic asynchronous commit on save.
require("git-scripts").enable_auto_commit()-- Disable automatic asynchronous commit on save.
require("git-scripts").disable_auto_commit()
```### Options
```lua
-- Default options:
require('git-scripts').setup() {
default_keymaps = true, -- Use the default keymaps.
commit_on_save = false, -- Automatically commit when saving the current buffer.
warnings = true, -- Display a warning on buffer entry when commit-on-save is active.
remove_log = true, -- Delete the log file from cache when entering or exiting nvim.
}
```### Default Keymaps
```lua
local opts = { noremap = true, silent = true }vim.api.nvim_set_keymap('n', 'gc', 'lua require("git-scripts").async_commit()', opts)
vim.api.nvim_set_keymap('n', 'gp', 'lua require("git-scripts").async_pull()', opts)
vim.api.nvim_set_keymap('n', 'tac', 'lua require("git-scripts").toggle_auto_commit()', opts)
```### Commit On Save
This will push a git commit with a generated message containing the current date
and time in UTC format, every time the buffer is saved while changes exist.
This occurs asynchronously in the background for maximum convenience.To disable commit on save for the current session, either use the
default keymap `tac` to toggle, or enter the command `:DisableCommit`.