Is it possible to render nothing when render function return nil #16
-
For example, I have something like this in my render function if props.focused then
local ok, gps = pcall(require, "nvim-gps")
if not ok or not gps.is_available() or (gps.get_location() == "") then
return nil
end
return { gps.get_location() }
end The result
simplescreenrecorder-2022-05-14_20.46.39.mp4Is it possible to completely get rid of the render result when we return |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
I had the same issue when I wanted to hide incline when my cursor is on the same line, so it doesn't hide source. My current workaround is an autocmd: vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
group = vim.api.nvim_create_augroup("hide_incline_on_first_line", {}),
buffer = 0,
callback = function()
local incline = require("incline")
if vim.fn.line(".", vim.api.nvim_get_current_win()) == 1 then
incline.disable()
else
incline.enable()
end
end,
}) There is probably a better way to do this. ( I also probably will start digging into incline itself for a PR, but that takes more time) |
Beta Was this translation helpful? Give feedback.
-
Update: This is now implemented. If Also added |
Beta Was this translation helpful? Give feedback.
-
By the way @fitrh I really like your idea of using Incline to display gps info. Would you like to contribute a screenshot/screencast to the showcase? And if so, would it be okay if I add it to the README? |
Beta Was this translation helpful? Give feedback.
-
This has been added, see my updated comment. |
Beta Was this translation helpful? Give feedback.
This isn’t currently possible but it’s a great idea. I will implement it soon.Update:
This is now implemented. If
render
returnsnil
, that statusline is temporarily hidden untilrender
returns non-nil. See:help incline-config-render
.Also added
config.hide.cursorline
. See:help incline-config-hide.cursorline
.