-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Option hide > inactive_window
#49
Comments
That can be achieved by setting your require('incline').setup({
render = function(props)
if props.focused then
return require('incline.presets').basic(props)
-- or return whatever you want to render in the focused window
end
return nil
end,
}) I don't think the additional options are needed as the |
@fitrh Thanks for reply! Your solution works for my problem but has side effects on floating windows. I use |
I has a solution like this:
and is_floating() like this:
|
The default behavior is to ignore floating windows, configurable via require('incline').setup({
render = function(props)
if props.focused then
return require('incline.presets').basic(props)
-- or return whatever you want to render in the focused window
end
return nil
end,
ignore = {
floating_wins = false,
},
}) Maybe achieve what you want |
|
Hello I have a question and I am sorry for reviving this thread, but my question is the same thing at its core - rendering incline differently based on props.focused. Everything seems pretty clear yet, I fail trying to do a similar condition. Apply different colors based of off the condition. I did something like that: config = function()
local center_hl = vim.api.nvim_get_hl(0, { name = "InclineCenter" })
local outer_hl = vim.api.nvim_get_hl(0, { name = "InclineOuter" })
local center_hl_inactive =
vim.api.nvim_get_hl(0, { name = "InclineCenterInactive" })
local outer_hl_inactive =
vim.api.nvim_get_hl(0, { name = "InclineOuterInactive" })
require("incline").setup {
window = {
margin = { vertical = 0, horizontal = 0 },
options = { signcolumn = false, wrap = false },
padding = 0,
},
hide = {
cursorline = false,
},
render = function(props)
local filename =
vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
if vim.bo[props.buf].modified then
filename = filename .. " "
end
local active_pill_end_hl = {
guifg = "#" .. string.format("%06x", outer_hl.fg),
guibg = "#" .. string.format("%06x", outer_hl.bg),
}
local active_pill_center_hl = {
guifg = "#" .. string.format("%06x", center_hl.fg),
guibg = "#" .. string.format("%06x", center_hl.bg),
}
local inactive_pill_end_hl = {
guifg = "#" .. string.format("%06x", outer_hl_inactive.fg),
guibg = "#" .. string.format("%06x", outer_hl_inactive.bg),
}
local inactive_pill_center_hl = {
guifg = "#" .. string.format("%06x", center_hl_inactive.fg),
guibg = "#" .. string.format("%06x", center_hl_inactive.bg),
}
local icon, color =
require("nvim-web-devicons").get_icon_color(filename)
if props.focused then
return {
{
"",
guifg = active_pill_end_hl.guifg,
guibg = active_pill_end_hl.guibg,
},
{
icon,
guifg = color,
guibg = active_pill_center_hl.guibg,
},
{
" ",
guibg = active_pill_center_hl.guibg,
},
{
filename,
guibg = active_pill_center_hl.guibg,
guifg = active_pill_center_hl.guifg,
},
{
"",
guifg = active_pill_end_hl.guifg,
guibg = active_pill_end_hl.guibg,
},
}
end
return {
{
"",
-- guifg = inactive_pill_end_hl.guifg,
-- guibg = inactive_pill_end_hl.guibg,
-- testing with plain black and white
guifg = "#ffffff",
guibg = "#000000",
},
{
icon,
-- guifg = color,
-- guibg = inactive_pill_center_hl.guibg,
guifg = "#ffffff",
guibg = "#000000",
},
{
" ",
-- guibg = inactive_pill_center_hl.guibg,
guibg = "#000000",
},
{
filename,
-- guibg = inactive_pill_center_hl.guibg,
-- guifg = inactive_pill_center_hl.guifg,
guifg = "#ffffff",
guibg = "#000000",
},
{
"",
-- guifg = inactive_pill_end_hl.guifg,
-- guibg = inactive_pill_end_hl.guibg,
guifg = "#ffffff",
guibg = "#000000",
},
}
end,
}
end, As you can see, I did plain and clear black and white color definitions for the returned result for "inactive" just to see if the condition works. It does not. All my incline instances are rendered with the active colors. Anything obvious I might be missing here or is it worth investigating deeper? I'd be glad to provide details if needed. I use self modded config grown on top of nvchad base, the highlights I pull in for "active" are custom and they work (the behavior is as if all the splits returned focused=true). I am not using any plugins that might affect how splits are created. I'd appreciate a quick glance at this issue. |
Hi @tom-gora. The issue with your config seems to be caused by You can fix this by changing it to I am going to make sure that an error message is displayed in a case like this so it doesn't fail silently. Side note 1: It's usually not necessary to do things like this: local outer_hl = vim.api.nvim_get_hl(0, { name = "InclineOuter" })
-- ...
local active_pill_end_hl = {
guifg = "#" .. string.format("%06x", outer_hl.fg),
guibg = "#" .. string.format("%06x", outer_hl.bg),
} You can just use local active_pill_end_hl = { group = "InclineOuter" } The only time you should need to do the former is if you want to change something about the group, like swap the fg/bg colors or something like that. Side note 2: I'm curious to know, why are you trying to disable |
@tom-gora Here's how I would simplify your config. This should be functionally equivalent: require('incline').setup {
window = {
margin = { vertical = 0, horizontal = 0 },
-- You can probably omit this because it should not be necessary
options = { signcolumn = 'no', wrap = false },
padding = 0,
},
-- Omit this if you've already set these highlight groups somewhere else in your config
highlight = {
groups = {
InclineOuter = { guifg = 'red' },
InclineCenter = { guibg = 'red', guifg = 'white' },
InclineOuterInactive = { guifg = 'gray' },
InclineCenterInactive = { guibg = 'gray', guifg = 'white' },
},
},
hide = {
-- You can omit this because false is the default value
cursorline = false,
},
render = function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ':t')
if vim.bo[props.buf].modified then
filename = filename .. ' '
end
local suffix = props.focused and '' or 'Inactive'
local outerGroup = 'InclineOuter' .. suffix
local centerGroup = 'InclineCenter' .. suffix
local icon, iconColor = require('nvim-web-devicons').get_icon_color(filename)
-- The result table can contain nested tables.
-- This works similar to how nested HTML tags work, and makes it easier to apply
-- styles to overlapping parts of the statusline without repeating yourself.
-- Styles defined in nested tables will override styles defined in their parent
-- tables.
return {
'',
{
{ icon, guifg = iconColor },
' ',
filename,
group = centerGroup,
},
'',
group = outerGroup,
}
end,
} |
Wow thank you for the quick response. I got an idea for my implementation from craftzdog's dotfiles. I copied some stuff from him where he had it set to true. Naturally I assumed false as opposite. I'll look into it after work. Thank you so much! |
Ah, and regarding sidenote 2: |
I've used
lualine
before and I could hide the status line in inactive window, why doesn'tincline
have such functionality?When I split the current window vertically, I see the
incline
status message on both windows, which is annoying.The text was updated successfully, but these errors were encountered: