Skip to content

Commit 2d53753

Browse files
committed
docs: clean up vim help
1 parent 1663085 commit 2d53753

2 files changed

Lines changed: 58 additions & 60 deletions

File tree

doc/bareline.txt

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Goals
2121

2222
1. Simple configuration.
2323
2. Batteries included experience.
24-
3. No timer. The statusline is updated immediately as changes happen.
24+
3. Async. No timer. The statusline is updated immediately as changes happen.
2525

2626
Design
2727

@@ -31,12 +31,12 @@ Bareline takes this approach to statusline configuration:
3131
See: |bareline.config.statusline.value|.
3232
2. Helper functions are provided to improve the experience of using the DSL.
3333
See: |bareline-vimscript-functions|.
34-
3. The plugin exposes "statusline items", which group of a buf-local var, a
34+
3. The plugin exposes "statusline items", which group a buf-local var, a
3535
callback which sets the var, and autocmds firing the callback.
3636
See: |bareline.item-structure|.
3737
4. When using any buf-local var in the statusline, reference it either
3838
directly (`%{b:foo}`) or with a `get` call, `%{get(b:,'foo','')}`. This is
39-
so the stl is updated by Nvim immediately when the vars are updated.
39+
so the stl is updated by Neovim immediately when the var is updated.
4040

4141
With this design, all Bareline items are asynchronous.
4242

@@ -110,7 +110,7 @@ Below is the default config, where `bareline` equals `require("bareline")`.
110110
}
111111
<
112112
*bareline.config.statusline*
113-
The main statusline. Use |bareline-built-in-items| here.
113+
The main statusline.
114114

115115
*bareline.config.statusline.value*
116116
{value} `(string)`
@@ -119,16 +119,16 @@ The main statusline. Use |bareline-built-in-items| here.
119119
*bareline.config.statusline.items*
120120
{items} `(BareItem[])`
121121
What you are "paying" for in `value`. List here the |bareline.BareItem|s
122-
in use. This is used by Bareline to keep the statusline always showing
123-
up to date values. Failing to do this can lead to seeing values not
124-
being updated.
122+
in use. You can list here the |bareline-built-in-items|. This is used by
123+
Bareline to keep the statusline always showing up to date values.
124+
Failing to do this can lead to seeing values not being updated.
125125

126126
*bareline.config.alt_statuslines*
127127
Alternate statuslines to |bareline.config.statusline|. These can be used to
128128
assign a different statusline on windows that meet some criteria. For example,
129129
Bareline internally uses this feature to assign a different statusline for
130130
plugin windows (e.g., nvim-tree). This list is traversed in order and the
131-
first statusline which `predicate` returns true is used.
131+
statusline picked is the first one which its `when` function returns true.
132132
See: |bareline-built-in-alt-statuslines|.
133133

134134
*bareline.config.items*
@@ -139,16 +139,16 @@ Provide item-specific configuration.
139139
See |bareline.items.mhr|.
140140

141141
*bareline.config.logging*
142-
Log file location: |$XDG_DATA_HOME|`/bareline.nvim/bareline.log`.
142+
Log file location: `stdpath("data")` .. `/bareline.nvim/bareline.log`.
143143

144144
*bareline.config.logging.enabled*
145145
{enabled} `(boolean)`
146-
Whether to write to the log file. Default: false.
146+
Whether to write to the log file. Default: `false`.
147147

148148
*bareline.config.logging.level*
149149
{level} `(integer)`
150-
Log statements on this level and up are written to the log file, the
151-
others are discarded. Default: `vim.log.levels.INFO`.
150+
Log statements on this level and up are written to the log file.
151+
Default: `vim.log.levels.INFO`.
152152

153153
------------------------------------------------------------------------------
154154
*bareline-item-structure*
@@ -178,15 +178,15 @@ Options applicable to any |bareline.BareItem|.
178178
Class ~
179179
{BareItemCommonOpts}
180180
Fields ~
181-
{autocmds} `(table[]?)` Expects tables each with the keys
182-
`event` and `opts`, which are used for: |vim.api.nvim_create_autocmd()|.
181+
{autocmds} `(table[]?)` Expects tables each with the keys `event` and `opts`,
182+
which are passed to: |vim.api.nvim_create_autocmd()|.
183183

184184
*bareline.BareItem:new()*
185185
`bareline.BareItem:new`({var}, {callback}, {opts})
186186
Constructor.
187187
Parameters ~
188188
{var} `(string)`
189-
{callback} `(fun(buf_var_name:string, opts:BareItemCommonOpts))`
189+
{callback} `(fun(var:string))`
190190
{opts} `(BareItemCommonOpts)`
191191
Return ~
192192
`(BareItem)`
@@ -198,18 +198,17 @@ Custom items ~
198198
All custom items are a |bareline.BareItem|. Example item indicating soft wrap:
199199
>lua
200200
local item_soft_wrap = bareline.BareItem:new(
201-
"bl_soft_wrap",
201+
"bl_x_soft_wrap",
202202
function(var)
203203
local label = nil
204204
if vim.wo.wrap then
205205
label = "s-wrap"
206206
end
207207
vim.b[var] = label
208208
end, {
209-
-- The autocmds need to account for all the cases where the value of the
210-
-- buf-local var indicatd by `var` would change, so the statusline does
211-
-- not show a stale value.
212209
autocmds = {
210+
-- IMPORTANT: The autocmds need to account for all the cases where the
211+
-- value of the buf-local var indicated by `var` would change.
213212
{
214213
event = "OptionSet",
215214
opts = { pattern = "wrap" }
@@ -222,7 +221,7 @@ Use it:
222221
require("bareline").setup({
223222
statuslines = {
224223
active = {
225-
statusline = "%{get(b:,'bl_soft_wrap','')}",
224+
statusline = "%{get(b:,'bl_x_soft_wrap','')}",
226225
items = {
227226
-- IMPORTANT: Do not forget to add the item in the `items` list,
228227
-- otherwise the value won't be updated as expected.
@@ -324,15 +323,15 @@ Built-in alt statuslines ~
324323

325324
All custom ad built-in alt stls are structured as a `BarelineAltStatusline`.
326325

326+
Statuslines defined as this class are meant to be used in the configuration
327+
key being |bareline.config.alt_statuslines|, which accepts a list. The list
328+
gets walked in order to find a match (`when`). The first match is used.
327329
Class ~
328330
{BarelineAltStatusline}
329331
Fields ~
330332
{value} `(string)` Value for 'statusline'.
331333
{items} `(BareItem[])` List of bare items.
332-
{predicate} `((fun():boolean)?)` When it returns true, this stl is used.
333-
Caveat: Statuslines as defined like this are meant to be used in the config
334-
key |bareline.config.alt_statuslines|, which accepts a list. The list gets
335-
walked in order to find a match. The first one returning true is taken.
334+
{when} `((fun():boolean)?)` Indicates a match. The stl should be used.
336335

337336
*bareline.alt_statuslines.plugin*
338337
`bareline.alt_statuslines.plugin`
@@ -396,8 +395,8 @@ Params:
396395

397396
*BlWrap()*
398397
BlWrap(value,prefix,suffix)
399-
Wrap {value} around {prefix} and {suffix}. Example function usage to wrap with
400-
parentheses the Git HEAD returned by the plugin gitsigns:
398+
Wrap {value} around {prefix} and {suffix}. Example usage to wrap with parens
399+
the Git HEAD returned by `https://github.com/lewis6991/gitsigns.nvim`:
401400
`BlWrap(get(b:,'gitsigns_head',''),'(',')')`
402401
Params:
403402
{value} `(string)` Any.
@@ -414,9 +413,9 @@ Reassign the proper value to the window local 'statusline'. Use this to
414413
integrate with plugins which provide statusline integration through buf-local
415414
vars and user autocmds.
416415

417-
For example, consider the integration with the plugin gitsigns. By default,
418-
Bareline provides this out of the box. If it were not provided, this is how a
419-
user could define it themselves:
416+
For example, consider the integration with `lewis6991/gitsigns.nvim`. Out of
417+
the box, Bareline provides this. If it did not provide it, this is how a user
418+
could define it themselves:
420419
>lua
421420
vim.api.nvim_create_autocmd("User", {
422421
group = h.statusline_augroup,

lua/bareline.lua

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
---
2222
--- 1. Simple configuration.
2323
--- 2. Batteries included experience.
24-
--- 3. No timer. The statusline is updated immediately as changes happen.
24+
--- 3. Async. No timer. The statusline is updated immediately as changes happen.
2525
---
2626
--- Design
2727
---
@@ -31,12 +31,12 @@
3131
--- See: |bareline.config.statusline.value|.
3232
--- 2. Helper functions are provided to improve the experience of using the DSL.
3333
--- See: |bareline-vimscript-functions|.
34-
--- 3. The plugin exposes "statusline items", which group of a buf-local var, a
34+
--- 3. The plugin exposes "statusline items", which group a buf-local var, a
3535
--- callback which sets the var, and autocmds firing the callback.
3636
--- See: |bareline.item-structure|.
3737
--- 4. When using any buf-local var in the statusline, reference it either
3838
--- directly (`%{b:foo}`) or with a `get` call, `%{get(b:,'foo','')}`. This is
39-
--- so the stl is updated by Nvim immediately when the vars are updated.
39+
--- so the stl is updated by Neovim immediately when the var is updated.
4040
---
4141
--- With this design, all Bareline items are asynchronous.
4242

@@ -219,7 +219,7 @@ local function assign_default_config()
219219
end
220220

221221
--- #tag bareline.config.statusline
222-
--- The main statusline. Use |bareline-built-in-items| here.
222+
--- The main statusline.
223223
---
224224
--- #tag bareline.config.statusline.value
225225
--- {value} `(string)`
@@ -228,16 +228,16 @@ end
228228
--- #tag bareline.config.statusline.items
229229
--- {items} `(BareItem[])`
230230
--- What you are "paying" for in `value`. List here the |bareline.BareItem|s
231-
--- in use. This is used by Bareline to keep the statusline always showing
232-
--- up to date values. Failing to do this can lead to seeing values not
233-
--- being updated.
231+
--- in use. You can list here the |bareline-built-in-items|. This is used by
232+
--- Bareline to keep the statusline always showing up to date values.
233+
--- Failing to do this can lead to seeing values not being updated.
234234
---
235235
--- #tag bareline.config.alt_statuslines
236236
--- Alternate statuslines to |bareline.config.statusline|. These can be used to
237237
--- assign a different statusline on windows that meet some criteria. For example,
238238
--- Bareline internally uses this feature to assign a different statusline for
239239
--- plugin windows (e.g., nvim-tree). This list is traversed in order and the
240-
--- first statusline which `predicate` returns true is used.
240+
--- statusline picked is the first one which its `when` function returns true.
241241
--- See: |bareline-built-in-alt-statuslines|.
242242

243243
--- #tag bareline.config.items
@@ -248,16 +248,16 @@ end
248248
--- See |bareline.items.mhr|.
249249

250250
--- #tag bareline.config.logging
251-
--- Log file location: |$XDG_DATA_HOME|`/bareline.nvim/bareline.log`.
251+
--- Log file location: `stdpath("data")` .. `/bareline.nvim/bareline.log`.
252252
---
253253
--- #tag bareline.config.logging.enabled
254254
--- {enabled} `(boolean)`
255-
--- Whether to write to the log file. Default: false.
255+
--- Whether to write to the log file. Default: `false`.
256256
---
257257
--- #tag bareline.config.logging.level
258258
--- {level} `(integer)`
259-
--- Log statements on this level and up are written to the log file, the
260-
--- others are discarded. Default: `vim.log.levels.INFO`.
259+
--- Log statements on this level and up are written to the log file.
260+
--- Default: `vim.log.levels.INFO`.
261261

262262
--- #delimiter
263263
--- #tag bareline-item-structure
@@ -283,12 +283,12 @@ bareline.BareItem["__index"] = bareline.BareItem
283283
--- #tag bareline-BareItemCommonOpts
284284
--- Options applicable to any |bareline.BareItem|.
285285
---@class BareItemCommonOpts
286-
---@field autocmds table[]? Expects tables each with the keys
287-
--- `event` and `opts`, which are used for: |vim.api.nvim_create_autocmd()|.
286+
---@field autocmds table[]? Expects tables each with the keys `event` and `opts`,
287+
--- which are passed to: |vim.api.nvim_create_autocmd()|.
288288

289289
--- Constructor.
290290
---@param var string
291-
---@param callback fun(buf_var_name:string, opts:BareItemCommonOpts)
291+
---@param callback fun(var:string)
292292
---@param opts BareItemCommonOpts
293293
---@return BareItem
294294
function bareline.BareItem:new(var, callback, opts)
@@ -307,18 +307,17 @@ end
307307
--- All custom items are a |bareline.BareItem|. Example item indicating soft wrap:
308308
--- >lua
309309
--- local item_soft_wrap = bareline.BareItem:new(
310-
--- "bl_soft_wrap",
310+
--- "bl_x_soft_wrap",
311311
--- function(var)
312312
--- local label = nil
313313
--- if vim.wo.wrap then
314314
--- label = "s-wrap"
315315
--- end
316316
--- vim.b[var] = label
317317
--- end, {
318-
--- -- The autocmds need to account for all the cases where the value of the
319-
--- -- buf-local var indicatd by `var` would change, so the statusline does
320-
--- -- not show a stale value.
321318
--- autocmds = {
319+
--- -- IMPORTANT: The autocmds need to account for all the cases where the
320+
--- -- value of the buf-local var indicated by `var` would change.
322321
--- {
323322
--- event = "OptionSet",
324323
--- opts = { pattern = "wrap" }
@@ -331,7 +330,7 @@ end
331330
--- require("bareline").setup({
332331
--- statuslines = {
333332
--- active = {
334-
--- statusline = "%{get(b:,'bl_soft_wrap','')}",
333+
--- statusline = "%{get(b:,'bl_x_soft_wrap','')}",
335334
--- items = {
336335
--- -- IMPORTANT: Do not forget to add the item in the `items` list,
337336
--- -- otherwise the value won't be updated as expected.
@@ -599,13 +598,13 @@ bareline.alt_statuslines = {}
599598
---
600599
--- All custom ad built-in alt stls are structured as a `BarelineAltStatusline`.
601600

601+
--- Statuslines defined as this class are meant to be used in the configuration
602+
--- key being |bareline.config.alt_statuslines|, which accepts a list. The list
603+
--- gets walked in order to find a match (`when`). The first match is used.
602604
---@class BarelineAltStatusline
603605
---@field value string Value for 'statusline'.
604606
---@field items BareItem[] List of bare items.
605-
---@field predicate (fun():boolean)? When it returns true, this stl is used.
606-
--- Caveat: Statuslines as defined like this are meant to be used in the config
607-
--- key |bareline.config.alt_statuslines|, which accepts a list. The list gets
608-
--- walked in order to find a match. The first one returning true is taken.
607+
---@field when (fun():boolean)? Indicates a match. The stl should be used.
609608

610609
--- Statusline for plugin windows, including the plugin name.
611610
---@type BarelineAltStatusline
@@ -618,7 +617,7 @@ bareline.alt_statuslines.plugin = {
618617
items = {
619618
bareline.items.plugin_name,
620619
},
621-
predicate = function()
620+
when = function()
622621
return h.is_plugin_window(0)
623622
end,
624623
}
@@ -729,8 +728,8 @@ endfunction
729728

730729
--- #tag BlWrap()
731730
--- BlWrap(value,prefix,suffix)
732-
--- Wrap {value} around {prefix} and {suffix}. Example function usage to wrap with
733-
--- parentheses the Git HEAD returned by the plugin gitsigns:
731+
--- Wrap {value} around {prefix} and {suffix}. Example usage to wrap with parens
732+
--- the Git HEAD returned by `https://github.com/lewis6991/gitsigns.nvim`:
734733
--- `BlWrap(get(b:,'gitsigns_head',''),'(',')')`
735734
--- Params:
736735
--- * {value} `(string)` Any.
@@ -753,9 +752,9 @@ endfunction
753752
--- integrate with plugins which provide statusline integration through buf-local
754753
--- vars and user autocmds.
755754
---
756-
--- For example, consider the integration with the plugin gitsigns. By default,
757-
--- Bareline provides this out of the box. If it were not provided, this is how a
758-
--- user could define it themselves:
755+
--- For example, consider the integration with `lewis6991/gitsigns.nvim`. Out of
756+
--- the box, Bareline provides this. If it did not provide it, this is how a user
757+
--- could define it themselves:
759758
--- >lua
760759
--- vim.api.nvim_create_autocmd("User", {
761760
--- group = h.statusline_augroup,
@@ -768,7 +767,7 @@ endfunction
768767
function bareline.refresh_statusline()
769768
local statusline_to_assign = bareline.config.statusline
770769
for _, statusline in ipairs(bareline.config.alt_statuslines) do
771-
if statusline.predicate() then
770+
if statusline.when() then
772771
statusline_to_assign = statusline
773772
end
774773
end

0 commit comments

Comments
 (0)