vim/lualine: minor refactor
This commit is contained in:
parent
7a73598f76
commit
7f80e37117
1 changed files with 13 additions and 16 deletions
|
@ -1,7 +1,9 @@
|
||||||
local filename = require('lualine.component'):extend()
|
local M = {}
|
||||||
|
|
||||||
function filename:init(options)
|
M.filename = require('lualine.component'):extend()
|
||||||
filename.super.init(self, options)
|
|
||||||
|
function M.filename:init(options)
|
||||||
|
M.filename.super.init(self, options)
|
||||||
|
|
||||||
local color = options.color or {}
|
local color = options.color or {}
|
||||||
local modified = { gui = 'italic' }
|
local modified = { gui = 'italic' }
|
||||||
|
@ -18,7 +20,7 @@ function filename:init(options)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
function filename:update_status(is_focused)
|
function M.filename:update_status(is_focused)
|
||||||
self.options.color_highlight = self.custom_highlights[is_focused][vim.bo.modified]
|
self.options.color_highlight = self.custom_highlights[is_focused][vim.bo.modified]
|
||||||
|
|
||||||
local window = require 'fschauen.window'
|
local window = require 'fschauen.window'
|
||||||
|
@ -34,9 +36,9 @@ function filename:update_status(is_focused)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local mode = require('lualine.component'):extend()
|
M.mode = require('lualine.component'):extend()
|
||||||
|
|
||||||
mode.map = {
|
M.mode.map = {
|
||||||
['n'] = '', -- 'Normal ', -- Normal
|
['n'] = '', -- 'Normal ', -- Normal
|
||||||
['no'] = '', -- 'O-Pend ', -- Operator-pending
|
['no'] = '', -- 'O-Pend ', -- Operator-pending
|
||||||
['ni'] = '', -- 'Normal ', -- Normal via i_CTRL-O
|
['ni'] = '', -- 'Normal ', -- Normal via i_CTRL-O
|
||||||
|
@ -55,17 +57,17 @@ mode.map = {
|
||||||
['t'] = '', -- ' Term ', -- Terminal
|
['t'] = '', -- ' Term ', -- Terminal
|
||||||
}
|
}
|
||||||
|
|
||||||
function mode:update_status(is_focused)
|
function M.mode:update_status(is_focused)
|
||||||
if is_focused then
|
if is_focused then
|
||||||
local code = vim.api.nvim_get_mode().mode:lower()
|
local code = vim.api.nvim_get_mode().mode:lower()
|
||||||
local symbol = mode.map[code:sub(1, 2)] or mode.map[code:sub(1, 1)] or code
|
local symbol = M.mode.map[code:sub(1, 2)] or M.mode.map[code:sub(1, 1)] or code
|
||||||
return ' ' .. symbol .. ' '
|
return ' ' .. symbol .. ' '
|
||||||
end
|
end
|
||||||
|
|
||||||
return ' '
|
return ' '
|
||||||
end
|
end
|
||||||
|
|
||||||
local trailing_whitespace = function()
|
M.trailing_whitespace = function()
|
||||||
local pattern = [[\s\+$]]
|
local pattern = [[\s\+$]]
|
||||||
local lineno = vim.fn.search(pattern, 'nwc')
|
local lineno = vim.fn.search(pattern, 'nwc')
|
||||||
if lineno == 0 then
|
if lineno == 0 then
|
||||||
|
@ -82,7 +84,7 @@ local trailing_whitespace = function()
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
local colored_if_focused = function(component)
|
M.colored_if_focused = function(component)
|
||||||
if type(component) == 'string' then
|
if type(component) == 'string' then
|
||||||
local c = require('lualine.components.' .. component):extend()
|
local c = require('lualine.components.' .. component):extend()
|
||||||
|
|
||||||
|
@ -109,10 +111,5 @@ local colored_if_focused = function(component)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return M
|
||||||
colored_if_focused = colored_if_focused,
|
|
||||||
filename = filename,
|
|
||||||
mode = mode,
|
|
||||||
trailing_whitespace = trailing_whitespace,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue