1 -local icon
= require'std.icon' 2 -local auto
= require'std.auto' 1 +local icon
= require 'std.icon' 2 +local auto
= require 'std.auto' 9 9 'nvim-tree/nvim-web-devicons',
10 + 'lewis6991/gitsigns.nvim',
13 - local heirline
= require'heirline' 14 - local conditions
= require(
"heirline.conditions")
15 - local utils
= require(
"heirline.utils")
12 + config = function ()
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)
17 + local nugu
= require 'bugabinga.nugu.palette' 18 + heirline.load_colors( nugu )
20 20 auto
'ReloadHeirlineColors' {
21 21 description =
'Reload dark/light nugu colors for Heirline',
22 22 events =
'ColorScheme',
23 - command =
function() utils.on_colorscheme(nugu)
end,
23 + command =
function () utils.on_colorscheme( nugu )
end,
27 - init =
function(self)
28 - self.mode
= vim.fn.mode(
1)
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",
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,
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,
49 + S = icon.select
.. '_',
50 + [
'\19'] =
'^' .. icon.select,
52 - ic = icon.insert
.. "c",
53 - ix = icon.insert
.. "x",
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",
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",
61 + cv = icon.command
.. 'x',
63 - rm = icon.pending
.. "m",
64 - [
"r?"] = icon.pending
.. "?",
65 - [
"!"] = icon.exclaim,
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",
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)
85 + provider =
function ( self )
86 86 local mode_name
= self.mode_names[self.mode]
87 - return " ".. icon.vim
.." %3(" .. mode_name
.. "%) " 87 + return ' ' .. icon.vim
.. ' %3(' .. mode_name
.. '%) ' 91 - local mode
= self.mode:sub(
1,
1)
90 + hl =
function ( self )
91 + local mode
= self.mode:sub(
1,
1 )
92 92 return {
fg = self.mode_colors[mode],
bold =
true }
98 - callback = vim.schedule_wrap(
function() vim.cmd.redrawstatus()
end),
98 + callback = vim.schedule_wrap(
function () vim.cmd.redrawstatus()
end ),
102 - local file_icon
= {
103 - init =
function(self)
102 + local file_icon
= {
103 + init =
function ( self )
104 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 })
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
.. " ")
108 + provider =
function ( self )
109 + return self.icon
and (self.icon
.. ' ')
111 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 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)
123 + provider =
function ( self )
124 124 return self.lfilename
128 - provider =
function(self)
129 - return vim.fs.normalize(vim.fn.pathshorten(self.lfilename))
128 + provider =
function ( self )
129 + return vim.fs.normalize( vim.fn.pathshorten( self.lfilename ) )
134 - local file_flags
= {
134 + local file_flags
= {
136 - condition =
function()
136 + condition =
function ()
137 137 return vim.bo.modified
139 - provider =
string.
format(
" %s ", icon.modified),
139 + provider =
string.
format(
' %s ', icon.modified ),
143 - condition =
function()
143 + condition =
function ()
144 144 return not vim.bo.modifiable
or vim.bo.readonly
146 - provider =
string.
format(
" %s ", icon.lock),
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))
151 + local file_name_block
= {
152 + init =
function ( self )
153 + self.filename
= vim.fs.normalize( vim.api.nvim_buf_get_name(
0 ) )
158 158 {
provider =
' ' },
160 + {
provider =
'%<' }
163 - local file_type
= {
164 - provider =
function()
165 - return icon.file
.. ' ' .. string.
upper(vim.bo.filetype)
163 + local file_type
= {
164 + provider =
function ()
165 + return icon.file
.. ' ' .. string.
upper( vim.bo.filetype )
169 - local file_encoding
= {
170 - provider =
function()
169 + local file_encoding
= {
170 + provider =
function ()
171 171 local enc
= (vim.bo.fenc
~= '' and vim.bo.fenc)
or vim.o.enc
172 172 return enc
~= 'utf-8' and enc:upper()
176 - local file_format
= {
176 + local file_format
= {
178 178 dos = icon.newline
.. icon.carriage_return,
179 179 unix = icon.newline,
180 180 mac = icon.carriage_return,
182 - provider =
function(self)
182 + provider =
function ( self )
183 183 local fileformat
= vim.bo.fileformat
184 184 return self[fileformat]
188 - local file_size
= {
189 - provider =
function()
188 + local file_size
= {
189 + provider =
function ()
192 192 local suffix
= {
'b',
'k',
'M',
'G',
'T',
'P',
'E' }
193 - local fsize
= vim.fn.getfsize(vim.api.nvim_buf_get_name(
0))
193 + local fsize
= vim.fn.getfsize( vim.api.nvim_buf_get_name(
0 ) )
194 194 fsize
= (fsize
< 0 and 0)
or fsize
195 195 if fsize
< 1024 then 196 - return fsize
..suffix[
1]
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])
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))
203 + local file_last_modified
= {
204 + provider =
function ()
205 + local ftime
= vim.fn.getftime( vim.api.nvim_buf_get_name(
0 ) )
206 206 if ftime
> 0 then 207 - local timeago
= require'std.timeago' 208 - return timeago.format(ftime)
207 + local timeago
= require 'std.timeago' 208 + return timeago.format( ftime )
213 - local lsp_active
= {
213 + local lsp_active
= {
214 214 condition = conditions.lsp_attached,
215 - update = {
'LspAttach',
'LspDetach',
'BufEnter'},
215 + update = {
'LspAttach',
'LspDetach',
'BufEnter' },
217 - provider =
function()
217 + provider =
function ()
219 - for _, client
in pairs(vim.lsp.get_active_clients{
bufnr =
0 })
do 220 - table.
insert(names, client.name)
219 + for _, client
in pairs( vim.lsp.get_clients {
bufnr =
0 } )
do 220 + table.
insert( names, client.name )
222 - return icon.lsp
.. " " .. table.
concat(names,
" ")
222 + return icon.lsp
.. ' ' .. table.
concat( names,
' ' )
226 - local diagnostic_enabled
= {
227 - init =
function(self)
226 + local diagnostic_enabled
= {
227 + init =
function ( self )
228 228 self.icon
= vim.diagnostic.is_disabled()
and icon.toggle_off
or icon.toggle_on
230 - provider =
function(self)
230 + provider =
function ( self )
231 231 return icon.diagnostic
.. ' ' .. self.icon
235 - local diagnostic
= {
235 + local diagnostic
= {
236 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,
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 })
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" },
252 + update = {
'DiagnosticChanged',
'BufEnter' },
255 - provider =
function(self)
255 + provider =
function ( self )
257 - return self.errors
> 0 and (self.error_icon
.. ' ' .. self.errors
.. " ")
257 + return self.errors
> 0 and (self.error_icon
.. ' ' .. self.errors
.. ' ')
259 259 hl =
'DiagnosticError',
262 - provider =
function(self)
263 - return self.warnings
> 0 and (self.warn_icon
.. ' ' .. self.warnings
.. " ")
262 + provider =
function ( self )
263 + return self.warnings
> 0 and (self.warn_icon
.. ' ' .. self.warnings
.. ' ')
265 265 hl =
'DiagnosticWarn',
268 - provider =
function(self)
269 - return self.info
> 0 and (self.info_icon
.. ' ' .. self.info
.. " ")
268 + provider =
function ( self )
269 + return self.info
> 0 and (self.info_icon
.. ' ' .. self.info
.. ' ')
271 271 hl =
'DiagnosticInfo',
274 - provider =
function(self)
274 + provider =
function ( self )
275 275 return self.hints
> 0 and (self.hint_icon
.. ' ' .. self.hints)
277 277 hl =
'DiagnosticHint',
281 - local is_svn_repo = function()
282 - local svn_dir
= vim.fs.find(
'.svn', {
281 + local is_svn_repo = function ()
282 + local svn_dir
= vim.fs.find(
'.svn', {
284 284 stop = vim.uv.os_homedir(),
285 - path = vim.fs.dirname(vim.api.nvim_buf_get_name(
0)),
285 + path = vim.fs.dirname( vim.api.nvim_buf_get_name(
0 ) ),
286 286 type =
'directory',
289 - return not vim.tbl_isempty(svn_dir)
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]' 292 + local svn_get_relative_url = function ()
293 + local job
= require 'plenary.job' 294 + local relative_url
= '[unversioned]' 298 - args = {
'info',
'--show-item',
'relative-url',
'--no-newline' },
299 - on_exit =
function(current_job, exit_code)
298 + args = {
'info',
'--show-item',
'relative-url',
'--no-newline' },
299 + on_exit =
function ( current_job, exit_code )
300 300 if exit_code
== 0 then relative_url
= current_job:result()
end 304 - return relative_url[
1]
304 + return type(relative_url)
== 'table' and relative_url[
1]
or relative_url
308 308 condition = is_svn_repo,
310 310 update =
'BufEnter',
312 - init =
function(self)
312 + init =
function ( self )
313 313 self.relative_url
= svn_get_relative_url()
317 - provider =
function(self)
318 - return icon.subversion
.. ' ' .. icon.branch
.. ' ' .. self.relative_url
317 + provider =
function ( self )
318 + return icon.subversion
.. ' ' .. icon.branch
.. ' ' .. self.relative_url
325 325 condition = conditions.is_git_repo,
327 - init =
function(self)
327 + init =
function ( self )
328 328 self.status_dict
= vim.b.gitsigns_status_dict
332 - provider =
function(self)
333 - return icon.git
.. " " .. icon.branch
.. " " .. self.status_dict.head
.. ' ' 332 + provider =
function ( self )
333 + return icon.git
.. ' ' .. icon.branch
.. ' ' .. self.status_dict.head
.. ' ' 337 - provider =
function(self)
337 + provider =
function ( self )
338 338 local count
= self.status_dict.added
or 0 339 - return count
> 0 and (icon.diff_add
.. " " .. count
.. ' ')
339 + return count
> 0 and (icon.diff_add
.. ' ' .. count
.. ' ')
344 - provider =
function(self)
344 + provider =
function ( self )
345 345 local count
= self.status_dict.removed
or 0 346 - return count
> 0 and (icon.diff_remove
.. " " .. count
.. ' ')
346 + return count
> 0 and (icon.diff_remove
.. ' ' .. count
.. ' ')
348 348 hl =
'DiffDelete',
351 - provider =
function(self)
351 + provider =
function ( self )
352 352 local count
= self.status_dict.changed
or 0 353 - return count
> 0 and (icon.diff_change
.. " " .. count
.. ' ')
353 + return count
> 0 and (icon.diff_change
.. ' ' .. count
.. ' ')
355 355 hl =
'DiffChange',
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()),
"~")
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)
369 + provider =
function ( self )
370 370 return self.icon
.. self.cwd
375 - provider =
function(self)
376 - local cwd
= vim.fn.pathshorten(self.cwd)
375 + provider =
function ( self )
376 + local cwd
= vim.fn.pathshorten( self.cwd )
377 377 return self.icon
.. cwd
386 - local help_file_name
= {
387 - condition =
function()
388 - return vim.bo.filetype
== "help" 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")
390 + provider =
function ()
391 + local filename
= vim.api.nvim_buf_get_name(
0 )
392 + return vim.fn.fnamemodify( filename,
':t' )
397 - local terminal_name
= {
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
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)
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 415 + local macro_recording
= {
416 + condition =
function ()
417 + return vim.fn.reg_recording()
~= '' and vim.o.cmdheight
== 0 419 - provider = icon.macro
.. " ",
419 + provider = icon.macro
.. ' ',
421 - utils.surround({
"░▒▓ ",
" ▓▒░" },
nil, {
422 - provider =
function()
421 + utils.surround( {
'░▒▓ ',
' ▓▒░' },
nil, {
422 + provider =
function ()
423 423 return vim.fn.reg_recording()
434 - condition =
function()
435 - local ok, lazy_status
= pcall(
require,
"lazy.status")
434 + condition =
function ()
435 + local ok, lazy_status
= pcall(
require,
'lazy.status' )
436 436 return ok
and lazy_status.has_updates()
438 - update = {
"User",
pattern =
"LazyUpdate" },
439 - provider =
function()
return ' ' .. icon.lazy
.. ' ' .. require'lazy.status'.updates()
.. ' ' end,
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",
441 + callback =
function ()
require 'lazy'.update()
end,
442 + name =
'update_plugins',
444 444 hl =
'LazyProgressTodo',
447 - local align
= {
provider =
"%=" }
448 - local space
= {
provider =
" " }
447 + local align
= {
provider =
'%=' }
448 + local space
= {
provider =
' ' }
450 - local default_statusline
= {
450 + local default_statusline
= {
451 451 vi_mode, macro_recording, align,
452 452 work_dir, space, git, svn, align,
453 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,
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" },
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
= {
472 + local terminal_statusline
= {
471 - condition =
function()
472 - return conditions.buffer_matches({
buftype = {
"terminal" } })
474 + condition =
function ()
475 + return conditions.buffer_matches {
buftype = {
'terminal' } }
475 - {
condition = conditions.is_active, vi_mode, space }, file_type, space, terminal_name, align,
478 + {
condition = conditions.is_active, vi_mode, space },
478 - local inactive_statusline
= {
485 + local inactive_statusline
= {
479 486 condition = conditions.is_not_active,
480 - file_type, space, file_name, align,
483 - local statuslines
= {
493 + local statuslines
= {
485 495 if conditions.is_active()
then 486 - return "StatusLine" 496 + return 'StatusLine' 488 - return "StatusLineNC" 498 + return 'StatusLineNC' 492 502 fallthrough =
false,
494 - special_statusline, terminal_statusline, inactive_statusline, default_statusline,
504 + special_statusline,
505 + terminal_statusline,
506 + inactive_statusline,
507 + default_statusline,
499 512 if conditions.is_active()
then 506 519 fallthrough =
false,
509 - condition =
function()
510 - return conditions.buffer_matches({
buftype = {
"terminal" } })
522 + condition =
function ()
523 + return conditions.buffer_matches {
buftype = {
'terminal' } }
513 - file_type, space, terminal_name,
520 - provider =
function(self)
521 - return "%" .. self.tabnr
.. "T " .. self.tabpage
.. " %T" 535 + provider =
function ( self )
536 + return '%' .. self.tabnr
.. 'T ' .. self.tabpage
.. ' %T' 523 - hl =
function(self)
538 + hl =
function ( self )
524 539 if not self.is_active
then 527 - return "TabLineSel" 542 + return 'TabLineSel' 532 - local tab_pages
= {
547 + local tab_pages
= {
534 - condition =
function()
549 + condition =
function ()
535 550 return #vim.api.nvim_list_tabpages()
>= 2 537 - {
provider =
"%=" },
538 - utils.make_tablist(tabpage),
552 + {
provider =
'%=' },
553 + utils.make_tablist( tabpage ),
541 - local tabline
= { tab_pages }
556 + local tabline
= { tab_pages }
553 - disable_winbar_cb =
function(args)
554 - return conditions.buffer_matches({
555 - buftype = {
"nofile",
"prompt",
"help",
"quickfix" },
556 - filetype = {
"^git.*",
"noice",
"Trouble" },
568 + disable_winbar_cb =
function ( args )
569 + return conditions.buffer_matches( {
570 + buftype = {
'nofile',
'prompt',
'help',
'quickfix' },
571 + filetype = {
'^git.*',
'noice',
'Trouble' },