aboutsummaryrefslogtreecommitdiffstats
path: root/lua/plugins/lualine.lua
blob: b5a4b47963902681391bd3192f1e9f6e759fcb10 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
return {
  {
    'nvim-lualine/lualine.nvim',
    dependencies = {
      'kyazdani42/nvim-web-devicons',
      'arkav/lualine-lsp-progress',
    },
    opts = function()
      local function winnr() return '  ' .. vim.fn.winnr() end
      local function bufnr() return '󱔗 ' .. vim.fn.bufnr() end

      local function lualine_c(filename_opts)
        filename_opts = filename_opts or {}

        return {
          {
            'filetype',
            icon_only = true,
            separator = '',
            padding = { left = 1, right = 0 },
          },
          {
            'filename',
            file_status = filename_opts.file_status,
            padding = 0,
            path = filename_opts.fullpath and 1,
            separator = '',
          },
        }
      end

      local sections = {
        lualine_a = { winnr },
        lualine_b = { bufnr },
        lualine_d = lualine_c { fullpath = true },
        lualine_x = { 'searchcount' },
        lualine_y = {
          "diagnostics",
          "diff",
          {
            require("noice").api.status.mode.get,
            cond = require("noice").api.status.mode.has,
            color = { fg = "#ff9e64" },
          },
          {
            require("lazy.status").updates,
            cond = require("lazy.status").has_updates,
            color = { fg = "ff9e64" },
          },
        },
        lualine_z = { 'progress' },
      }

      return {
        options = {
          disabled_filetypes = { 'pi', 'dbui', 'fugitiveblame' },
          theme = 'catppuccin',
        },
        tabline = {
          lualine_a = {
            'mode',
            'selectioncount',
            function() return vim.fn.fnamemodify(vim.fn.getcwd(), ':p:~:h') end,
          },
          lualine_b = {
            function()
              local dap_status = require('dap').status()

              return dap_status ~= '' and '󰃤 ' .. dap_status or ''
            end,
          },
          lualine_x = { 'lsp_progress' },
          lualine_y = { { "branch", icon = "" }, "db_ui#statusline" },
          lualine_z = {
            {
              'tabs',
              show_modified_status = false,
              use_mode_colors = true,
            },
          },
        },
        sections = sections,
        inactive_sections = sections,
        extensions = {
          {
            filetypes = { 'fugitive', 'git' },
            sections = vim.tbl_extend('force', sections, {
              lualine_c = { { 'FugitiveHead', icon = '' } },
            }),
          },
          {
            filetypes = { 'help', 'man' },
            sections = vim.tbl_extend('force', sections, {
              lualine_c = lualine_c { file_status = false },
            }),
          },
          {
            filetypes = { 'oil' },
            sections = vim.tbl_extend('force', sections, {
              lualine_c = {
                {
                  function()
                    local dir = require('oil').get_current_dir()

                    return dir and vim.fn.fnamemodify(dir, ':p:~:.')
                  end,
                  icon = {
                    '',
                    color = {
                      fg = require('catppuccin.palettes').get_palette('frappe').maroon,
                    },
                  },
                },
              },
            }),
          },
          {
            filetypes = { 'qf' },
            sections = vim.tbl_extend('force', sections, {
              lualine_c = { 'w:quickfix_title' },
            }),
          },
        },
      }
    end,
  },
}