1- local col_mark_1 = 120
2- local col_mark_2 = 180
1+ local col_mark_80 = 80
2+ local col_mark_120 = 120
3+ local col_mark_180 = 180
34
45--- @class Section
56local S = {}
5051--- @param onColumn integer ? The column number where the section will be hidden when the buffer ' s width is less than
5152--- @return Section
5253function S :set_autohide_fmt (onColumn )
53- onColumn = onColumn or col_mark_1
54+ onColumn = onColumn or col_mark_120
5455
5556 if self .fmt ~= nil then
5657 vim .defer_fn (function ()
@@ -69,14 +70,12 @@ function S:set_autohide_fmt(onColumn)
6970end
7071
7172local devKit_icons = Glyphs .dev_kit
72-
73+ local fs_icons = Glyphs . file_status
7374local diag_icons = {}
7475for key , val in pairs (Glyphs .diagnostics ) do
7576 diag_icons [key ] = val .. ' '
7677end
7778
78- local fs_icons = Glyphs .file_status
79-
8079return {
8180 ' nvim-lualine/lualine.nvim' ,
8281 dependencies = {
@@ -95,7 +94,7 @@ return {
9594 },
9695 ignore_focus = {},
9796 always_divide_middle = true ,
98- always_show_tabline = true ,
97+ always_show_tabline = false ,
9998 globalstatus = false ,
10099 refresh = {
101100 statusline = 1000 ,
@@ -121,7 +120,7 @@ return {
121120 S :new ({ ' mode' })
122121 :set_fmt ( -- trim to initials using kebab-case
123122 function (str )
124- if vim .api .nvim_win_get_width (0 ) > col_mark_1 then
123+ if vim .api .nvim_win_get_width (0 ) > col_mark_120 then
125124 return str
126125 end
127126 if str :match ' -' then
@@ -136,10 +135,10 @@ return {
136135 },
137136
138137 lualine_b = {
139- S :new ({ ' branch' })
138+ S :new ({ ' branch' , icon = ' ' })
140139 :set_fmt ( -- trim to first char
141140 function (str )
142- if vim .api .nvim_win_get_width (0 ) > col_mark_1 then
141+ if vim .api .nvim_win_get_width (0 ) > col_mark_120 then
143142 return str
144143 end
145144 -- just the first char
@@ -153,39 +152,37 @@ return {
153152
154153 lualine_c = {
155154 {
156- -- TODO: this still doesn't work with buffers like oil.nvim
157155 function ()
158156 -- do some evaluation
159157 local buff_width = vim .api .nvim_win_get_width (0 )
160- local m_flag = vim .api .nvim_eval_statusline (' %m' , {}).str
161- local r_flag = vim .api .nvim_eval_statusline (' %r' , {}).str
162- local w_flag = vim .api .nvim_eval_statusline (' %w' , {}).str
158+ local proto_prefix = vim .fn .expand (' %' ):match ' (.-://).+' or ' '
163159
164- local filename_parts = {
160+ local filename_parts = {}
161+
162+ -- handle special case before setting default
163+ if proto_prefix == ' oil://' then
164+ filename_parts [1 ] = (buff_width > col_mark_80 and ' %F' )
165+ or proto_prefix .. ' .../' .. vim .fs .basename (vim .fn .fnamemodify (vim .fn .getcwd (), ' %:p' )) .. ' /'
166+ elseif proto_prefix == ' term://' then
167+ filename_parts [1 ] = proto_prefix .. ' %t'
168+ else
165169 -- responsive file-path-name
166- (buff_width > col_mark_2 and ' %F' ) -- full path
167- or (buff_width > col_mark_1 and ' %f' ) -- relative path
168- or ' %t' , -- file name only
169- -- modifiable indicator
170- (m_flag == ' [+]' and fs_icons .modified )
171- or (m_flag == ' [-]' and fs_icons .unmodifiable )
172- or m_flag ,
173- -- read-only indicator
174- (r_flag == ' [RO]' and fs_icons .readOnly ) or r_flag ,
175- -- preview indicator
176- (w_flag == ' [Preview]' and fs_icons .preview ) or w_flag ,
177- }
178-
179- -- immediately concating table puts more whitespace for empty fields
180- -- so I'm manually concating
181- local str = ' %<'
182- for _ , v in ipairs (filename_parts ) do
183- if v ~= ' ' then
184- str = str .. v .. ' '
185- end
170+ filename_parts [1 ] = (buff_width > col_mark_180 and ' %F' ) -- full path
171+ or (buff_width > col_mark_120 and ' %f' ) -- relative path
172+ or proto_prefix .. ' %t' -- file name only
186173 end
187174
188- return str
175+ -- modifiable indicator
176+ filename_parts [# filename_parts + 1 ] = vim .bo .modified and fs_icons .modified
177+ or not vim .bo .modifiable and fs_icons .unmodifiable
178+ or nil
179+ -- read-only indicator
180+ filename_parts [# filename_parts + 1 ] = (vim .bo .readonly and fs_icons .readOnly ) or nil
181+
182+ -- preview indicator
183+ filename_parts [# filename_parts + 1 ] = (vim .wo .previewwindow and fs_icons .preview ) or nil
184+
185+ return ' %<' .. table.concat (filename_parts , ' ' )
189186 end ,
190187 },
191188 },
@@ -247,7 +244,7 @@ return {
247244 S :new ({
248245 -- A location section, row:col
249246 function ()
250- if vim .api .nvim_win_get_width (0 ) > col_mark_1 then
247+ if vim .api .nvim_win_get_width (0 ) > col_mark_120 then
251248 -- padding with two char
252249 return ' %2l:%-2v'
253250 end
0 commit comments