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---
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()
219219end
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
294294function 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" }
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
768767function 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