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: disable auto-setup #438

Merged
merged 2 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ files you can even type the letter ahead from memory.
require('lazy').setup {
{'romgrk/barbar.nvim',
dependencies = 'nvim-tree/nvim-web-devicons',
init = function() vim.g.barbar_auto_setup = false end,
opts = {
-- lazy.nvim can automatically call setup for you. just put your options here:
-- insert_at_start = true,
-- lazy.nvim will automatically call setup for you. put your options here, anything missing will use the default:
-- animation = true,
-- …etc
-- insert_at_start = true,
-- …etc.
},
version = '^1.0.0', -- optional: only update when a new 1.x version is released
},
Expand All @@ -61,7 +62,8 @@ You can skip the dependency on `'nvim-tree/nvim-web-devicons'` if you
install [nerd fonts](https://www.nerdfonts.com/).

##### Requirements
- Neovim `0.7`

- Neovim `0.7`

## Features

Expand Down Expand Up @@ -235,14 +237,15 @@ map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', opts)
> If you're using Vim Script, just wrap `setup` like this:
>
> ```vim
> let g:barbar_auto_setup = v:false " disable auto-setup
> lua << EOF
> require'barbar'.setup {…}
> require'barbar'.setup {…}
> EOF
> ```

```lua
-- Set barbar's options
require'barbar'.setup {
vim.g.barbar_auto_setup = false -- disable auto-setup
require'barbar'.setup { -- Set barbar's options
-- Enable/disable animations
animation = true,

Expand Down
14 changes: 12 additions & 2 deletions doc/barbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,20 @@ Highlight groups are created in this way: `Buffer<STATUS><PART>`.
==============================================================================
4. Settings *barbar-setup*

*g:barbar_auto_setup* `boolean` (default: `true`)
By default, |barbar.nvim| will call the |barbar.setup()| function for you.
However, if you want to customize this plugin, there is no need for that
since you will have to call |barbar.setup()| yourself.

To disable the auto-setup, set this variable to `false`: >
vim.g.barbar_auto_setup = false -- Lua
let g:barbar_auto_setup = v:false " Vim script
<

`barbar`.setup({options}) *barbar.setup()*

To configure barbar or enable it for the first time, you must call this
`setup` function. The valid {options} are listed below.
To configure barbar, you must call this `setup` function. The valid
{options} are listed below.

Lua example: >
require'barbar'.setup {
Expand Down
8 changes: 2 additions & 6 deletions lua/barbar/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,12 @@ local DEPRECATED_OPTIONS = {
--- @field tabpages boolean

--- @class barbar.config
--- @field did_initialize boolean
--- @field options barbar.config.options
local config = {
did_initialize = false,
options = {},
}
local config = { options = {} }

--- @param options? table
function config.setup(options)
config.did_initialize = true
vim.g.barbar_auto_setup = false

if type(options) ~= 'table' then
options = {}
Expand Down
20 changes: 10 additions & 10 deletions plugin/barbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
-- Date: Fri 22 May 2020 02:22:36 AM EDT
-- !::exe [So]

local user_config = vim.g.bufferline
if vim.g.barbar_auto_setup ~= false then
local options = vim.g.bufferline

if user_config then
require'barbar.utils'.notify_once(
"`g:bufferline` is deprecated, use `require'barbar'.setup` instead. " ..
'See `:h barbar-setup` for more information.',
vim.log.levels.WARN
)
end
if options then
require'barbar.utils'.notify_once(
"`g:bufferline` is deprecated, use `require'barbar'.setup` instead. " ..
'See `:h barbar-setup` for more information.',
vim.log.levels.WARN
)
end

if require'barbar.config'.did_initialize == false then
require'bufferline'.setup(user_config)
require'barbar'.setup(options)
end