Created
May 22, 2022 09:44
-
-
Save s1n7ax/3d2b476ecbde72693572b8652044e5a4 to your computer and use it in GitHub Desktop.
Show file path in the winbar
This file contains hidden or 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
vim.o.winbar = "%{%v:lua.require'nvim.utils.nvim.winbar'.eval()%}" |
This file contains hidden or 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 M = {} | |
vim.api.nvim_set_hl(0, 'WinBarPath', { bg = '#dedede', fg = '#363636' }) | |
vim.api.nvim_set_hl(0, 'WinBarModified', { bg = '#dedede', fg = '#ff3838' }) | |
function M.eval() | |
local file_path = vim.api.nvim_eval_statusline('%f', {}).str | |
local modified = vim.api.nvim_eval_statusline('%M', {}).str == '+' and '⊚' or '' | |
file_path = file_path:gsub('/', ' ➤ ') | |
return '%#WinBarPath#' | |
.. file_path | |
.. '%*' | |
.. '%#WinBarModified#' | |
.. modified | |
.. '%*' | |
end | |
return M |
Thanks for this and your videos!
I've found the following function helpful
local function join_status_line(input, highlight, item)
return input .. '%#' .. highlight .. '#' .. item .. '%*'
end
function M.eval()
local winbar = ''
-- do stuff.........
winbar = join_status_line(winbar, 'WinBarPath', file_path)
winbar = join_status_line(winbar, 'WinBarModified', modified)
return winbar
end
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice