From 465b0af032cd9d459ca4d920eb121868e1bbf58f Mon Sep 17 00:00:00 2001 From: Felix Kratz Date: Mon, 9 May 2022 20:47:28 +0200 Subject: [PATCH] nicer feline default config --- lua/core/options.lua | 2 + lua/plugins/configs/statusline.lua | 214 ++++++++++------------------- 2 files changed, 73 insertions(+), 143 deletions(-) diff --git a/lua/core/options.lua b/lua/core/options.lua index c9346c4..425ed92 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -21,6 +21,8 @@ opt.smartindent = true -- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758 opt.fillchars = { eob = " " } +opt.showmode = false + opt.hidden = true opt.ignorecase = true opt.smartcase = true diff --git a/lua/plugins/configs/statusline.lua b/lua/plugins/configs/statusline.lua index 706c6db..db8c6ff 100644 --- a/lua/plugins/configs/statusline.lua +++ b/lua/plugins/configs/statusline.lua @@ -14,48 +14,73 @@ options.icon_styles = { default = { left = "", right = " ", - main_icon = "  ", - vi_mode_icon = " ", + main_icon = " ", + vi_mode_icon = " ", position_icon = " ", }, arrow = { left = "", right = "", - main_icon = "  ", - vi_mode_icon = " ", + main_icon = " ", + vi_mode_icon = "", position_icon = " ", }, block = { left = " ", right = " ", - main_icon = "  ", - vi_mode_icon = "  ", + main_icon = " ", + vi_mode_icon = "", position_icon = "  ", }, round = { left = "", right = "", - main_icon = "  ", - vi_mode_icon = " ", + main_icon = " ", + vi_mode_icon = " ", position_icon = " ", }, slant = { left = " ", right = " ", - main_icon = "  ", - vi_mode_icon = " ", + main_icon = " ", + vi_mode_icon = " ", position_icon = " ", }, } +options.mode_colors = { + ["n"] = { "NORMAL", options.colors.red }, + ["no"] = { "N-PENDING", options.colors.red }, + ["i"] = { "INSERT", options.colors.dark_purple }, + ["ic"] = { "INSERT", options.colors.dark_purple }, + ["t"] = { "TERMINAL", options.colors.green }, + ["v"] = { "VISUAL", options.colors.cyan }, + ["V"] = { "V-LINE", options.colors.cyan }, + [""] = { "V-BLOCK", options.colors.cyan }, + ["R"] = { "REPLACE", options.colors.orange }, + ["Rv"] = { "V-REPLACE", options.colors.orange }, + ["s"] = { "SELECT", options.colors.nord_blue }, + ["S"] = { "S-LINE", options.colors.nord_blue }, + [""] = { "S-BLOCK", options.colors.nord_blue }, + ["c"] = { "COMMAND", options.colors.pink }, + ["cv"] = { "COMMAND", options.colors.pink }, + ["ce"] = { "COMMAND", options.colors.pink }, + ["r"] = { "PROMPT", options.colors.teal }, + ["rm"] = { "MORE", options.colors.teal }, + ["r?"] = { "CONFIRM", options.colors.teal }, + ["!"] = { "SHELL", options.colors.green }, +} + options.separator_style = options.icon_styles[require("core.utils").load_config().plugins.options.statusline.separator_style] options.main_icon = { - provider = options.separator_style.main_icon, + provider = function() + return "  " .. options.mode_colors[vim.fn.mode()][1] .. " " + end, hl = { fg = options.colors.statusline_bg, @@ -71,17 +96,18 @@ options.main_icon = { }, } -options.file_name = { +options.dir_name = { provider = function() + local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") local filename = vim.fn.expand "%:t" local extension = vim.fn.expand "%:e" local icon = require("nvim-web-devicons").get_icon(filename, extension) if icon == nil then icon = " " - return icon end - return " " .. icon .. " " .. filename .. " " + return " " .. icon .. " " .. dir_name .. " " end, + hl = { fg = options.colors.white, bg = options.colors.lightbg, @@ -93,25 +119,6 @@ options.file_name = { }, } -options.dir_name = { - provider = function() - local dir_name = vim.fn.fnamemodify(vim.fn.getcwd(), ":t") - return "  " .. dir_name .. " " - end, - - hl = { - fg = options.colors.grey_fg2, - bg = options.colors.lightbg2, - }, - right_sep = { - str = options.separator_style.right, - hi = { - fg = options.colors.lightbg2, - bg = options.colors.statusline_bg, - }, - }, -} - options.diff = { add = { provider = "git_diff_added", @@ -119,7 +126,7 @@ options.diff = { fg = options.colors.grey_fg2, bg = options.colors.statusline_bg, }, - icon = " ", + icon = "  ", }, change = { @@ -227,121 +234,49 @@ options.lsp_progress = { options.lsp_icon = { provider = function() if next(vim.lsp.buf_get_clients()) ~= nil then - return "  LSP" + return "  LSP " else - return "" + return " " end end, hl = { fg = options.colors.grey_fg2, bg = options.colors.statusline_bg }, } -options.mode_colors = { - ["n"] = { "NORMAL", options.colors.red }, - ["no"] = { "N-PENDING", options.colors.red }, - ["i"] = { "INSERT", options.colors.dark_purple }, - ["ic"] = { "INSERT", options.colors.dark_purple }, - ["t"] = { "TERMINAL", options.colors.green }, - ["v"] = { "VISUAL", options.colors.cyan }, - ["V"] = { "V-LINE", options.colors.cyan }, - [""] = { "V-BLOCK", options.colors.cyan }, - ["R"] = { "REPLACE", options.colors.orange }, - ["Rv"] = { "V-REPLACE", options.colors.orange }, - ["s"] = { "SELECT", options.colors.nord_blue }, - ["S"] = { "S-LINE", options.colors.nord_blue }, - [""] = { "S-BLOCK", options.colors.nord_blue }, - ["c"] = { "COMMAND", options.colors.pink }, - ["cv"] = { "COMMAND", options.colors.pink }, - ["ce"] = { "COMMAND", options.colors.pink }, - ["r"] = { "PROMPT", options.colors.teal }, - ["rm"] = { "MORE", options.colors.teal }, - ["r?"] = { "CONFIRM", options.colors.teal }, - ["!"] = { "SHELL", options.colors.green }, -} - -options.chad_mode_hl = function() - return { - fg = options.mode_colors[vim.fn.mode()][2], - bg = options.colors.one_bg, - } -end - -options.empty_space = { - provider = " " .. options.separator_style.left, - hl = { - fg = options.colors.one_bg2, - bg = options.colors.statusline_bg, - }, -} - --- this matches the vi mode color -options.empty_spaceColored = { - provider = options.separator_style.left, - hl = function() - return { - fg = options.mode_colors[vim.fn.mode()][2], - bg = options.colors.one_bg2, - } - end, -} - -options.mode_icon = { - provider = options.separator_style.vi_mode_icon, - hl = function() - return { - fg = options.colors.statusline_bg, - bg = options.mode_colors[vim.fn.mode()][2], - } - end, -} - -options.empty_space2 = { - provider = function() - return " " .. options.mode_colors[vim.fn.mode()][1] .. " " - end, - hl = options.chad_mode_hl, -} - -options.separator_right = { - provider = options.separator_style.left, - hl = { - fg = options.colors.grey, - bg = options.colors.one_bg, - }, -} - -options.separator_right2 = { - provider = options.separator_style.left, - hl = { - fg = options.colors.green, - bg = options.colors.grey, - }, -} - -options.position_icon = { - provider = options.separator_style.position_icon, - hl = { - fg = options.colors.black, - bg = options.colors.green, - }, -} - options.current_line = { provider = function() local current_line = vim.fn.line "." + local current_col = vim.fn.col "." local total_line = vim.fn.line "$" + if current_col < 10 then + current_col = " " .. current_col + end + if current_line == 1 then - return " Top " + return "  " .. current_line .. ":" .. current_col .. "/" .. "Top " elseif current_line == vim.fn.line "$" then - return " Bot " + return "  " .. current_line .. ":" .. current_col .. "/" .. "Bot " end local result, _ = math.modf((current_line / total_line) * 100) - return " " .. result .. "%% " + + if result < 10 then + result = " " .. result + end + + return "  " .. current_line .. ":" .. current_col .. "/" .. result .. "%% " end, hl = { - fg = options.colors.green, - bg = options.colors.one_bg, + fg = options.colors.statusline_bg, + bg = options.colors.green, + }, + + left_sep = { + str = options.separator_style.left, + hl = { + fg = options.colors.green, + bg = options.colors.statusline_bg, + }, }, } @@ -360,27 +295,20 @@ options.right = {} -- left add_table(options.left, options.main_icon) -add_table(options.left, options.file_name) add_table(options.left, options.dir_name) +add_table(options.left, options.git_branch) add_table(options.left, options.diff.add) add_table(options.left, options.diff.change) add_table(options.left, options.diff.remove) -add_table(options.left, options.diagnostic.error) -add_table(options.left, options.diagnostic.warning) -add_table(options.left, options.diagnostic.hint) -add_table(options.left, options.diagnostic.info) add_table(options.middle, options.lsp_progress) -- right +add_table(options.right, options.diagnostic.error) +add_table(options.right, options.diagnostic.warning) +add_table(options.right, options.diagnostic.hint) +add_table(options.right, options.diagnostic.info) add_table(options.right, options.lsp_icon) -add_table(options.right, options.git_branch) -add_table(options.right, options.empty_space) -add_table(options.right, options.empty_spaceColored) -add_table(options.right, options.mode_icon) -add_table(options.right, options.empty_space2) -add_table(options.right, options.separator_right) -add_table(options.right, options.separator_right2) add_table(options.right, options.position_icon) add_table(options.right, options.current_line)