bigfile.nvim icon indicating copy to clipboard operation
bigfile.nvim copied to clipboard

feat: add custom autocmd for user defined features

Open delphinus opened this issue 2 years ago • 6 comments

I want to disable features other than defined in this plugin. I added custom autocmd named BigfileBufReadPost to use such as below.

vim.api.nvim_create_autocmd("User", {
  pattern = "BigfileBufReadPost",
  callback = function(args)
    vim.api.nvim_buf_call(args.buf, function()
      -- disable heavy plugin such as https://github.com/lewis6991/satellite.nvim
      vim.cmd.SatelliteDisable()
    end)
  end,
})

If you like to merge, I will add doc for this.

delphinus avatar Aug 29 '23 09:08 delphinus

Nice feature. Please merge.

hinell avatar Oct 13 '23 08:10 hinell

Sorry for the delay, I must have marked the notification as read

this is already possible but I though of a different way of doing it when creating the plugin. here's a modified example from the readme

-- all fields except `name` and `disable` are optional
local satellite = {
  name = "satellite", -- name
  opts = {
    defer = true, -- set to true if `disable` should be called on `BufReadPost` and not `BufReadPre`
  },
  disable = function() -- called to disable the feature
    vim.cmd.SatelliteDisable()
  end,
}

require("bigfile").setup {
  filesize = 1,
  features = { "treesitter", satellite }
}

LostInTheLogs avatar Nov 06 '23 13:11 LostInTheLogs

@LostNeophyte I would rather name the disable = like run or apply. Just to avoid confusion.

hinell avatar Nov 06 '23 15:11 hinell

@LostNeophyte I would rather name the disable = like run or apply. Just to avoid confusion.

yea, it's a relic of the past. the plugin used to enable all the features back after the big buffers were closed, but the functionality was removed. so i removed the enable function and disable stayed.

I'm busy with school, but if you make a backwards compatible pr with a deprecation warning that says to use apply instead of disable i'll be happy to merge it

LostInTheLogs avatar Nov 06 '23 15:11 LostInTheLogs

That's going to be a major change.... You don't seem use any versioning at all in this project. I would urge you to look at my nvim plugins to see how development is managed. What school btw?

hinell avatar Nov 06 '23 16:11 hinell

That's going to be a major change.... You don't seem use any versioning at all in this project. I would urge you to look at my nvim plugins to see how development is managed

I didn't really find versioning necessary, I don't think anyone would set the version of this plugin in their plugin manager. this is a small plugin so i'd just handle this in the feature constructor and vim.notify that disable needs to be changed and that support for it will be dropped in the future and mark the future commit as a breaking change. But maybe I'm missing something else that's useful about having versions?

What school btw?

last year of vocational school before studies

LostInTheLogs avatar Nov 06 '23 17:11 LostInTheLogs