1 -local icon
= require'std.icon' 2 -local auto
= require'std.auto' 1 +local icon
= require 'std.icon' 2 +local auto
= require 'std.auto' 3 +local ignored
= require 'std.ignored' 5 +local NEW_FILE
= '~new~' 6 - 'rebelot/heirline.nvim',
9 - 'nvim-tree/nvim-web-devicons',
13 - local heirline
= require'heirline' 14 - local conditions
= require(
"heirline.conditions")
15 - local utils
= require(
"heirline.utils")
17 - local nugu
= require'bugabinga.nugu.palette' 18 - heirline.load_colors(nugu)
20 - auto
'ReloadHeirlineColors' {
21 - description =
'Reload dark/light nugu colors for Heirline',
22 - events =
'ColorScheme',
23 - command =
function() utils.on_colorscheme(nugu)
end,
27 - init =
function(self)
28 - self.mode
= vim.fn.mode(
1)
34 - no = icon.normal
.. "?",
35 - nov = icon.normal
.. "?",
36 - noV = icon.normal
.. "?",
37 - [
"no\22"] = icon.normal
.. "?",
38 - niI = icon.normal
.. "i",
39 - niR = icon.normal
.. "r",
40 - niV = icon.normal
.. "v",
41 - nt = icon.normal
.. "t",
43 - vs = icon.visual
.. "s",
44 - V = icon.visual
.. "_",
45 - Vs = icon.visual
.. "s",
46 - [
"\22"] =
"^" .. icon.visual,
47 - [
"\22s"] =
"^" .. icon.visual,
49 - S = icon.select
.. "_",
50 - [
"\19"] =
"^" .. icon.select,
52 - ic = icon.insert
.. "c",
53 - ix = icon.insert
.. "x",
55 - Rc = icon.replace
.. "c",
56 - Rx = icon.replace
.. "x",
57 - Rv = icon.replace
.. "v",
58 - Rvc = icon.replace
.. "v",
59 - Rvx = icon.replace
.. "v",
61 - cv = icon.command
.. "x",
63 - rm = icon.pending
.. "m",
64 - [
"r?"] = icon.pending
.. "?",
65 - [
"!"] = icon.exclaim,
71 - v =
"ui_important_global",
72 - V =
"ui_important_global",
73 - [
"\22"] =
"ui_important_global",
74 - c =
"ui_important_global",
75 - s =
"ui_important_global",
76 - S =
"ui_important_global",
77 - [
"\19"] =
"ui_important_global",
78 - R =
"ui_important_global",
79 - r =
"ui_important_global",
80 - [
"!"] =
"ui_important_global",
81 - t =
"ui_important_global",
85 - provider =
function(self)
86 - local mode_name
= self.mode_names[self.mode]
87 - return " ".. icon.vim
.." %3(" .. mode_name
.. "%) " 91 - local mode
= self.mode:sub(
1,
1)
92 - return {
fg = self.mode_colors[mode],
bold =
true }
98 - callback = vim.schedule_wrap(
function() vim.cmd.redrawstatus()
end),
102 - local file_icon
= {
103 - init =
function(self)
104 - local filename
= self.filename
105 - local extension
= vim.fn.fnamemodify(filename,
":e")
106 - self.icon
= require(
"nvim-web-devicons").get_icon_color(filename, extension, {
default =
true })
108 - provider =
function(self)
109 - return self.icon
and (self.icon
.. " ")
111 - hl =
'DefaultIcon',
114 - local file_name
= {
115 - init =
function(self)
116 - self.lfilename
= vim.fs.normalize(vim.fn.fnamemodify(self.filename,
":."))
117 - if self.lfilename
== "" then self.lfilename
= "~new~" end 123 - provider =
function(self)
124 - return self.lfilename
128 - provider =
function(self)
129 - return vim.fs.normalize(vim.fn.pathshorten(self.lfilename))
134 - local file_flags
= {
136 - condition =
function()
137 - return vim.bo.modified
139 - provider =
string.
format(
" %s ", icon.modified),
143 - condition =
function()
144 - return not vim.bo.modifiable
or vim.bo.readonly
146 - provider =
string.
format(
" %s ", icon.lock),
151 - local file_name_block
= {
152 - init =
function(self)
153 - self.filename
= vim.fs.normalize(vim.api.nvim_buf_get_name(
0))
158 - {
provider =
' ' },
163 - local file_type
= {
164 - provider =
function()
165 - return icon.file
.. ' ' .. string.
upper(vim.bo.filetype)
169 - local file_encoding
= {
170 - provider =
function()
171 - local enc
= (vim.bo.fenc
~= '' and vim.bo.fenc)
or vim.o.enc
172 - return enc
~= 'utf-8' and enc:upper()
176 - local file_format
= {
178 - dos = icon.newline
.. icon.carriage_return,
179 - unix = icon.newline,
180 - mac = icon.carriage_return,
182 - provider =
function(self)
183 - local fileformat
= vim.bo.fileformat
184 - return self[fileformat]
188 - local file_size
= {
189 - provider =
function()
192 - local suffix
= {
'b',
'k',
'M',
'G',
'T',
'P',
'E' }
193 - local fsize
= vim.fn.getfsize(vim.api.nvim_buf_get_name(
0))
194 - fsize
= (fsize
< 0 and 0)
or fsize
195 - if fsize
< 1024 then 196 - return fsize
..suffix[
1]
198 - local i
= math.
floor((
math.
log(fsize)
/ math.
log(
1024)))
199 - return string.
format(
"%.2g%s", fsize
/ math.
pow(
1024, i), suffix[i
+ 1])
203 - local file_last_modified
= {
204 - provider =
function()
205 - local ftime
= vim.fn.getftime(vim.api.nvim_buf_get_name(
0))
207 - local timeago
= require'std.timeago' 208 - return timeago.format(ftime)
213 - local lsp_active
= {
214 - condition = conditions.lsp_attached,
215 - update = {
'LspAttach',
'LspDetach',
'BufEnter'},
217 - provider =
function()
219 - for _, client
in pairs(vim.lsp.get_active_clients{
bufnr =
0 })
do 220 - table.
insert(names, client.name)
222 - return icon.lsp
.. " " .. table.
concat(names,
" ")
226 - local diagnostic_enabled
= {
227 - init =
function(self)
228 - self.icon
= vim.diagnostic.is_disabled()
and icon.toggle_off
or icon.toggle_on
230 - provider =
function(self)
231 - return icon.diagnostic
.. ' ' .. self.icon
235 - local diagnostic
= {
236 - condition = conditions.has_diagnostics,
239 - error_icon = icon.error,
240 - warn_icon = icon.warn,
241 - info_icon = icon.info,
242 - hint_icon = icon.hint,
245 - init =
function(self)
246 - self.errors
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.ERROR })
247 - self.warnings
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.WARN })
248 - self.hints
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.HINT })
249 - self.info
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.INFO })
252 - update = {
"DiagnosticChanged",
"BufEnter" },
255 - provider =
function(self)
257 - return self.errors
> 0 and (self.error_icon
.. ' ' .. self.errors
.. " ")
259 - hl =
'DiagnosticError',
262 - provider =
function(self)
263 - return self.warnings
> 0 and (self.warn_icon
.. ' ' .. self.warnings
.. " ")
265 - hl =
'DiagnosticWarn',
268 - provider =
function(self)
269 - return self.info
> 0 and (self.info_icon
.. ' ' .. self.info
.. " ")
271 - hl =
'DiagnosticInfo',
274 - provider =
function(self)
275 - return self.hints
> 0 and (self.hint_icon
.. ' ' .. self.hints)
277 - hl =
'DiagnosticHint',
281 - local is_svn_repo = function()
282 - local svn_dir
= vim.fs.find(
'.svn', {
284 - stop = vim.uv.os_homedir(),
285 - path = vim.fs.dirname(vim.api.nvim_buf_get_name(
0)),
286 - type =
'directory',
289 - return not vim.tbl_isempty(svn_dir)
292 - local svn_get_relative_url = function()
293 - local job
= require'plenary.job' 294 - local relative_url
= '[ERR]' 298 - args = {
'info',
'--show-item',
'relative-url',
'--no-newline' },
299 - on_exit =
function(current_job, exit_code)
300 - if exit_code
== 0 then relative_url
= current_job:result()
end 304 - return relative_url[
1]
308 - condition = is_svn_repo,
310 - update =
'BufEnter',
312 - init =
function(self)
313 - self.relative_url
= svn_get_relative_url()
317 - provider =
function(self)
318 - return icon.subversion
.. ' ' .. icon.branch
.. ' ' .. self.relative_url
325 - condition = conditions.is_git_repo,
327 - init =
function(self)
328 - self.status_dict
= vim.b.gitsigns_status_dict
332 - provider =
function(self)
333 - return icon.git
.. " " .. icon.branch
.. " " .. self.status_dict.head
.. ' ' 337 - provider =
function(self)
338 - local count
= self.status_dict.added
or 0 339 - return count
> 0 and (icon.diff_add
.. " " .. count
.. ' ')
344 - provider =
function(self)
345 - local count
= self.status_dict.removed
or 0 346 - return count
> 0 and (icon.diff_remove
.. " " .. count
.. ' ')
351 - provider =
function(self)
352 - local count
= self.status_dict.changed
or 0 353 - return count
> 0 and (icon.diff_change
.. " " .. count
.. ' ')
360 - init =
function(self)
361 - self.icon
= (vim.fn.haslocaldir(
0)
== 1 and icon[
'local']
or "")
.. " " .. icon.global
.. " " 362 - self.cwd
= vim.fs.normalize(vim.uv.cwd()):gsub(vim.fs.normalize(vim.uv.os_homedir()),
"~")
369 - provider =
function(self)
370 - return self.icon
.. self.cwd
375 - provider =
function(self)
376 - local cwd
= vim.fn.pathshorten(self.cwd)
377 - return self.icon
.. cwd
386 - local help_file_name
= {
387 - condition =
function()
388 - return vim.bo.filetype
== "help" 390 - provider =
function()
391 - local filename
= vim.api.nvim_buf_get_name(
0)
392 - return vim.fn.fnamemodify(filename,
":t")
397 - local terminal_name
= {
400 - provider =
function()
401 - local tname, _
= vim.api.nvim_buf_get_name(
0):gsub(
".*:",
"")
402 - tname
= vim.fs.basename(tname)
403 - return icon.terminal
.. " " .. tname
409 - provider =
function()
410 - local togglers
= require'bugabinga.options.togglers' 411 - return tostring(togglers)
415 - local macro_recording
= {
416 - condition =
function()
417 - return vim.fn.reg_recording()
~= "" and vim.o.cmdheight
== 0 419 - provider = icon.macro
.. " ",
421 - utils.surround({
"░▒▓ ",
" ▓▒░" },
nil, {
422 - provider =
function()
423 - return vim.fn.reg_recording()
434 - condition =
function()
435 - local ok, lazy_status
= pcall(
require,
"lazy.status")
436 - return ok
and lazy_status.has_updates()
438 - update = {
"User",
pattern =
"LazyUpdate" },
439 - provider =
function()
return ' ' .. icon.lazy
.. ' ' .. require'lazy.status'.updates()
.. ' ' end,
441 - callback =
function()
require'lazy'.update()
end,
442 - name =
"update_plugins",
444 - hl =
'LazyProgressTodo',
447 - local align
= {
provider =
"%=" }
448 - local space
= {
provider =
" " }
450 - local default_statusline
= {
451 - vi_mode, macro_recording, align,
452 - work_dir, space, git, svn, align,
453 - diagnostic_enabled, space, diagnostic, space, lsp_active, align,
455 - lazy, space, file_encoding, space, file_format, space ,file_type, space, file_size, space, file_last_modified,
458 - local special_statusline
= {
459 - condition =
function()
460 - return conditions.buffer_matches({
461 - buftype = {
"nofile",
"prompt",
"help",
"quickfix",
"noice",
"Trouble" },
462 - filetype = {
"^git.*",
"fugitive" },
466 - file_type, space, help_file_name, align
469 - local terminal_statusline
= {
471 - condition =
function()
472 - return conditions.buffer_matches({
buftype = {
"terminal" } })
475 - {
condition = conditions.is_active, vi_mode, space }, file_type, space, terminal_name, align,
478 - local inactive_statusline
= {
479 - condition = conditions.is_not_active,
480 - file_type, space, file_name, align,
483 - local statuslines
= {
485 - if conditions.is_active()
then 486 - return "StatusLine" 488 - return "StatusLineNC" 492 - fallthrough =
false,
494 - special_statusline, terminal_statusline, inactive_statusline, default_statusline,
499 - if conditions.is_active()
then 506 - fallthrough =
false,
509 - condition =
function()
510 - return conditions.buffer_matches({
buftype = {
"terminal" } })
513 - file_type, space, terminal_name,
520 - provider =
function(self)
521 - return "%" .. self.tabnr
.. "T " .. self.tabpage
.. " %T" 523 - hl =
function(self)
524 - if not self.is_active
then 527 - return "TabLineSel" 532 - local tab_pages
= {
534 - condition =
function()
535 - return #vim.api.nvim_list_tabpages()
>= 2 537 - {
provider =
"%=" },
538 - utils.make_tablist(tabpage),
541 - local tabline
= { tab_pages }
546 - statusline = statuslines,
553 - disable_winbar_cb =
function(args)
554 - return conditions.buffer_matches({
555 - buftype = {
"nofile",
"prompt",
"help",
"quickfix" },
556 - filetype = {
"^git.*",
"noice",
"Trouble" },
9 + 'rebelot/heirline.nvim',
12 + 'nvim-tree/nvim-web-devicons',
13 + 'lewis6991/gitsigns.nvim',
15 + config =
function ()
16 + local heirline
= require 'heirline' 17 + local conditions
= require 'heirline.conditions' 18 + local utils
= require 'heirline.utils' 20 + local nugu
= require 'bugabinga.nugu.palette' 21 + heirline.load_colors( nugu )
23 + auto
'ReloadHeirlineColors' {
24 + description =
'Reload dark/light nugu colors for Heirline',
25 + events =
'ColorScheme',
26 + command =
function () utils.on_colorscheme( nugu )
end,
30 + init =
function ( self )
31 + self.mode
= vim.fn.mode(
1 )
37 + no = icon.normal
.. '?',
38 + nov = icon.normal
.. '?',
39 + noV = icon.normal
.. '?',
40 + [
'no\22'] = icon.normal
.. '?',
41 + niI = icon.normal
.. 'i',
42 + niR = icon.normal
.. 'r',
43 + niV = icon.normal
.. 'v',
44 + nt = icon.normal
.. 't',
46 + vs = icon.visual
.. 's',
47 + V = icon.visual
.. '_',
48 + Vs = icon.visual
.. 's',
49 + [
'\22'] =
'^' .. icon.visual,
50 + [
'\22s'] =
'^' .. icon.visual,
52 + S = icon.select
.. '_',
53 + [
'\19'] =
'^' .. icon.select,
55 + ic = icon.insert
.. 'c',
56 + ix = icon.insert
.. 'x',
58 + Rc = icon.replace
.. 'c',
59 + Rx = icon.replace
.. 'x',
60 + Rv = icon.replace
.. 'v',
61 + Rvc = icon.replace
.. 'v',
62 + Rvx = icon.replace
.. 'v',
64 + cv = icon.command
.. 'x',
66 + rm = icon.pending
.. 'm',
67 + [
'r?'] = icon.pending
.. '?',
68 + [
'!'] = icon.exclaim,
74 + v =
'ui_important_global',
75 + V =
'ui_important_global',
76 + [
'\22'] =
'ui_important_global',
77 + c =
'ui_important_global',
78 + s =
'ui_important_global',
79 + S =
'ui_important_global',
80 + [
'\19'] =
'ui_important_global',
81 + R =
'ui_important_global',
82 + r =
'ui_important_global',
83 + [
'!'] =
'ui_important_global',
84 + t =
'ui_important_global',
88 + provider =
function ( self )
89 + local mode_name
= self.mode_names[self.mode]
90 + return ' ' .. icon.vim
.. ' %3(' .. mode_name
.. '%) ' 93 + hl =
function ( self )
94 + local mode
= self.mode:sub(
1,
1 )
95 + return {
fg = self.mode_colors[mode],
bold =
true }
101 + callback = vim.schedule_wrap(
function () vim.cmd.redrawstatus()
end ),
105 + local file_icon
= {
106 + init =
function ( self )
107 + local filename
= self.filename
108 + local extension
= vim.fn.fnamemodify( filename,
':e' )
109 + self.icon
= require 'nvim-web-devicons'.get_icon_color( filename, extension, {
default =
true } )
111 + provider =
function ( self )
112 + return self.icon
and (self.icon
.. ' ')
114 + hl =
'DefaultIcon',
117 + local file_name
= {
118 + init =
function ( self )
119 + self.lfilename
= vim.fs.normalize( vim.fn.fnamemodify( self.filename,
':.' ) )
120 + if self.lfilename
== '' then self.lfilename
= NEW_FILE
end 126 + provider =
function ( self )
127 + return self.lfilename
131 + provider =
function ( self )
132 + return vim.fs.normalize( vim.fn.pathshorten( self.lfilename ) )
137 + local file_flags
= {
139 + condition =
function ()
140 + return vim.bo.modified
142 + provider =
string.
format(
' %s ', icon.modified ),
146 + condition =
function ()
147 + return not vim.bo.modifiable
or vim.bo.readonly
149 + provider =
string.
format(
' %s ', icon.lock ),
154 + local file_name_block
= {
155 + init =
function ( self )
156 + self.filename
= vim.fs.normalize( vim.api.nvim_buf_get_name(
0 ) )
160 + {
provider =
' ' },
163 + {
provider =
'%<' }
166 + local file_type
= {
167 + provider =
function ()
168 + return icon.file
.. ' ' .. string.
upper( vim.bo.filetype )
172 + local file_encoding
= {
173 + provider =
function ()
174 + local enc
= (vim.bo.fenc
~= '' and vim.bo.fenc)
or vim.o.enc
175 + return enc
~= 'utf-8' and enc:upper()
179 + local file_format
= {
181 + dos = icon.newline
.. icon.carriage_return,
182 + unix = icon.newline,
183 + mac = icon.carriage_return,
185 + provider =
function ( self )
186 + local fileformat
= vim.bo.fileformat
187 + return self[fileformat]
191 + local file_size
= {
192 + provider =
function ()
195 + local suffix
= {
'b',
'k',
'M',
'G',
'T',
'P',
'E' }
196 + local fsize
= vim.fn.getfsize( vim.api.nvim_buf_get_name(
0 ) )
197 + fsize
= (fsize
< 0 and 0)
or fsize
198 + if fsize
< 1024 then 199 + return fsize
.. suffix[
1]
201 + local i
= math.
floor( (
math.
log( fsize )
/ math.
log(
1024 )) )
202 + return string.
format(
'%.2g%s', fsize
/ math.
pow(
1024, i ), suffix[i
+ 1] )
206 + local file_last_modified
= {
207 + provider =
function ()
208 + local ftime
= vim.fn.getftime( vim.api.nvim_buf_get_name(
0 ) )
210 + local timeago
= require 'std.timeago' 211 + return timeago.format( ftime )
216 + local lsp_active
= {
217 + condition = conditions.lsp_attached,
218 + update = {
'LspAttach',
'LspDetach',
'BufEnter' },
220 + provider =
function ()
222 + for _, client
in pairs( vim.lsp.get_active_clients {
bufnr =
0 } )
do 223 + table.
insert( names, client.name )
225 + return icon.lsp
.. ' ' .. table.
concat( names,
' ' )
229 + local diagnostic_enabled
= {
230 + init =
function ( self )
231 + self.icon
= vim.diagnostic.is_disabled()
and icon.toggle_off
or icon.toggle_on
233 + provider =
function ( self )
234 + return icon.diagnostic
.. ' ' .. self.icon
238 + local diagnostic
= {
239 + condition = conditions.has_diagnostics,
242 + error_icon = icon.error,
243 + warn_icon = icon.warn,
244 + info_icon = icon.info,
245 + hint_icon = icon.hint,
248 + init =
function ( self )
249 + self.errors
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.ERROR } )
250 + self.warnings
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.WARN } )
251 + self.hints
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.HINT } )
252 + self.info
= #vim.diagnostic.get(
0, {
severity = vim.diagnostic.severity.INFO } )
255 + update = {
'DiagnosticChanged',
'BufEnter' },
258 + provider =
function ( self )
260 + return self.errors
> 0 and (self.error_icon
.. ' ' .. self.errors
.. ' ')
262 + hl =
'DiagnosticError',
265 + provider =
function ( self )
266 + return self.warnings
> 0 and (self.warn_icon
.. ' ' .. self.warnings
.. ' ')
268 + hl =
'DiagnosticWarn',
271 + provider =
function ( self )
272 + return self.info
> 0 and (self.info_icon
.. ' ' .. self.info
.. ' ')
274 + hl =
'DiagnosticInfo',
277 + provider =
function ( self )
278 + return self.hints
> 0 and (self.hint_icon
.. ' ' .. self.hints)
280 + hl =
'DiagnosticHint',
284 + local is_svn_repo = function ()
285 + local svn_dir
= vim.fs.find(
'.svn', {
287 + stop = vim.uv.os_homedir(),
288 + path = vim.fs.dirname( vim.api.nvim_buf_get_name(
0 ) ),
289 + type =
'directory',
292 + return not vim.tbl_isempty( svn_dir )
295 + local svn_get_relative_url = function ()
296 + local job
= require 'plenary.job' 297 + local relative_url
= '[ERR]' 301 + args = {
'info',
'--show-item',
'relative-url',
'--no-newline' },
302 + on_exit =
function ( current_job, exit_code )
303 + if exit_code
== 0 then relative_url
= current_job:result()
end 307 + return relative_url[
1]
311 + condition = is_svn_repo,
313 + update =
'BufEnter',
315 + init =
function ( self )
316 + self.relative_url
= svn_get_relative_url()
320 + provider =
function ( self )
321 + return icon.subversion
.. ' ' .. icon.branch
.. ' ' .. self.relative_url
328 + condition = conditions.is_git_repo,
330 + init =
function ( self )
331 + self.status_dict
= vim.b.gitsigns_status_dict
335 + provider =
function ( self )
336 + return icon.git
.. ' ' .. icon.branch
.. ' ' .. self.status_dict.head
.. ' ' 340 + provider =
function ( self )
341 + local count
= self.status_dict.added
or 0 342 + return count
> 0 and (icon.diff_add
.. ' ' .. count
.. ' ')
347 + provider =
function ( self )
348 + local count
= self.status_dict.removed
or 0 349 + return count
> 0 and (icon.diff_remove
.. ' ' .. count
.. ' ')
354 + provider =
function ( self )
355 + local count
= self.status_dict.changed
or 0 356 + return count
> 0 and (icon.diff_change
.. ' ' .. count
.. ' ')
363 + init =
function ( self )
364 + self.icon
= (vim.fn.haslocaldir(
0 )
== 1 and icon[
'local']
or '')
.. ' ' .. icon.global
.. ' ' 365 + self.cwd
= vim.fs.normalize( vim.uv.cwd() ):gsub( vim.fs.normalize( vim.uv.os_homedir() ),
'~' )
371 + provider =
function ( self )
372 + return self.icon
.. self.cwd
376 + provider =
function ( self )
377 + local cwd
= vim.fn.pathshorten( self.cwd )
378 + return self.icon
.. cwd
386 + local help_file_name
= {
387 + condition =
function ()
388 + return vim.bo.filetype
== 'help' 390 + provider =
function ()
391 + local filename
= vim.api.nvim_buf_get_name(
0 )
392 + return vim.fn.fnamemodify( filename,
':t' )
397 + local terminal_name
= {
398 + provider =
function ()
399 + local tname, _
= vim.api.nvim_buf_get_name(
0 ):gsub(
'.*:',
'' )
400 + tname
= vim.fs.basename( tname )
401 + return icon.terminal
.. ' ' .. tname
407 + provider =
function ()
408 + local togglers
= require 'bugabinga.options.togglers' 409 + return tostring( togglers )
413 + local macro_recording
= {
414 + condition =
function ()
415 + return vim.fn.reg_recording()
~= '' and vim.o.cmdheight
== 0 417 + provider = icon.macro
.. ' ',
419 + utils.surround( {
'░▒▓ ',
' ▓▒░' },
nil, {
420 + provider =
function ()
421 + return vim.fn.reg_recording()
432 + condition =
function ()
433 + local ok, lazy_status
= pcall(
require,
'lazy.status' )
434 + return ok
and lazy_status.has_updates()
436 + update = {
'User',
pattern =
'LazyUpdate' },
437 + provider =
function ()
return ' ' .. icon.lazy
.. ' ' .. require 'lazy.status'.updates()
.. ' ' end,
439 + callback =
function ()
require 'lazy'.update()
end,
440 + name =
'update_plugins',
442 + hl =
'LazyProgressTodo',
445 + local align
= {
provider =
'%=' }
446 + local space
= {
provider =
' ' }
448 + local default_statusline
= {
449 + vi_mode, macro_recording, align,
450 + work_dir, space, git, svn, align,
451 + diagnostic_enabled, space, diagnostic, space, lsp_active, align,
453 + lazy, space, file_encoding, space, file_format, space, file_type, space, file_size, space, file_last_modified,
456 + local special_statusline
= {
457 + condition =
function ()
458 + return conditions.buffer_matches {
459 + buftype = ignored.buftypes,
460 + filetype = ignored.filetypes,
470 + local terminal_statusline
= {
472 + condition =
function ()
473 + return conditions.buffer_matches {
buftype = {
'terminal' } }
476 + {
condition = conditions.is_active, vi_mode, space },
483 + local inactive_statusline
= {
484 + condition = conditions.is_not_active,
491 + local statuslines
= {
493 + if conditions.is_active()
then 494 + return 'StatusLine' 496 + return 'StatusLineNC' 500 + fallthrough =
false,
502 + special_statusline,
503 + terminal_statusline,
504 + inactive_statusline,
505 + default_statusline,
510 + if conditions.is_active()
then 517 + fallthrough =
false,
520 + condition =
function ()
521 + return conditions.buffer_matches {
buftype = {
'terminal' } }
532 + local tabline_buffer_number
= {
533 + provider =
function ( self )
534 + return '(' .. tostring( self.bufnr )
.. ')' 536 + hl =
function ( self )
537 + if self.is_active
then 538 + return {
fg =
'content_accent' }
540 + return {
fg =
'ui_minor' }
545 + local tabline_file_name
= {
546 + provider =
function ( self )
547 + local file_name
= self.file_name
548 + file_name
= file_name
== '' and NEW_FILE
or vim.fs.normalize( vim.fn.fnamemodify( file_name,
':t' ) )
551 + hl =
function ( self )
return {
bold = self.is_active
or self.is_visible,
italic =
true }
end,
554 + local tabline_file_flags
= {
556 + condition =
function ( self )
return vim.api.nvim_buf_get_option( self.bufnr,
'modified' )
end,
557 + provider = icon.modified,
560 + condition =
function ( self )
561 + return not vim.api.nvim_buf_get_option( self.bufnr,
'modifiable' )
or 562 + vim.api.nvim_buf_get_option( self.bufnr,
'readonly' )
564 + provider =
function ( self )
565 + if vim.api.nvim_buf_get_option( self.bufnr,
'buftype' )
== 'terminal' then 566 + return icon.terminal
575 + local tabline_file_name_block
= {
576 + init =
function ( self )
577 + self.file_name
= vim.api.nvim_buf_get_name( self.bufnr )
580 + hl =
function ( self )
581 + if self.is_active
then 582 + return 'TabLineSel' 583 + elseif not vim.api.nvim_buf_is_loaded( self.bufnr )
then 584 + return {
fg =
'ui_unfocus' }
591 + callback =
function ( _, minwid, _, button )
592 + if button
== 'm' then 593 + vim.schedule(
function ()
594 + vim.api.nvim_buf_delete( minwid, {
force =
false } )
595 + vim.cmd.redrawtabline()
598 + vim.api.nvim_win_set_buf(
0, minwid )
601 + minwid =
function ( self )
return self.bufnr
end,
602 + name =
'heirline_tabline_buffer_callback',
606 + {
provider =
' ' },
608 + tabline_buffer_number,
609 + tabline_file_flags,
612 + local tabline_close_button
= {
613 + condition =
function ( self )
614 + return not vim.api.nvim_buf_get_option( self.bufnr,
'modified' )
616 + {
provider =
' ' },
618 + provider = icon.close,
619 + hl = {
fg =
'gray' },
621 + callback =
function ( _, minwid )
622 + vim.schedule(
function ()
623 + vim.api.nvim_buf_delete( minwid, {
force =
false } )
624 + vim.cmd.redrawtabline()
627 + minwid =
function ( self )
630 + name =
'heirline_tabline_close_buffer_callback',
635 + local tabline_buffer_block
= utils.surround(
636 + { icon.block_open, icon.block_close },
638 + if self.is_active
then 639 + return utils.get_highlight
'TabLineSel'.bg
641 + return utils.get_highlight
'TabLine'.bg
644 + { tabline_file_name_block, tabline_close_button }
647 + local buffer_line
= utils.make_buflist(
648 + tabline_buffer_block,
649 + {
provider = icon.arrow_left,
hl = {
fg =
'ui_minor' } },
650 + {
provider = icon.arrow_right,
hl = {
fg =
'ui_minor' } }
654 + provider =
function ( self )
655 + return '%' .. self.tabnr
.. 'T ' .. self.tabpage
.. ' %T' 657 + hl =
function ( self )
658 + if not self.is_active
then 661 + return 'TabLineSel' 666 + local tab_pages
= {
667 + {
provider =
'%=' },
668 + utils.make_tablist( tabpage ),
671 + local tabline
= { buffer_line, tab_pages }
676 + statusline = statuslines,
683 + disable_winbar_cb =
function ( args )
684 + return conditions.buffer_matches(
686 + buftype = ignored.buftypes,
687 + filetype = ignored.filetypes,