comparison .chezmoitemplates/init.lua @ 605:2828b29de182

switch to heirline as status line
author zegervdv <zegervdv@me.com>
date Fri, 15 Jul 2022 13:50:02 +0200
parents cfd937d65fdc
children 3fb4fbf5fde2
comparison
equal deleted inserted replaced
604:cfd937d65fdc 605:2828b29de182
432 } 432 }
433 433
434 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } } 434 use { 'vimjas/vim-python-pep8-indent', ft = { 'python' } }
435 435
436 use { 436 use {
437 'NTBBloodbath/galaxyline.nvim', 437 'rebelot/heirline.nvim',
438 branch = 'main', 438 config = function()
439 -- your statusline 439 local utils = require 'heirline.utils'
440 config = function() 440 local conditions = require 'heirline.conditions'
441 local gl = require 'galaxyline' 441
442 local colors = require('galaxyline.themes.colors').default 442 local colors = require('onedark.palette').dark
443 local condition = require 'galaxyline.condition' 443 colors.diag_warn = utils.get_highlight('DiagnosticSignWarn').fg
444 local gls = gl.section 444 colors.diag_error = utils.get_highlight('DiagnosticSignError').fg
445 445
446 colors.bg = '#2C323C' 446 require('heirline').load_colors(colors)
447 447
448 gls.left[1] = { 448 local align = { provider = '%=' }
449 RainbowRed = { 449 local space = { provider = ' ' }
450 provider = function() return '▊ ' end, 450 local lbound = { provider = '▊ ', hl = { fg = 'blue', bg = 'bg' } }
451 highlight = { colors.blue, colors.bg }, 451 local rbound = { provider = ' ▊', hl = { fg = 'blue', bg = 'bg' } }
452 }, 452
453 } 453 local FileNameBlock = {
454 454 init = function(self) self.filename = vim.api.nvim_buf_get_name(0) end,
455 gls.left[2] = { 455 }
456 FileName = { 456
457 provider = function() return require('galaxyline.providers.fileinfo').get_current_file_name '⊙' end, 457 local FileName = {
458 condition = condition.buffer_not_empty, 458 provider = function(self)
459 highlight = { colors.magenta, colors.bg, 'bold' }, 459 local filename = vim.fn.fnamemodify(self.filename, ':.')
460 }, 460 if filename == '' then return '[No Name]' end
461 } 461
462 462 return filename
463 gls.right[1] = { 463 end,
464 ShowLspClient = { 464 hl = { fg = 'blue' },
465 provider = 'GetLspClient', 465 }
466 condition = function() 466
467 local tbl = { ['dashboard'] = true, [''] = true } 467 local FileFlags = {
468 if tbl[vim.bo.filetype] then return false end 468 {
469 return true 469 provider = function()
470 if vim.bo.modified then return ' [+]' end
470 end, 471 end,
471 highlight = { colors.green, colors.bg, 'bold' }, 472 hl = { fg = 'green' },
472 }, 473 },
473 } 474 {
474 475 provider = function()
475 gls.right[2] = { 476 if not vim.bo.modifiable or vim.bo.readonly then return ' RO' end
476 LineInfo = { 477 end,
477 provider = 'LineColumn', 478 hl = { fg = 'orange' },
478 separator = ' ', 479 },
479 separator_highlight = { 'NONE', colors.bg }, 480 }
480 highlight = { colors.fg, colors.bg }, 481
481 }, 482 FileNameBlock = utils.insert(FileNameBlock, FileName, unpack(FileFlags), { provider = '%<' })
482 } 483
483 484 local Ruler = { provider = '%l : %c %P' }
484 gls.right[3] = { 485
485 PerCent = { 486 local Lsp = {
486 provider = 'LinePercent', 487 condition = conditions.lsp_attached,
487 separator = ' ', 488 update = { 'LspAttach', 'LspDetach' },
488 separator_highlight = { 'NONE', colors.bg }, 489 provider = function()
489 highlight = { colors.fg, colors.bg, 'bold' }, 490 local names = {}
490 }, 491 for _, server in pairs(vim.lsp.get_active_clients { bufnr = 0 }) do
491 } 492 table.insert(names, server.name)
492 gls.right[8] = { 493 end
493 RainbowBlue = { 494 return table.concat(names, ', ')
494 provider = function() return ' ▊' end, 495 end,
495 highlight = { colors.blue, colors.bg }, 496 hl = { fg = 'green' },
496 }, 497 }
497 } 498
498 499 local Diagnostics = {
499 gls.short_line_left[1] = { 500 condition = conditions.has_diagnostics,
500 BufferType = { 501 init = function(self)
501 provider = 'FileTypeName', 502 self.errors = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })
502 separator = ' ', 503 self.warnings = #vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })
503 separator_highlight = { 'NONE', colors.bg }, 504 end,
504 highlight = { colors.blue, colors.bg, 'bold' }, 505 update = { 'DiagnosticChanged', 'BufEnter' },
505 }, 506 {
506 } 507 provider = function(self) return self.errors > 0 and self.errors .. ' ' end,
507 508 hl = { fg = 'diag_error' },
508 gls.short_line_left[2] = { 509 },
509 SFileName = { 510 {
510 provider = 'SFileName', 511 provider = function(self) return self.warnings > 0 and self.warnings .. ' ' end,
511 condition = condition.buffer_not_empty, 512 },
512 highlight = { colors.fg, colors.bg, 'bold' }, 513 hl = { fg = 'diag_warn' },
513 }, 514 on_click = {
514 } 515 callback = function() require('trouble').toggle { mode = 'document_diagnostics' } end,
515 516 name = 'heirline_diagnostics',
516 gls.short_line_right[1] = { 517 },
517 BufferIcon = { provider = 'BufferIcon', highlight = { colors.fg, colors.bg } }, 518 }
518 } 519
520 local statusline_default = { lbound, FileNameBlock, align, Diagnostics, Lsp, space, Ruler, rbound }
521 local statusline_inactive = {
522 condition = function() return not conditions.is_active() end,
523 lbound,
524 FileNameBlock,
525 align,
526 rbound,
527 }
528 local statusline = {
529 init = utils.pick_child_on_condition,
530 hl = { bg = 'bg' },
531 statusline_inactive,
532 statusline_default,
533 }
534
535 require('heirline').setup(statusline)
519 end, 536 end,
520 } 537 }
521 538
522 -- File navigation 539 -- File navigation
523 use { 540 use {