Giter VIP home page Giter VIP logo

git-scripts.nvim's Introduction

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.

" Pull on entry to a specific repository:
autocmd BufEnter <example_repo_path>/** lua require('git-scripts').async_pull('<example_repo_path>')

" 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

use {
  'declancm/git-scripts.nvim',
  requires = 'nvim-lua/plenary.nvim',
}

Usage

Functions List

-- 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

-- 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

local opts = { noremap = true, silent = true }

vim.api.nvim_set_keymap('n', '<leader>gc', '<Cmd>lua require("git-scripts").async_commit()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>gp', '<Cmd>lua require("git-scripts").async_pull()<CR>', opts)
vim.api.nvim_set_keymap('n', '<leader>tac', '<Cmd>lua require("git-scripts").toggle_auto_commit()<CR>', 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 <leader>tac to toggle, or enter the command :DisableCommit.

git-scripts.nvim's People

Contributors

declancm avatar vividboarder avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

vividboarder

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.