diff options
| author | jdhao <jdhao@hotmail.com> | 2022-09-10 23:55:22 +0800 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2022-09-10 23:55:22 +0800 |
| commit | aaeb6a813a9044892e5bb76ba4a3a61db08eae4d (patch) | |
| tree | 6a1dc5a4f79f08678bdb8903a7920e8545718fa7 /lua/config/statusline.lua | |
| parent | 9ba728e201657892681cafc2c6fe8ad997873b49 (diff) | |
format with stylua
Diffstat (limited to 'lua/config/statusline.lua')
| -rw-r--r-- | lua/config/statusline.lua | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index bb018ce..846d561 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -11,9 +11,9 @@ end local function ime_state() if vim.g.is_mac then -- ref: https://github.com/vim-airline/vim-airline/blob/master/autoload/airline/extensions/xkblayout.vim#L11 - local layout = fn.libcall(vim.g.XkbSwitchLib, 'Xkb_Switch_getXkbLayout', '') - if layout == '0' then - return '[CN]' + local layout = fn.libcall(vim.g.XkbSwitchLib, "Xkb_Switch_getXkbLayout", "") + if layout == "0" then + return "[CN]" end end @@ -27,7 +27,7 @@ local function trailing_space() local line_num = nil - for i=1, fn.line('$') do + for i = 1, fn.line("$") do local linetext = fn.getline(i) -- To prevent invalid escape error, we wrap the regex string with `[[]]`. local idx = fn.match(linetext, [[\v\s+$]]) @@ -53,24 +53,26 @@ local function mixed_indent() local space_pat = [[\v^ +]] local tab_pat = [[\v^\t+]] - local space_indent = fn.search(space_pat, 'nwc') - local tab_indent = fn.search(tab_pat, 'nwc') + local space_indent = fn.search(space_pat, "nwc") + local tab_indent = fn.search(tab_pat, "nwc") local mixed = (space_indent > 0 and tab_indent > 0) local mixed_same_line if not mixed then - mixed_same_line = fn.search([[\v^(\t+ | +\t)]], 'nwc') + mixed_same_line = fn.search([[\v^(\t+ | +\t)]], "nwc") mixed = mixed_same_line > 0 end - if not mixed then return '' end + if not mixed then + return "" + end if mixed_same_line ~= nil and mixed_same_line > 0 then - return 'MI:'..mixed_same_line + return "MI:" .. mixed_same_line end - local space_indent_cnt = fn.searchcount({pattern=space_pat, max_count=1e3}).total - local tab_indent_cnt = fn.searchcount({pattern=tab_pat, max_count=1e3}).total + local space_indent_cnt = fn.searchcount({ pattern = space_pat, max_count = 1e3 }).total + local tab_indent_cnt = fn.searchcount({ pattern = tab_pat, max_count = 1e3 }).total if space_indent_cnt > tab_indent_cnt then - return 'MI:'..tab_indent + return "MI:" .. tab_indent else - return 'MI:'..space_indent + return "MI:" .. space_indent end end @@ -89,7 +91,7 @@ local diff = function() return info end -require("lualine").setup({ +require("lualine").setup { options = { icons_enabled = true, theme = "auto", @@ -105,19 +107,19 @@ require("lualine").setup({ lualine_b = { "branch", { - 'diff', - source = diff - } + "diff", + source = diff, + }, }, lualine_c = { "filename", { ime_state, - color = {fg = 'black', bg = '#f46868'} + color = { fg = "black", bg = "#f46868" }, }, { spell, - color = {fg = 'black', bg = '#a7c080'} + color = { fg = "black", bg = "#a7c080" }, }, }, lualine_x = { @@ -137,15 +139,15 @@ require("lualine").setup({ "location", { "diagnostics", - sources = { "nvim_diagnostic" } + sources = { "nvim_diagnostic" }, }, { trailing_space, - color = "WarningMsg" + color = "WarningMsg", }, { mixed_indent, - color = "WarningMsg" + color = "WarningMsg", }, }, }, @@ -158,6 +160,5 @@ require("lualine").setup({ lualine_z = {}, }, tabline = {}, - extensions = {'quickfix', 'fugitive', 'nvim-tree'}, -}) - + extensions = { "quickfix", "fugitive", "nvim-tree" }, +} |
