using icons in statusline.section_filename #1830
-
Contributing guidelines
Module(s)mini.statusline QuestionI'm wondering if there is a way to make the way that a modified file show more obviously than a |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It is possible, yes. This requires writing custom section instead of using local my_filename = function()
-- In terminal always use plain name
if vim.bo.buftype == 'terminal' then return '%t' end
local modified = vim.bo.modified and '❌' or '✅'
return (MiniStatusline.is_truncated(140) and '%f' or '%F') .. modified .. '%r'
end You can use it in combination with default active content like this: local active_content = function()
local mode, mode_hl = MiniStatusline.section_mode({ trunc_width = 120 })
local git = MiniStatusline.section_git({ trunc_width = 40 })
local diff = MiniStatusline.section_diff({ trunc_width = 75 })
local diagnostics = MiniStatusline.section_diagnostics({ trunc_width = 75 })
local lsp = MiniStatusline.section_lsp({ trunc_width = 75 })
local filename = my_filename()
local fileinfo = MiniStatusline.section_fileinfo({ trunc_width = 120 })
local location = MiniStatusline.section_location({ trunc_width = 75 })
local search = MiniStatusline.section_searchcount({ trunc_width = 75 })
return MiniStatusline.combine_groups({
{ hl = mode_hl, strings = { mode } },
{ hl = 'MiniStatuslineDevinfo', strings = { git, diff, diagnostics, lsp } },
'%<', -- Mark general truncate point
{ hl = 'MiniStatuslineFilename', strings = { filename } },
'%=', -- End left alignment
{ hl = 'MiniStatuslineFileinfo', strings = { fileinfo } },
{ hl = mode_hl, strings = { search, location } },
})
end
require('mini.statusline').setup({ content = { active = active_content } }) |
Beta Was this translation helpful? Give feedback.
-
This works an absolute treat. Thanks so much for taking the time to help. I was really struggling to find/follow the documentation for how to identify if the buffer is modified. |
Beta Was this translation helpful? Give feedback.
It is possible, yes. This requires writing custom section instead of using
section_filename
:You can use it in combination with default active content like this: