From bcb457b8b9aa457f4e4d589c9da5ac652bbc3da9 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 4 Jun 2024 23:51:47 +0200 Subject: [PATCH] Neovim: Add incline render function --- home/modules/neovim/inclineNavic.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 home/modules/neovim/inclineNavic.lua diff --git a/home/modules/neovim/inclineNavic.lua b/home/modules/neovim/inclineNavic.lua new file mode 100644 index 00000000..d923ec0c --- /dev/null +++ b/home/modules/neovim/inclineNavic.lua @@ -0,0 +1,25 @@ +function(props) + local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t") + if filename == "" then + filename = "[No Name]" + end + local ft_icon, ft_color = devicons.get_icon_color(filename) + local modified = vim.bo[props.buf].modified + local res = { + ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "", + " ", + { filename, gui = modified and "bold,italic" or "bold" }, + guibg = "#44406e", + } + if props.focused then + for _, item in ipairs(navic.get_data(props.buf) or {}) do + table.insert(res, { + { " > ", group = "NavicSeparator" }, + { item.icon, group = "NavicIcons" .. item.type }, + { item.name, group = "NavicText" }, + }) + end + end + table.insert(res, " ") + return res +end