You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 20, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: USAGE.md
+26Lines changed: 26 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -164,6 +164,32 @@ end
164
164
165
165
If you omit the provider value, it will be set to an empty string. A component with no provider or an empty provider may be useful for things like [applying a highlight to section gaps](#highlight-section-gaps) or just having an icon or separator as a component.
166
166
167
+
##### Update provider value using triggers
168
+
169
+
Sometimes the provider value has to do some heavy operations, which makes it undesirable to run the provider function every time the statusline is generated. Feline allows you to conditionally re-run the provider function by triggering an update to the provider string through either an autocmd or a function. Until the provider function is run again, the value from the previous execution of the provider function is used as the provider string.
170
+
171
+
Updating provider value through triggers is achieved through the `update` key in the `provider` table. `update` can be either a boolean value, a table or a function that returns a boolean value or a table. If it's a boolean value, then the provider will be updated if value is `true`. For example:
172
+
173
+
```lua
174
+
provider= {
175
+
name='my_provider',
176
+
-- Only update provider if there are less than 4 windows in the current tabpage
177
+
update=function()
178
+
return#vim.api.nvim_tabpage_list_wins(0) <4
179
+
end
180
+
}
181
+
```
182
+
183
+
If it's a table, it must contain a list of autocmds that will trigger an update for the provider. For example:
184
+
185
+
```lua
186
+
provider= {
187
+
name='my_provider',
188
+
-- Only update provider if a window is closed or if a buffer is deleted
189
+
update= { 'WinClosed', 'BufDelete' }
190
+
}
191
+
```
192
+
167
193
#### Component name
168
194
169
195
A component can optionally be given a name. While the component is not required to have a name and the name is mostly useless, it can be used to check if the component has been [truncated](#truncation). To give a component a name, just set its `name` value to a `string`, shown below:
0 commit comments