summary refs log tree commit diff
path: root/.vim/lua/line.lua
blob: 278782f7e04994f6414676a32f8d4c01aa69969b (plain) (blame)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
-- statusline

local gl  = require('galaxyline')
local gls = gl.section
local gcolors = require('galaxyline.colors')

local colors = {
  blue = '#5fafd7',
  orange = '#d7875f',
  purple = '#af87d7',
  yellow = '#d7af5f',

  black = '#1c1c1c',
  grey_dim = '#3a3a3a',
  grey_dimmer = '#262626',
  white = '#d0d0d0',
  white_dim = '#bdc0ba',
}

local style = {
  left = {
    sep = ' ',
    sep_hl = {colors.white, colors.black},
  },
  right = {
    hl = {colors.white,colors.grey_dimmer},
    sep = ' ',
    sep_hl = {colors.grey_dim, colors.grey_dimmer},
  }
}

local empty_buffer = function()
  if vim.fn.empty(vim.fn.expand('%:t')) ~= 1 then
    return true
  end
    return false
end

local space = function() return ' ' end

gls.left[1] = {
  ViMode = {
    provider = function()
      local m = vim.fn.mode()
      if m == 'n' then
        gcolors.set_highlight('GalaxyViMode', {colors.white, colors.grey_dim, 'bold'})
      elseif m == 'i' then
        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.blue, 'bold'})
      elseif m == 'v' or m == 'V' or m == 'CTRL-V' then
        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.purple, 'bold'})
      elseif m == 's' or m == 'S' or m == 'CTRL-S' then
        gcolors.set_highlight('GalaxyViMode', {colors.black, '#ff0000', 'bold'})
      elseif m == 'R' or m == 'Rc' or m == 'Rv' or m == 'Rx' then
        gcolors.set_highlight('GalaxyViMode', {colors.black, colors.orange, 'bold'})
      elseif m == 'c' then
        gcolors.set_highlight('GalaxyViMode', {colors.yellow, colors.grey_dim, 'bold,italic'})
      end
      return '  ' .. m:gsub("^%l*$", string.upper) .. ' '
    end,
    separator = style.left.sep,
    separator_highlight = style.left.sep_hl,
  },
}

gls.left[2] = {
  FileName = {
    provider = function()
      local file = vim.fn.expand('%:t')
      if vim.fn.empty(file) == 1 then return '' end
      if vim.bo.readonly then
        return file .. ' '
      end
      if vim.o.modifiable then
        if vim.bo.modified then
          return file .. ' +'
        end
      end
      return file .. ' '
    end,
    condition = empty_buffer,
    highlight = {colors.white,colors.grey_dimmer},
    separator = style.left.sep,
    separator_highlight = style.left.sep_hl,
  }
}

-- ########################################################## --

gls.right[1] = {
  Indent = {
    provider = function()
      local res = vim.o.expandtab and '→' or '␣'
      return res
        .. ' '
        .. 'ts=' .. vim.o.tabstop
        .. ' '
        .. 'sw=' .. vim.o.shiftwidth
    end,
    highlight = style.right.hl,
  },
}

gls.right[2] = {
  BufNum = {
    icon = '% ',
    provider = function()
      local nbufs = #vim.fn.getbufinfo({buflisted = 1})
      local res = vim.fn.bufnr('%') .. '(' .. nbufs .. ')'
      if vim.fn.tabpagenr() > 1 then
        res = res .. ':' .. vim.fn.tabpagenr()
      end
      return res
    end,
    highlight = style.right.hl,
    separator = style.right.sep,
    separator_highlight = style.right.sep_hl,
  },
}

gls.right[3] = {
  LineColumn = {
    icon = ' ',
    provider = 'LineColumn',
    highlight = style.right.hl,
    separator = style.right.sep,
    separator_highlight = style.right.sep_hl,
  },
}

gls.right[4] = {
  LinePercent = {
    provider = 'LinePercent',
    highlight = style.right.hl,
    separator = style.right.sep,
    separator_highlight = style.right.sep_hl,
  }
}

gls.right[5] = {
  BufferType = {
    provider = function() return '  ' .. vim.bo.filetype .. ' ' end,
    highlight = {colors.white,colors.grey_dim,'bold'},
    -- separator = style.right.sep,
    -- separator_highlight = style.right.sep_hl,
  }
}