Created
December 16, 2022 17:27
-
-
Save amustaque97/c214d292b1f5f188d9476611b41315ab to your computer and use it in GitHub Desktop.
Status line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local generator = function() | |
local el_segments = {} | |
-- Option 2, just a function that returns a string. | |
local extensions = require('el.extensions') | |
local subscribe = require('el.subscribe') | |
local section = require('el.sections') | |
table.insert(el_segments, extensions.mode) -- mode returns the current mode. | |
table.insert(el_segments, section.split) | |
table.insert(el_segments, | |
subscribe.buf_autocmd( | |
"el_git_branch", | |
"BufEnter", | |
function(window, buffer) | |
local branch = extensions.git_branch(window, buffer) | |
if branch then | |
return branch | |
end | |
end | |
)) | |
table.insert(el_segments, section.split) | |
-- expresss_line provides a helpful wrapper for these. | |
-- You can check out el.builtin | |
local builtin = require('el.builtin') | |
table.insert(el_segments, builtin.file) | |
table.insert(el_segments, section.split) | |
-- Option 4, you can return a coroutine. | |
-- In lua, you can cooperatively multi-thread. | |
-- You can use `coroutine.yield()` to yield execution to another coroutine. | |
-- | |
-- For example, in luvjob.nvim, there is `co_wait` which is a coroutine | |
-- version of waiting for a job to complete. So you can start multiple | |
-- jobs at once and wait for them to all be done. | |
table.insert(el_segments, extensions.git_changes) | |
table.insert(el_segments, section.split) | |
table.insert(el_segments, builtin.filetype) | |
table.insert(el_segments, builtin.percentage_through_file) | |
return el_segments | |
end | |
-- And then when you're all done, just call | |
require('el').setup { generator = generator } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment