Skip to content

smtucker/autodircmds

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 

Repository files navigation

AutoDirCmds

A very simple Neovim plugin to help keep your configurations clean by creating autocmds for files in folders specified from your plugin configuration.

Current Features

  • Creates autocmds from plugin configuration
  • Autocmds are trigged for all files/subfolders within given directory
  • Can specify lua function or vim command to be trigged
  • Enable/Disable autocmds during runtime
  • Command to temporarily run a command without generated autocmds

Example Configuration

Lazy:

{
  "smtucker/autodircmds"
  opts = {
    dirs = {
        ["~/notes"] = {
            ["BufReadPre"] = "!sync-notes down %", -- external shell script
            ["BufWritePost"] = function(event)
                -- Your code here
                end,
      },
    },
  },
  lazy = false,
},

Usage

All autocmds are created in a augroup so the plugin can toggle them on and off. To disable the autocmds generated by the plugin you can use the ADCDisable, and then you can re-enable them with ADCEnable.

The plugin also supplies a ADCRunWithout vim command that allows you to pass a command to be run with the autocmds temporarily disabled.

All of the above have corresponding Lua functions you can call from your code as well.

For example:

local ADC = require("autodircmds")
ADC.disable()
ADC.enable()
ADC.run_without(lua_func, args)

About

A very simple Neovim plugin to help keep your configurations clean by creating autocmds for files in folders specified in your plugin configuration.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages