return {
  'rebelot/heirline.nvim',
  opts = function(_, opts)
    vim.opt.showtabline = 2
		vim.cmd([[au FileType * if index(['wipe', 'delete'], &bufhidden) >= 0 | set nobuflisted | endif]])
    vim.opt.showmode = false
    vim.opt.fillchars = { diff = ' ', eob = ' ', stlnc = '─', stl = '─', vert = '│', msgsep = '‾' }
    local conditions = require 'heirline.conditions'
    local utils = require 'heirline.utils'
    local Align = { provider = '%=' }
    local Space = { provider = '───' }
    local Blank = { provider = ' ' }
    local Git = {
      condition = conditions.is_git_repo,
      init = function(self)
        self.status_dict = vim.b.gitsigns_status_dict
        self.has_changes = self.status_dict.added ~= 0 or self.status_dict.removed ~= 0 or self.status_dict.changed ~= 0
      end,
      { -- git branch name
        provider = function(self)
          return '  ' .. self.status_dict.head .. ' '
        end,
        hl = { fg = 'orange', bold = true },
      },
      {
        provider = function(self)
          local count = self.status_dict.added or 0
          return count > 0 and ('+' .. count .. ' ')
        end,
        hl = 'GitSignsAdd',
      },
      {
        provider = function(self)
          local count = self.status_dict.removed or 0
          return count > 0 and ('-' .. count .. ' ')
        end,
        hl = 'GitSignsDelete',
      },
      {
        provider = function(self)
          local count = self.status_dict.changed or 0
          return count > 0 and ('~' .. count .. ' ')
        end,
        hl = 'GitSignsChange',
      },
      {
        condition = function(self)
          return self.has_changes
        end,
        provider = '',
      },
    }
    local ViMode = {
      init = function(self)
        self.mode = vim.fn.mode(1) -- :h mode()
      end,
      static = {
        mode_names = {
          n = '',
          no = ' OPERATOR PENDING ',
          nov = ' OPERATOR PENDING ',
          noV = ' OP LINE ',
          ['no\22'] = ' OP BLOCK ',
          niI = ' (INSERT) ',
          niR = ' (INSERT) REPLACE',
          niV = ' (INSERT) VISUAL',
          nt = '',
          v = ' VISUAL ',
          vs = ' VISUAL ',
          V = ' VISUAL LINE ',
          Vs = ' VISUAL LINE ',
          ['\22'] = ' VISUAL BLOCK ',
          ['\22s'] = ' VISUAL BLOCK ',
          s = ' SELECT ',
          S = ' SELECT LINE ',
          ['\19'] = ' SELECT BLOCK ',
          i = ' INSERT ',
          ic = ' COMPLETION ',
          ix = ' COMPLETION ',
          R = ' REPLACE ',
          Rc = ' REPLACE ',
          Rx = ' REPLACE ',
          Rv = ' VIRTUAL REPLACE ',
          Rvc = ' VIRTUAL REPLACE ',
          Rvx = ' VIRTUAL REPLACE ',
          c = ' COMMAND ',
          cv = ' EX ',
          r = ' ENTER ',
          rm = ' MORE ',
          ['r?'] = ' CONFIRM ',
          ['!'] = ' SHELL ',
          t = ' TERMINAL ',
        },
        mode_colors = {
          n = 'NONE',
          i = 'MediumSeaGreen',
          v = 'DeepSkyBlue',
          V = 'DeepSkyBlue',
          ['\22'] = 'DeepSkyBlue',
          c = 'orange',
          s = 'CornflowerBlue',
          S = 'CornflowerBlue',
          ['\19'] = 'CornflowerBlue',
          R = 'NavajoWhite1',
          r = 'NavajoWhite1',
          ['!'] = 'tomato',
          t = 'OrangeRed',
        },
      },
      provider = function(self)
        return '%2(' .. self.mode_names[self.mode] .. '%)'
      end,
      hl = function(self)
        local mode = self.mode:sub(1, 1) -- get only the first mode character
        return { fg = self.mode_colors[mode], bold = true }
      end,
      update = {
        'ModeChanged',
        pattern = '*:*',
        callback = vim.schedule_wrap(function()
          vim.cmd 'redrawstatus'
        end),
      },
    }
    local Ruler = {
      provider = ' :%l/%L ─ :%c/%-2{virtcol("$") - 1} ─ %p%% ',
      hl = 'Normal',
    }
    local HelpFileName = {
      condition = function()
        return vim.bo.filetype == 'help'
      end,
      provider = function()
        local filename = vim.api.nvim_buf_get_name(0)
        local formatted = vim.fn.fnamemodify(filename, ':t')
        return ' ' .. formatted .. ' '
      end,
      hl = { fg = 'CornflowerBlue' },
    }
    local TerminalName = {
      provider = function()
        local tname = '%{b:term_title}'
        return ' ' .. ' ' .. tname .. ' '
      end,
      hl = { fg = 'orange' },
    }
    -- statusline
    local DefaultStatusline = {
      Space,
      Git,
      Space,
      ViMode,
      Align,
      Ruler,
      Space,
    }
    local InactiveStatusline = {
      condition = conditions.is_not_active,
      Align,
    }
    local SpecialStatusline = {
      condition = function()
        return conditions.buffer_matches {
          buftype = { 'nofile', 'prompt', 'help', 'quickfix' },
          filetype = { '^git.*', 'fugitive', },
        }
      end,
      Align,
      HelpFileName,
      Align,
      Space,
    }
    local TerminalStatusline = {
      condition = function()
        return conditions.buffer_matches { buftype = { 'terminal' } }
      end,
      hl = { fg = 'OrangeRed' },
      { condition = conditions.is_active, Space, ViMode },
      Align,
      TerminalName,
      Align,
      Space,
    }
    opts.statusline = {
      fallthrough = false,
      SpecialStatusline,
      TerminalStatusline,
      InactiveStatusline,
      DefaultStatusline,
    }
		opts.disable_winbar_cb = function (args)
       return conditions.buffer_matches ({
          buftype = { 'nofile', 'prompt', 'help', 'quickfix' },
          filetype = { '^git.*', 'fugitive', 'Trouble' },
        }, args.buf)
		end
    -- tabline
    local TablineFileName = {
      provider = function(self)
        local filename = self.filename
        filename = filename == '' and '[No Name]' or vim.fn.fnamemodify(filename, ':t')
        return filename
      end,
    }
    local TablineFileFlags = {
      {
        condition = function(self)
          return vim.api.nvim_buf_get_option(self.bufnr, 'modified')
        end,
        provider = ' ',
        hl = { fg = 'turquoise' },
      },
      {
        condition = function(self)
          return not vim.api.nvim_buf_get_option(self.bufnr, 'modifiable')
            or vim.api.nvim_buf_get_option(self.bufnr, 'readonly')
        end,
        provider = function(self)
          if vim.api.nvim_buf_get_option(self.bufnr, 'buftype') == 'terminal' then
            return '  '
          else
            return ''
          end
        end,
        hl = { fg = 'OrangeRed' },
      },
    }
    local FileIcon = {
      init = function(self)
        local filename = self.filename
        local extension = vim.fn.fnamemodify(filename, ':e')
        self.icon, self.icon_color =
          require('nvim-web-devicons').get_icon_color(filename, extension, { default = true })
      end,
      provider = function(self)
        return self.icon and (self.icon .. ' ')
      end,
      hl = function(self)
        return { fg = self.icon_color }
      end,
    }
    local TablineFileNameBlock = {
      init = function(self)
        self.filename = vim.api.nvim_buf_get_name(self.bufnr)
      end,
      hl = function(self)
        if self.is_active then
          return 'TabLineSel'
        else
          return 'TabLine'
        end
      end,
      Blank,
      FileIcon,
      TablineFileName,
      Blank,
      TablineFileFlags,
      Blank,
    }
    local BufferLine = utils.make_buflist(TablineFileNameBlock)
    local Tabpage = {
      provider = function(self)
        return '%' .. self.tabnr .. 'T ' .. self.tabpage .. ' %T'
      end,
      hl = function(self)
        if not self.is_active then
          return 'TabLineSel'
        else
          return 'TabLine'
        end
      end,
    }
    local TabPages = {
      condition = function()
        return #vim.api.nvim_list_tabpages() >= 2
      end,
      utils.make_tablist(Tabpage),
    }
    opts.tabline = { BufferLine, Align, TabPages }
  end,
}
