Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add custom autocmd for user defined features #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

delphinus
Copy link

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.

@hinell
Copy link

hinell commented Oct 13, 2023

Nice feature. Please merge.

@LostNeophyte
Copy link
Member

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

@hinell
Copy link

hinell commented Nov 6, 2023

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

@LostNeophyte
Copy link
Member

@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

@hinell
Copy link

hinell commented Nov 6, 2023

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?

@LostNeophyte
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants