Giter Site home page Giter Site logo

polirritmico / lazy-local-patcher.nvim Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 31 KB

Apply local patches to plugins installed through lazy.nvim

License: GNU General Public License v2.0

Lua 100.00%
neovim-plugin neovim nvim lua nvim-plugin neovim-lua

lazy-local-patcher.nvim's Introduction

๐ŸŒ€ Lazy local patcher

Pull Requests GitHub last commit GitHub issues

๐Ÿง Description

Sometimes, I need to apply small patches to a plugin to fulfill a very niche use case or to fix something without waiting for the PR to reach upstream. However, when doing so, Lazy can't sync the repo because there are local changes.

This small plugin addresses this issue by automatically applying the patches through git commands (if possible) and reverting them before Lazy starts its lazy magic.


Before:

Before

After:

After


๐Ÿ“‹ Requirements

๐Ÿ“ฆ Installation

return {
    "polirritmico/lazy-local-patcher.nvim",
    config = true,
    ft = "lazy", -- for lazy loading
}

๐Ÿš€ Usage

โš™๏ธ Setup

Create the patches directory or the plugin will complain about the missing dir: (default path)

$ mkdir ~/.config/nvim/patches

Here you could add your patches. Two considerations:

  1. Only one file per plugin.
  2. The name of the patch should match the repository name. (More precisely, the directory name inside the Lazy root folder). e.g.: nvim-treesitter.patch

โš™๏ธ Configuration

Custom folders could be passed to the setup function:

require("lazy-local-patcher").setup({
    lazy_path = "/custom/root/lazy/path", -- directory where lazy install the plugins
    patches_path = "/custom/patch/path", -- directory where diff patches files are stored
})

Defaults

Lazy local patcher comes with the following defaults:

local defaults = {
    lazy_path = vim.fn.stdpath("data") .. "/lazy", -- directory where lazy install the plugins
    patches_path = vim.fn.stdpath("config") .. "/patches", -- directory where diff patches files are stored
}

Patches

Patches are applied using:

git -C <plugin_path_in_Lazy_root> apply --ignore-space-change <patch>

Example of patch creation:

cd .local/share/nvim/lazy/nvim-treesitter
nvim edit/some/file
git diff | tee ~/.config/nvim/patches/nvim-treesitter.patch

Now enter into Nvim and sync the plugin with Lazy.

Manual executions

You could use apply_all or restore_all functions to manually apply/restore all patches inside the patches-path folder:

:lua require("lazy-local-patcher").apply_all()
[patches: nvim-treesitter.patch] Applying patch...
[patches: nvim-treesitter.patch] Done
:lua require("lazy-local-patcher").restore_all()
[patches: nvim-treesitter.patch] Restoring plugin repository...
[patches: nvim-treesitter.patch] Done

๐ŸŒฑ Contributions

While this plugin is primarily designed for my personal use and tailored to a very specific use case, suggestions, issues, or pull requests are very welcome.

Enjoy

lazy-local-patcher.nvim's People

Contributors

polirritmico avatar

Stargazers

William Roy avatar Manh Vu avatar  avatar  avatar chiddy avatar hebe โšธ dite avatar  avatar Will Hopkins avatar Yuta Katayama avatar

Watchers

 avatar

lazy-local-patcher.nvim's Issues

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.