From c7fdd680729ced2a3805f9aacd8c9910a902de1d Mon Sep 17 00:00:00 2001 From: siduck76 Date: Fri, 13 Aug 2021 12:12:43 +0530 Subject: [PATCH] statusline : add vimode colors --- lua/plugins/luasnip.lua | 7 ++-- lua/plugins/statusline.lua | 79 ++++++++++++++++++++++++-------------- lua/themes/norchad.lua | 4 +- 3 files changed, 55 insertions(+), 35 deletions(-) diff --git a/lua/plugins/luasnip.lua b/lua/plugins/luasnip.lua index bd7ee39c..d15cd79a 100644 --- a/lua/plugins/luasnip.lua +++ b/lua/plugins/luasnip.lua @@ -8,8 +8,8 @@ local t = function(str) end local check_back_space = function() - local col = vim.fn.col('.') - 1 - if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then + local col = vim.fn.col(".") - 1 + if col == 0 or vim.fn.getline("."):sub(col, col):match("%s") then return true else return false @@ -24,7 +24,7 @@ _G.tab_complete = function() elseif check_back_space() then return t "" else - return vim.fn['compe#complete']() + return vim.fn["compe#complete"]() end end _G.s_tab_complete = function() @@ -57,7 +57,6 @@ _G.completions = function() return npairs.check_break_line_char() end - vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) diff --git a/lua/plugins/statusline.lua b/lua/plugins/statusline.lua index 07af61eb..bbc49ae8 100644 --- a/lua/plugins/statusline.lua +++ b/lua/plugins/statusline.lua @@ -8,6 +8,9 @@ local gls = gl.section gl.short_line_list = {" "} +local left_separator = "" -- or " " +local right_separator = " " -- or "" + local global_theme = "themes/" .. vim.g.nvchad_theme local colors = require(global_theme) @@ -26,7 +29,7 @@ gls.left[2] = { return "  " end, highlight = {colors.statusline_bg, colors.nord_blue}, - separator = " ", + separator = right_separator .. " ", separator_highlight = {colors.nord_blue, colors.lightbg} } } @@ -44,7 +47,7 @@ gls.left[4] = { provider = {"FileName"}, condition = condition.buffer_not_empty, highlight = {colors.white, colors.lightbg}, - separator = " ", + separator = right_separator, separator_highlight = {colors.lightbg, colors.lightbg2} } } @@ -56,7 +59,7 @@ gls.left[5] = { return "  " .. dir_name .. " " end, highlight = {colors.grey_fg2, colors.lightbg2}, - separator = " ", + separator = right_separator, separator_highlight = {colors.lightbg2, colors.statusline_bg} } } @@ -121,7 +124,7 @@ gls.right[1] = { for _, client in ipairs(clients) do local filetypes = client.config.filetypes if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then - return " " .. "  " .. " LSP " + return " " .. "  " .. " LSP" end end return "" @@ -153,53 +156,71 @@ gls.right[3] = { } } +local active_mode = { + n = {"Normal", colors.red}, + i = {"Insert", colors.dark_purple}, + c = {"Command", colors.pink}, + V = {"Visual", colors.cyan}, + [""] = {"Visual", colors.cyan}, + v = {"Visual", colors.cyan}, + R = {"Replace", colors.orange}, + t = {"Terminal", colors.green} +} + +local function mode(m) + local chad_mode = active_mode[vim.fn.mode()][m] + + if chad_mode == "nil" then + return active_mode[vim.fn.mode()]["t"] + else + return chad_mode + end +end + gls.right[4] = { + left_round = { + provider = function() + vim.cmd("hi Galaxyleft_round guifg=" .. mode(2)) + return left_separator + end, + separator = " ", + separator_highlight = {colors.statusline_bg, colors.statusline_bg}, + highlight = {"GalaxyViMode", colors.statusline_bg} + } +} + +gls.right[5] = { viMode_icon = { provider = function() + vim.cmd("hi GalaxyviMode_icon guibg=" .. mode(2)) return " " end, - highlight = {colors.statusline_bg, colors.red}, - separator = " ", - separator_highlight = {colors.red, colors.statusline_bg} + highlight = {colors.statusline_bg, colors.red} } } -gls.right[5] = { +gls.right[6] = { ViMode = { provider = function() - local alias = { - n = "Normal", - i = "Insert", - c = "Command", - V = "Visual", - [""] = "Visual", - v = "Visual", - R = "Replace" - } - local current_Mode = alias[vim.fn.mode()] - - if current_Mode == nil then - return " Terminal " - else - return " " .. current_Mode .. " " - end + vim.cmd("hi GalaxyViMode guifg=" .. mode(2)) + return " " .. mode(1) .. " " end, - highlight = {colors.red, colors.lightbg} + highlight = {"GalaxyViMode", colors.lightbg} -- colors.red here will be overriden many times } } -gls.right[6] = { - some_icon = { +gls.right[7] = { + some_RoundIcon = { provider = function() return " " end, - separator = "", + separator = left_separator, separator_highlight = {colors.green, colors.lightbg}, highlight = {colors.lightbg, colors.green} } } -gls.right[7] = { +gls.right[8] = { line_percentage = { provider = function() local current_line = vim.fn.line(".") diff --git a/lua/themes/norchad.lua b/lua/themes/norchad.lua index 7f676279..f3e3e8d6 100644 --- a/lua/themes/norchad.lua +++ b/lua/themes/norchad.lua @@ -12,7 +12,7 @@ local colors = { light_grey = "#646a76", red = "#BF616A", baby_pink = "#de878f", - pink = "#e89199", + pink = "#d57780", line = "#3a404c", -- for lines like vertsplit green = "#A3BE8C", vibrant_green = "#afca98", @@ -21,7 +21,7 @@ local colors = { yellow = "#EBCB8B", sun = "#e1c181", purple = "#aab1be", - dark_purple = "##B48EAD", + dark_purple = "#B48EAD", teal = "#6484a4", orange = "#e39a83", cyan = "#9aafe6",