stevearc / stickybuf.nvim

Neovim plugin for locking a buffer to a window
MIT License
246 stars 7 forks source link

Improvement: Expose opts to pin by `filetype` and by `buftype` #15

Closed Zeioth closed 1 year ago

Zeioth commented 1 year ago

In most cases creating an autocmd shouldn't be necessary.

stevearc commented 1 year ago

This is why I exposed the get_auto_pin function in the config options. You can put whatever logic you want in there. For example

require("stickybuf").setup({
  get_auto_pin = function(bufnr)
    if vim.bo[bufnr].buftype == "terminal" then
      return "bufnr"
    elseif vim.bo[bufnr].filetype == "nix" then
      return "filetype"
    else
      return require("stickybuf").should_auto_pin(bufnr)
    end
  end,
})