Skip to content

Commit

Permalink
refactor(configs)!: deprecate opts.general
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Oct 26, 2024
1 parent 998441a commit 54590c0
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 220 deletions.
145 changes: 69 additions & 76 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
- [Usage with `vim.ui.select`](#usage-with-vimuiselect)
- [Configuration](#configuration)
- [Options](#options)
- [General](#general)
- [Icons](#icons)
- [Symbol](#symbol)
- [Bar](#bar)
Expand Down Expand Up @@ -280,7 +279,7 @@ vim.ui.select = require('dropbar.utils.menu').select
-- If you encounter performance issues when scrolling the window, try
-- setting this option to a number slightly larger than
-- 1000 / key_repeat_rate
update_interval = 0,
update_debounce = 0,
update_events = {
win = {
'CursorMoved',
Expand Down Expand Up @@ -906,80 +905,6 @@ vim.ui.select = require('dropbar.utils.menu').select

</details>

#### General

These options live under `opts.general` and are used to configure the
general behavior of the plugin:

- `opts.general.enable`: `boolean|fun(buf: integer, win: integer): boolean`
- Controls whether to enable the plugin for the current buffer and window
- If a function is provided, it will be called with the current bufnr and
winid and should return a boolean
- Default:
```lua
function(buf, win, _)
return vim.api.nvim_buf_is_valid(buf)
and vim.api.nvim_win_is_valid(win)
and vim.wo[win].winbar == ''
and vim.fn.win_gettype(win) == ''
and vim.bo[buf].ft ~= 'help'
and ((pcall(vim.treesitter.get_parser, buf)) and true or false)
end,
```
- `opts.general.attach_events`: `string[]`
- Controls when to evaluate the `enable()` function and attach the plugin
to corresponding buffer or window
- Default:
```lua
{
'OptionSet',
'BufWinEnter',
'BufWritePost',
}
```
- `opts.general.update_interval`: `number`
- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g. `'j'`) to scroll the window
- If you encounter performance issues when scrolling the window, try
setting this option to a number slightly larger than
`1000 / key_repeat_rate`
- Default: `0`
- `opts.general.update_events.win`: `string[]`
- List of events that should trigger an update on the dropbar attached to
a single window
- Default:
```lua
{
'CursorMoved',
'WinEnter',
'WinResized',
}
```
- `opts.general.update_events.buf`: `string[]`
- List of events that should trigger an update on all dropbars attached to a
buffer
- Default:
```lua
{
'BufModifiedSet',
'FileChangedShellPost',
'TextChanged',
'ModeChanged',
}
```
- `opts.general.update_events.global`: `string[]`
- List of events that should trigger an update of all dropbars in current
nvim session
- Default:
```lua
{
'DirChanged',
'VimResized',
}
```

#### Icons

These options live under `opts.icons` and are used to configure the icons
Expand Down Expand Up @@ -1132,6 +1057,74 @@ the symbols:
These options live under `opts.bar` and are used to control the behavior of the
winbar:

- `opts.bar.enable`: `boolean|fun(buf: integer, win: integer): boolean`
- Controls whether to attach dropbar to the current buffer and window
- If a function is provided, it will be called with the current bufnr and
winid and should return a boolean
- Default:
```lua
function(buf, win, _)
return vim.api.nvim_buf_is_valid(buf)
and vim.api.nvim_win_is_valid(win)
and vim.wo[win].winbar == ''
and vim.fn.win_gettype(win) == ''
and vim.bo[buf].ft ~= 'help'
and ((pcall(vim.treesitter.get_parser, buf)) and true or false)
end,
```
- `opts.bar.attach_events`: `string[]`
- Controls when to evaluate the `enable()` function and attach the plugin
to corresponding buffer or window
- Default:
```lua
{
'OptionSet',
'BufWinEnter',
'BufWritePost',
}
```
- `opts.bar.update_debounce`: `number`
- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g. `'j'`) to scroll the window
- If you encounter performance issues when scrolling the window, try
setting this option to a number slightly larger than
`1000 / key_repeat_rate`
- Default: `0`
- `opts.bar.update_events.win`: `string[]`
- List of events that should trigger an update on the dropbar attached to
a single window
- Default:
```lua
{
'CursorMoved',
'WinEnter',
'WinResized',
}
```
- `opts.bar.update_events.buf`: `string[]`
- List of events that should trigger an update on all dropbars attached to a
buffer
- Default:
```lua
{
'BufModifiedSet',
'FileChangedShellPost',
'TextChanged',
'ModeChanged',
}
```
- `opts.bar.update_events.global`: `string[]`
- List of events that should trigger an update of all dropbars in current
nvim session
- Default:
```lua
{
'DirChanged',
'VimResized',
}
```
- `opts.bar.hover`: `boolean`
- Whether to highlight the symbol under the cursor
- This feature requires `'mousemoveevent'` to be enabled
Expand Down
166 changes: 79 additions & 87 deletions doc/dropbar.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ CONTENTS *dropbar-table-of-contents*
4.1 Usage with `vim.ui.select` |dropbar-usage-with-ui-select|
5. Configuration |dropbar-configuration|
5.1 Options |dropbar-configuration-options|
5.1.1 General |dropbar-configuration-options-general|
5.1.2 Icons |dropbar-configuration-options-icons|
5.1.3 Symbol |dropbar-configuration-options-symbol|
5.1.4 Bar |dropbar-configuration-options-bar|
5.1.5 Menu |dropbar-configuration-options-menu|
5.1.6 Sources |dropbar-configuration-options-sources|
5.1.6.1 Path |dropbar-configuration-options-sources-path|
5.1.6.2 Treesitter |dropbar-configuration-options-sources-treesitter|
5.1.6.3 LSP |dropbar-configuration-options-sources-lsp|
5.1.6.4 Markdown |dropbar-configuration-options-sources-markdown|
5.1.6.5 Terminal |dropbar-configuration-options-sources-terminal|
5.1.1 Icons |dropbar-configuration-options-icons|
5.1.2 Symbol |dropbar-configuration-options-symbol|
5.1.3 Bar |dropbar-configuration-options-bar|
5.1.4 Menu |dropbar-configuration-options-menu|
5.1.5 Sources |dropbar-configuration-options-sources|
5.1.5.1 Path |dropbar-configuration-options-sources-path|
5.1.5.2 Treesitter |dropbar-configuration-options-sources-treesitter|
5.1.5.3 LSP |dropbar-configuration-options-sources-lsp|
5.1.5.4 Markdown |dropbar-configuration-options-sources-markdown|
5.1.5.5 Terminal |dropbar-configuration-options-sources-terminal|
5.2 API |dropbar-configuration-api|
5.3 Utility Functions |dropbar-configuration-utility-functions|
5.3.1 Bar Utility Functions |dropbar-configuration-utility-functions-bar|
Expand Down Expand Up @@ -194,82 +193,6 @@ CONFIGURATION *dropbar-configuration*
------------------------------------------------------------------------------
OPTIONS *dropbar-configuration-options*

..............................................................................
GENERAL *dropbar-configuration-options-general*

These options live under `opts.general` and are used to configure the general
behavior of the plugin:

- `opts.general.enable`: `boolean|fun(buf: integer, win: integer): boolean`
- Controls whether to enable the plugin for the current buffer and window
- If a function is provided, it will be called with the current bufnr and
winid and should return a boolean
- Default: >lua

function(buf, win, _)
return vim.api.nvim_buf_is_valid(buf)
and vim.api.nvim_win_is_valid(win)
and vim.wo[win].winbar == ''
and vim.fn.win_gettype(win) == ''
and vim.bo[buf].ft ~= 'help'
and ((pcall(vim.treesitter.get_parser, buf)) and true or false)
end,
<
- `opts.general.attach_events`: `string[]`
- Controls when to evaluate the `enable()` function and attach the plugin
to corresponding buffer or window
- Default: >lua

{
'OptionSet',
'BufWinEnter',
'BufWritePost',
}
<
- `opts.general.update_interval`: `number`
- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g. `'j'`) to scroll the window
- If you encounter performance issues when scrolling the window, try
setting this option to a number slightly larger than
`1000 / key_repeat_rate`
- Default: `0`

- `opts.general.update_events.win`: `string[]`
- List of events that should trigger an update on the dropbar attached to
a single window
- Default: >lua

{
'CursorMoved',
'WinEnter',
'WinResized',
}
<
- `opts.general.update_events.buf`: `string[]`
- List of events that should trigger an update on all dropbars attached to a
buffer
- Default: >lua

{
'BufModifiedSet',
'FileChangedShellPost',
'TextChanged',
'ModeChanged',
}
<
- `opts.general.update_events.global`: `string[]`
- List of events that should trigger an update of all dropbars in current
nvim session
- Default: >lua

{
'DirChanged',
'VimResized',
}
<

..............................................................................
ICONS *dropbar-configuration-options-icons*

Expand Down Expand Up @@ -427,6 +350,75 @@ BAR *dropbar-configuration-options-bar*
These options live under `opts.bar` and are used to control the behavior of
the winbar:

- `opts.bar.enable`: `boolean|fun(buf: integer, win: integer): boolean`
- Controls whether to enable the plugin for the current buffer and window
- If a function is provided, it will be called with the current bufnr and
winid and should return a boolean
- Default: >lua

function(buf, win, _)
return vim.api.nvim_buf_is_valid(buf)
and vim.api.nvim_win_is_valid(win)
and vim.wo[win].winbar == ''
and vim.fn.win_gettype(win) == ''
and vim.bo[buf].ft ~= 'help'
and ((pcall(vim.treesitter.get_parser, buf)) and true or false)
end,
<
- `opts.bar.attach_events`: `string[]`
- Controls when to evaluate the `enable()` function and attach the plugin
to corresponding buffer or window
- Default: >lua

{
'OptionSet',
'BufWinEnter',
'BufWritePost',
}
<
- `opts.general.update_debounce`: `number`
- Wait for a short time before updating the winbar, if another update
request is received within this time, the previous request will be
cancelled, this improves the performance when the user is holding
down a key (e.g. `'j'`) to scroll the window
- If you encounter performance issues when scrolling the window, try
setting this option to a number slightly larger than
`1000 / key_repeat_rate`
- Default: `0`

- `opts.general.update_events.win`: `string[]`
- List of events that should trigger an update on the dropbar attached to
a single window
- Default: >lua

{
'CursorMoved',
'WinEnter',
'WinResized',
}
<
- `opts.general.update_events.buf`: `string[]`
- List of events that should trigger an update on all dropbars attached to a
buffer
- Default: >lua

{
'BufModifiedSet',
'FileChangedShellPost',
'TextChanged',
'ModeChanged',
}
<
- `opts.general.update_events.global`: `string[]`
- List of events that should trigger an update of all dropbars in current
nvim session
- Default: >lua

{
'DirChanged',
'VimResized',
}
<
- `opts.bar.hover`:
- Whether to highlight the symbol under the cursor
- This feature requires 'mousemoveevent' to be enabled
Expand Down
Loading

0 comments on commit 54590c0

Please sign in to comment.