Status Line Integration
Opened this issue · 4 comments
Hello,
Can you please explain how to integrate statusline variables name using lualine, that is what is your configuration to produce the second screenshot in the README?
For me the status line shows the name of the file when it is not active which I would like to keep, but change the statusline only if your buffer variable is set,
Thanks
See https://github.com/xeluxee/competitest.nvim#statusline-and-winbar-integration
I use feline, but lualine configuration shouldn't be much different:
- Create a statusline for filetype
CompetiTest
- Create a component that shows the value of
vim.b.competitest_title
Here's my config for feline:
conditional_components = {
{
condition = function()
return vim.bo.filetype == "CompetiTest"
end,
inactive = {
{
{
provider = "",
hl = { bg = "bg" },
},
},
{
{
left_sep = "slant_left",
provider = function()
return vim.b.competitest_title or "CompetiTest"
end,
hl = { fg = "main_fg", bg = "main_bg" },
right_sep = "slant_right",
},
},
{},
},
},
},
-- Custom extension
local competitest_line = {
filetypes = {'CompetiTest'},
sections = {
lualine_b = { function()
return vim.b.competitest_title or 'CompetiTest'
end },
lualine_y = {'searchcount'},
lualine_z = {lineinfo},
},
inactive_sections = {
lualine_b = { function()
return vim.b.competitest_title or 'CompetiTest'
end },
},
}
-- Add extension to your require('lualine').setup block
require('lualine').setup { extensions = {competitest_line} }
Alternatively, if you want to have the same statusline for when a window is focused or when it is inactive:
local competitest_line = {
filetypes = {'CompetiTest'},
inactive_sections = {
lualine_b = { function()
return vim.b.competitest_title or 'CompetiTest'
end },
},
}
require('lualine').setup {
ignore_focus = {'CompetiTest'},
extensions = {competitest_line},
}
This is my setup for lualine: ...
-- Custom extension local competitest_line = { filetypes = {'CompetiTest'}, sections = { lualine_b = { function() return vim.b.competitest_title or 'CompetiTest' end }, lualine_y = {'searchcount'}, lualine_z = {lineinfo}, }, inactive_sections = { lualine_b = { function() return vim.b.competitest_title or 'CompetiTest' end }, }, } -- Add extension to your require('lualine').setup block require('lualine').setup { extensions = {competitest_line} }
Hi @hedyhli , thanks for this useful snippet. Can you please tell what is this lineinfo
variable in the lualine_z
section in the above configuration. I am assuming this is some global function defined elsewhere.
Hi @hedyhli , thanks for this useful snippet. Can you please tell what is this
lineinfo
variable in thelualine_z
section in the above configuration. I am assuming this is some global function defined elsewhere.
Yes, though it isn't really related to competitest integration since lualine components can be anything you want. In my case it was a local function:
local function lineinfo()
-- return " "
local total = tostring(vim.fn.line('$'))
-- Left pad the current line count to max width of this value, to avoid jittering
return string.format("%"..total:len().."d", vim.fn.line('.'))..'/'..total
end
Feel free to look for anything else that might help in this file; note though that I can't help with any further troubleshooting since I no longer use any status line at all.
Cheers!